Jump to content

Context not resizing correctly


 Share

Recommended Posts

Hello,

 

the active context is not resizing correctly when changing the window layout without rendering a world.

 

Resizing while rendering a world:

post-7919-0-76873200-1408546579_thumb.png

post-7919-0-34735300-1408546585_thumb.png

 

Resizing without rendering a world:

post-7919-0-19333300-1408546605_thumb.png

post-7919-0-14956000-1408546615_thumb.png

 

Example code:

 

bool App::Loop()
{
//Close the window to end the program
if (window->Closed()) return false;

if (window->KeyHit(Key::J))
{
window->SetLayout(window->GetX(), window->GetY(), 1920, 1080);
}
if (window->KeyHit(Key::K))
{
window->SetLayout(window->GetX(), window->GetY(), 1024, 800);
}
//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);
//}
Leadwerks::Time::Update();
//world->Update();
//world->Render();
context->SetColor(0, 0, 0, 1);
context->Clear();

context->SetColor(1, 1, 1, 1);
context->SetBlendMode(Blend::Alpha);
context->DrawText("10x10", 10, 10);
context->DrawText("100x100", 100, 100);
context->SetBlendMode(Blend::Solid);
context->Sync(false);

return true;
}

 

Comment / Uncomment the world update and rendering and press J and K a few times to resize.

Link to comment
Share on other sites

That's interesting. There's not any command in the loop that recalculates the orthogonal projection when the context changes size.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

You can add this after the Sync() call, and in the next build it will just work automatically without this code:

    GraphicsDriver::GetCurrent()->projectionmatrix.Ortho(0, context->GetWidth(), 0, context->GetHeight(), -1, 1);
   glViewport(0, 0, context->GetWidth(), context->GetHeight());

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...