codeape Posted April 24, 2015 Posted April 24, 2015 I want to be able to toggle between diffren windows styles (FullScreen and Resizable). For all examples I have created I have used a new project and only added the if (window->KeyHit(Key::R)) block and I create the window in App::Start() with Leadwerks::Window::Create("test", 0, 0, 1024, 768, Leadwerks::Window::Resizable); Example one. I can toggle from windowed mode to full screen mode but not back to windowed mode with this code: bool App::Loop() { //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); } if (window->KeyHit(Key::R)) { if (window->style == Leadwerks::Window::FullScreen) { System::Print("Go Resizable"); window->Release(); window = Leadwerks::Window::Create("test", 0, 0, 800, 600, Leadwerks::Window::Resizable); } else { System::Print("Go FullScreen"); window->Release(); window = Leadwerks::Window::Create("test", 0, 0, 1920, 1200, Leadwerks::Window::FullScreen); } //Create a context context = Context::Create(window); window->HideMouse(); window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2); } Leadwerks::Time::Update(); world->Update(); world->Render(); context->Sync(false); return true; } So when I hit R i get in to full screen but when I hit R again I do not get back to windowed mode. When I hit ESC twice I get back my desktop by exiting the application. Example 2. So to test what happens behind the sceens I changed the if (window->KeyHit(Key::R)) block to this: if (window->KeyHit(Key::R)) { if (window->style == Leadwerks::Window::Titlebar) { System::Print("Go Resizable"); window->Release(); window = Leadwerks::Window::Create("test", 0, 0, 1024, 768, Leadwerks::Window::Resizable); } else { System::Print("Go other size"); window->Release(); window = Leadwerks::Window::Create("test", 0, 0, 800, 600, Leadwerks::Window::Titlebar); } //Create a context context = Context::Create(window); window->HideMouse(); window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2); } Everytime I hit R I get a new window but the old window is not removed (so I get a large amount os windows). What am I doing wrong? or is this a bug? Quote
Josh Posted April 25, 2015 Posted April 25, 2015 It looks like there may be a bug. Try setting window->takeownership to true and see if that makes the XWindow get deleted. Quote My job is to make tools you love, with the features you want, and performance you can't live without.
codeape Posted April 27, 2015 Author Posted April 27, 2015 Sorry for the late answer but I have been busy with my kids I can confirm that window->takeownership work. I have changed my code to this and I can now create a new window and get the old window destroyed: if (window->KeyHit(Key::R)) { window->takeownership = true; if (window->style == Leadwerks::Window::FullScreen) { System::Print("Go Resizable"); window->Release(); window = Leadwerks::Window::Create("test", 0, 0, 1024, 768, Leadwerks::Window::Resizable); } else { System::Print("Go FullScreen"); window->Release(); window = Leadwerks::Window::Create("test", 0, 0, 1920, 1200, Leadwerks::Window::FullScreen); } //Create a context context = Context::Create(window); window->HideMouse(); window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2); } Thanks Quote
codeape Posted April 30, 2015 Author Posted April 30, 2015 Josh, should I post this to the Bug forum? Thanks for the help by the way Quote
Josh Posted May 1, 2015 Posted May 1, 2015 It's already fixed in the source and will make it out in the next update. Thanks. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without.
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.