Jump to content

Getting the desktop resolution


aiaf
 Share

Go to solution Solved by aiaf,

Recommended Posts

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.

 

 

 

Link to comment
Share on other sites

@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 "  ??

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...