codeape Posted March 11, 2015 Share Posted March 11, 2015 I am pplaying with changing the resolution in my game. My idea was to start simple ... Hit L and the resolution is changed. So when So when I call window->SetLayout(0, 0, 1600, 1200) the resolution is not changed from the default 1024x768.Codes: #include "App.h"#include "game/BranchLoop.h"using namespace Leadwerks;App::App() : window(NULL), context(NULL), world(NULL), camera(NULL), loop(NULL){}App::~App() { if (NULL != loop) { delete loop; } if (NULL != world) { delete world; } if (NULL != window) { delete window; }}bool App::Start(){ //Initialize Steamworks (optional) /*if (!Steamworks::Initialize()) { System::Print("Error: Failed to initialize Steam."); return false; }*/ //Create a window window = Leadwerks::Window::Create("branch"); //Create a context context = Context::Create(window); //Create a world world = World::Create(); //Create a camera camera = Camera::Create(); camera->Move(0,2,-5); loop = new Branch::BranchLoop(context, window, camera); //Hide the mouse cursor window->HideMouse(); std::string mapname = System::GetProperty("map","Maps/start.map"); Map::Load(mapname); //Move the mouse to the center of the screen window->SetMousePosition(context->GetWidth()/2,context->GetHeight()/2); return true;}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)) { window->ShowMouse(); return false; } if (window->KeyHit(Key::L)) { System::Print("Change layout"); window->SetLayout(0, 0, 1600, 1200); } loop->preRenderUpdate(); Leadwerks::Time::Update(); world->Update(); world->Render(); loop->postRenderUpdate(); context->Sync(false); return true;} And yeha, I get the output "Change layout" but nothing happens. Link to comment Share on other sites More sharing options...
codeape Posted March 12, 2015 Author Share Posted March 12, 2015 The code works in Windows. When I hit the L key the window is resized to 1600x1200 from 1024x768. This is a Linux only bug. Anyone else that experiense this in Linux? Link to comment Share on other sites More sharing options...
DerRidda Posted March 13, 2015 Share Posted March 13, 2015 I haven't specifically tried that yet but it was already clear that basically none of the windowing features work under Linux. Just take a look at the full screen situation that still doesn't fully work let alone all the other window flags. Link to comment Share on other sites More sharing options...
codeape Posted March 16, 2015 Author Share Posted March 16, 2015 I haven't specifically tried that yet but it was already clear that basically none of the windowing features work under Linux. Just takea look at the full screen situation that still doesn't fully work let alone all the other window flags. Mmmmm True. I forgot my specs. Linux dist: $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.2 LTS Release: 14.04 Codename: trusty Graphics card: fglrxinfo display: :0 screen: 0 OpenGL vendor string: Advanced Micro Devices, Inc. OpenGL renderer string: AMD Radeon HD 5700 Series OpenGL version string: 4.3.12798 Compatibility Profile Context 13.35.1005 A question. Will this bug be fixed soon or something that will be included when you get in to fixing the Uniform buffers and FBOs mentioned in this blog post: http://www.leadwerks.com/werkspace/blog/1/entry-1427-34-recap-and-beyond/ Link to comment Share on other sites More sharing options...
beo6 Posted March 17, 2015 Share Posted March 17, 2015 I think Josh said that he will fix Linux bugs. Not sure which bugs exactly. But then, Josh says a lot of things when the day is long. (No offence intended) Link to comment Share on other sites More sharing options...
Josh Posted March 17, 2015 Share Posted March 17, 2015 This is the actual code for SetLayout: void Window::SetLayout(const int x, const int y, const int width, const int height) { XMoveResizeWindow(this->display,this->window,x,y,width,height); } 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 More sharing options...
codeape Posted March 17, 2015 Author Share Posted March 17, 2015 This is the actual code for SetLayout: void Window::SetLayout(const int x, const int y, const int width, const int height) { XMoveResizeWindow(this->display,this->window,x,y,width,height); } Ok, so you probably need to call XSetWMNormalHints before you call XMoveResizewindow. This is because some window managers may redirect window configuration requests, but ignore the resulting events and pay property changes instead. Some more info ... Page 623 in this book: https://books.google.se/books?id=2uVfJj_4AZgC&printsec=frontcover&source=gbs_ge_summary_r&cad=0#v=onepage&q&f=false This man page: http://manpages.ubuntu.com/manpages/saucy/man3/XAllocSizeHints.3.html 1 Link to comment Share on other sites More sharing options...
codeape Posted March 19, 2015 Author Share Posted March 19, 2015 (edited) Ok I have done some more research. A god idea is to read this: http://www.hpc.unimelb.edu.au/nec/g1ae02e/appd.html, and clean out all obsolete stuff like XSetStandardProperties (Pre X11 legacy stuff). Also XMoveResizeWindow can sometimes be ignored and we end up with no-op: http://tronche.com/gui/x/xlib/window/XMoveResizewindow.html I think this is some good hints from SDL that can interpreted like this: // Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the // XResizeWindow, thus we must set the size hints to adjust the window size. XSizeHints *sizehints = XAllocSizeHints(); long userhints; XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); sizehints->min_width = sizehints->max_width = window->w; sizehints->min_height = sizehints->max_height = window->h; sizehints->flags |= PMinSize | PMaxSize; XSetWMNormalHints(display, data->xwindow, sizehints); XFree(sizehints); // WMs each have their little quirks with that. When you change the // size hints, they get a ConfigureNotify event with the // WM_NORMAL_SIZE_HINTS Atom. They all save the hints then, but they // dont all resize the window right away to enforce the new hints. // Some of them resize only after: // - A user-initiated move or resize // - A code-initiated move or resize // - Hiding & showing window (Unmap & map) // The following move & resize seems to help a lot of WMs that didn't // properly update after the hints were changed. We don't do a // hide/show, because there are supposedly subtle problems with doing so // and transitioning from windowed to fullscreen in Unity. XResizeWindow(display, data->xwindow, window->w, window->h); XMoveWindow(display, data->xwindow, window->x, window->y); XRaiseWindow(display, data->xwindow); Inspired by X11_SetWindowSize (https://hg.libsdl.org/SDL/file/3331d2f57704/src/video/x11/SDL_x11window.c#l831) The comments about Unity in that file is very interesting also since that is the only WM that Leadwerks support. Edited March 19, 2015 by codeape Link to comment Share on other sites More sharing options...
codeape Posted March 30, 2015 Author Share Posted March 30, 2015 Any progress on this? Link to comment Share on other sites More sharing options...
codeape Posted April 8, 2015 Author Share Posted April 8, 2015 Another good example is from the godot engine: https://github.com/okamstudio/godot/blob/a12c364489df586bf3cbb38f613c0615f88eaff1/platform/x11/os_x11.cpp So what are your thoughts about this problem Josh? Link to comment Share on other sites More sharing options...
codeape Posted April 16, 2015 Author Share Posted April 16, 2015 So I have done a bunch of research for this. Some feedback. An update. Any of your new helpers that speak Xlib? Link to comment Share on other sites More sharing options...
DerRidda Posted April 18, 2015 Share Posted April 18, 2015 That's a damn good question. Link to comment Share on other sites More sharing options...
beo6 Posted April 18, 2015 Share Posted April 18, 2015 Maybe I could try to make a resolution change into a library for lua. Would have to test it under Linux though. Link to comment Share on other sites More sharing options...
Josh Posted April 18, 2015 Share Posted April 18, 2015 This is not high priority right now. 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 More sharing options...
codeape Posted April 18, 2015 Author Share Posted April 18, 2015 This is not high priority right now. Why is this not high priority? When will it be high priority? Is there a workaround? Link to comment Share on other sites More sharing options...
Josh Posted April 19, 2015 Share Posted April 19, 2015 It's low priority because the information needed to fix this is not readily available, and full-screen mode in Linux only presently supports the native monitor resolution. So it's not like not being able to change the size of a windowed game on Linux is holding anyone back right now. 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 More sharing options...
codeape Posted April 24, 2015 Author Share Posted April 24, 2015 I solved it with this little code change: window = Leadwerks::Window::Create("test", 0, 0, 1024, 768, Leadwerks::Window::Resizable); The key was setting the style argument of Window::Create() to Leadwerks::Window::Resizable. The Leadwerks C++ template code looks like this: Leadwerks::Window::Create("branch"); The style argument defaults to Leadwerks::Window::Titlebar and that does apparently not play nice with SetLayout in Linux but works well in Windows. Link to comment Share on other sites More sharing options...
Josh Posted April 24, 2015 Share Posted April 24, 2015 Interesting. This is the code in Linux that handles the resize creation flag: if (Window::Resizable & style) { XSetStandardProperties(display, window->window, name, name, 0L, NULL, 0, NULL); } else { sizehints.flags = PMinSize | PMaxSize; sizehints.min_width = width; sizehints.min_height = height; sizehints.max_width = width; sizehints.max_height = height; XSetStandardProperties(display, window->window, name, name, 0L, NULL, 0, &sizehints); } 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 More sharing options...
codeape Posted April 27, 2015 Author Share Posted April 27, 2015 Interesting. This is the code in Linux that handles the resize creation flag: if (Window::Resizable & style) { XSetStandardProperties(display, window->window, name, name, 0L, NULL, 0, NULL); } else { sizehints.flags = PMinSize | PMaxSize; sizehints.min_width = width; sizehints.min_height = height; sizehints.max_width = width; sizehints.max_height = height; XSetStandardProperties(display, window->window, name, name, 0L, NULL, 0, &sizehints); } The XSetStandardProperties function has been superseded by XSetWMProperties. Link to comment Share on other sites More sharing options...
DerRidda Posted April 28, 2015 Share Posted April 28, 2015 The XSetStandardProperties function has been superseded by XSetWMProperties. I think that was pointed out somewhere else before. Or it was another function where X used to do things solo and is now asking the WM for "permission". Link to comment Share on other sites More sharing options...
Recommended Posts