aarrowh Posted November 12, 2014 Share Posted November 12, 2014 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(); Quote Link to comment Share on other sites More sharing options...
Rick Posted November 12, 2014 Share Posted November 12, 2014 Your 2D drawing functions have to be after world->Render() and before context->Sync(). world->Render() draws the 3D world so if you draw 2D text before that the 3D world drawn gets drawn over your 2D text so it's gone. What you want is to render the 3D world first and then draw the 2D on top of that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.