aiaf Posted May 8, 2020 Share Posted May 8, 2020 How do i get the desktop native resolution size in leadwerks ? I want to create a window full screen with the size of the user desktop screen. I seen in API: CountGraphicsModes GetGraphicsMode Probably been asked before but i searched and didnt find a solution. Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
Marcousik Posted May 8, 2020 Share Posted May 8, 2020 This is a good question, because I had a lot of problem with this with my little race game. Starting in fullscreen mode was buggy because it selected automatic the biggest resolution possible, so only a part of the image was projected on the screen. The player had to change manually the resolution in the options to get it running ok, if the user windows screen resolution setting was lower as the biggest possible. Some weird thing I never get solved. And this is no way for commercial games. I had to start the game in windowded mode to get it run fine. Quote Link to comment Share on other sites More sharing options...
gamecreator Posted May 8, 2020 Share Posted May 8, 2020 It's come up before and I don't believe Leadwerks does this, which means you'd need to use system functions. The workaround is that you can take the last (largest) resolution from GetGraphicsMode which works most (but not all) of the time. Quote Link to comment Share on other sites More sharing options...
reepblue Posted May 9, 2020 Share Posted May 9, 2020 My window code is here that has the solution: 1 Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Solution aiaf Posted May 9, 2020 Author Solution Share Posted May 9, 2020 I get it, selecting the last resolution from GetGraphicsMode works. On my side i get a 2560x1440 fullscreen. Thanks , this basically answers my question. Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
Marcousik Posted May 10, 2020 Share Posted May 10, 2020 @reepblue Sorry I am working in lua in LE4.6 But I don't understand how you solve the screen detection problem, how/where do you get the current windows user resolution ? Quote // Create a window Leadwerks::Window* window; std::string windowtitle = App::GetName(); if (IsDebug()) windowtitle = windowtitle + " [Debug]"; if (fullscreenmode) { iVec2 gfx = System::GetGraphicsMode(Leadwerks::System::CountGraphicsModes() - 1); window = Leadwerks::Window::Create(windowtitle, 0, 0, gfx.x, gfx.y, Leadwerks::Window::Fullscreen, parent); } This seems to select as before the biggest value " System::CountGraphicsModes() - 1 " ?? Quote Link to comment Share on other sites More sharing options...
gamecreator Posted May 10, 2020 Share Posted May 10, 2020 5 hours ago, Marcousik said: But I don't understand how you solve the screen detection problem, how/where do you get the current windows user resolution ? This seems to select as before the biggest value " System::CountGraphicsModes() - 1 " ?? Yes, it looks like he's doing the same thing I mentioned, taking the last resolution from the list. It doesn't actually detect the desktop resolution. Quote Link to comment Share on other sites More sharing options...
aiaf Posted May 10, 2020 Author Share Posted May 10, 2020 Yes, its exactly what i did. I tested on my windows desktop and linux laptop and it works. Seem to always return highest resolution supported. Quote I made this with Leadwerks/UAK: Structura | Stacky Desktop Edition Website: Binary Station Link to comment Share on other sites More sharing options...
gamecreator Posted May 10, 2020 Share Posted May 10, 2020 There's a reason I said that it works for "most" above. I made a mini-game once using this autodetection, I think for a Leadwerks tournament, and someone said it didn't work for them. I can't find the thread now. Quote Link to comment Share on other sites More sharing options...
reepblue Posted May 10, 2020 Share Posted May 10, 2020 9 hours ago, Marcousik said: @reepblue Sorry I am working in lua in LE4.6 But I don't understand how you solve the screen detection problem, how/where do you get the current windows user resolution ? This seems to select as before the biggest value " System::CountGraphicsModes() - 1 " ?? You can take a look at the sample menu code for options to see how to obtain all resolutions with lua. Fullscreen doesn't work for everyone for some reason. I had multiple computers run Leadwerks with no issues. The only time I had an issue was when I had that Samsung Magic for SSD motoring running in the background. So I think some apps prevent fullscreen working properly for some reason. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
gamecreator Posted May 10, 2020 Share Posted May 10, 2020 For the sake of completeness, here are 2 methods in Windows to detect the desktop size: RECT desktop; // Get a handle to the desktop window const HWND hDesktop = GetDesktopWindow(); // Get the size of screen to the variable desktop GetWindowRect(hDesktop, &desktop); cout << "Desktop size: " << desktop.right << ", " << desktop.bottom << '\n'; DWORD dwWidth = GetSystemMetrics(SM_CXSCREEN); DWORD dwHeight = GetSystemMetrics(SM_CYSCREEN); cout << "Desktop size: " << dwWidth << ", " << dwHeight << '\n'; Sources: https://stackoverflow.com/questions/8690619/how-to-get-screen-resolution-in-c https://stackoverflow.com/questions/17504954/windows-get-screen-resolution-in-c 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.