Search the Community
Showing results for tags 'drawtext'.
-
Hello every one. Today i am working on raycast, and a wanted to draw key value of an entity, but unfortunately it's doesn't draw text ;( Here is a screenshot of the render: As you can see i am drawing first fps (who works) then draw the line and to finish draw keyvalue of the hit box (Fail) Here is my code: bool App::Loop() { //quit ? if (window->Closed() or window->KeyHit(Key::Escape))return false; Red->Move(); Green->Move(); Blue->Move(); world->Update(); if (window->KeyDown(Key::Right)) { camera->SetRotation(Vec3(camera->GetRotation().x, camera->GetRotation().y + 4, camera->GetRotation().z)); } //REFRESH STUFF Time::Update(); context->SetColor(0, 0, 0, 0); context->Clear(); world->Render(); //DRAW FPS context->SetBlendMode(Blend::Alpha); context->SetColor(255, 0, 0, 1); context->DrawText("FPS : " + String(Time::UPS()), 10, 20); //DRAW LINE context->SetBlendMode(Blend::Solid); context->SetColor((world->Pick(rayCastFirst, rayCastEnd, pickInfo) ? (rayCastColorOn) : (rayCastColorOff))); context->DrawLine(camera->Project(rayCastFirst).x, camera->Project(rayCastFirst).y, camera->Project(rayCastEnd).x, camera->Project(rayCastEnd).y); //set sphere to hit hitSphere->SetPosition((world->Pick(rayCastFirst, rayCastEnd, pickInfo,0,true)) ? (pickInfo.position) : (rayCastFirst) ); //if hit DRAW KEY VALUE if (world->Pick(rayCastFirst, rayCastEnd, pickInfo, 0, true)) { //fail context->SetColor(1, 1, 1, 1); context->SetBlendMode(Blend::Alpha); context->DrawText(pickInfo.entity->GetKeyValue("Color"), 20, 40); } context->Sync(true); return true; } Any reply will be appreciate ?
-
I'm attempting to implement a simple x,y display for the mouse and x,y,z for the camera, but I cannot get any text display to work. I'm using the context::DrawText() command, I've attempted drawing the text before the world and vice versa to see if that was the issue, but that didn't work either. The documentation example doesn't use any 3d rendering in the demo code, so I have no idea if I'm rendering everything in the correct order. Here is a copy of the app loop I was testing with //Close the window to end the program if (window->Closed()) return false; //Press escape to end freelook mode if (window->KeyHit(Key::Escape)) { if (!freelookmode) return false; freelookmode = false; window->ShowMouse(); } if (freelookmode) { //Keyboard movement float strafe = (window->KeyDown(Key:) - window->KeyDown(Key::A))*Leadwerks::Time::GetSpeed() * 0.05; float move = (window->KeyDown(Key::W) - window->KeyDown(Key::S))*Leadwerks::Time::GetSpeed() * 0.05; camera->Move(strafe, 0, move); //Get the mouse movement float sx = context->GetWidth() / 2; float sy = context->GetHeight() / 2; Vec3 mouseposition = window->GetMousePosition(); float dx = mouseposition.x - sx; float dy = mouseposition.y - sy; //Adjust and set the camera rotation camerarotation.x += dy / 10.0; camerarotation.y += dx / 10.0; camera->SetRotation(camerarotation); //Move the mouse to the center of the screen window->SetMousePosition(sx, sy); } context->SetColor(0, 0, 0); context->Clear(); //Draw some centered text on the screen std::string text = "Leadwerks"; Font* font = context->GetFont(); int x = context->GetWidth() / 2; int y = context->GetHeight() / 2; x -= font->GetTextWidth(text) / 2; y -= font->GetHeight() / 2; context->SetBlendMode(Blend::Alpha); context->SetColor(1, 1, 1); context->DrawText(text, x, y); context->SetBlendMode(Blend::Solid); Leadwerks::Time::Update(); world->Update(); world->Render(); context->Sync();
-
I've gotten my text entry function almost finished but I need to add a cursor to it which seems tricker than I first thought. When using Context:DrawText are there any special characters in the same way as ASCII control chars, things like blink or reverse or do I have to emulate them? Assuming the latter is there an easy way to get how many pixels a text stream took to be displayed or is there a way to effectively append more text in a second DrawText Command.