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();