Page 1 of 1

Getting a list of available screen resolutions

PostPosted: 23 Jan 2010, 21:04
by qubodup
How to let the player/user pick from all the resolutions his machine/display provides? It appears that the SDL_ListModes() function is not reliable. Does anyone else share that experience? Did you find a way around it? Or do you provide a hand-written list of possible resolutions?
If a manual solution is the case: where can one get a list like that? Grumbel created a list of popular resolutions on our wiki: http://freegamedev.net/wiki/Screen_Resolutions and Wikipedia has a list too: http://en.wikipedia.org/wiki/List_of_common_resolutions . Do you know where such a list is available for easy import? (Otherwise someone will have to hack some regex/sed :))
And even when such a list is at hand, how to prevent the user from picking a resolution not supported by his graphics card and/or monitor?

Re: Getting a list of available screen resolutions

PostPosted: 24 Jan 2010, 15:18
by amuzen
If you want to remain portable, you should use the resolution list returned by SDL_ListModes(). At least on my system, it seems to do exactly what you're asking for: it lists the same 22 supported resolutions as xrandr, and the largest resolution in the list is the native resolution of the monitor. The list is queried from the system (RandR on X11) so if there are problems with it, your system is likely configured incorrectly.

I tried to search for complaints regarding the function but didn't find much so far. There were a few related to multiple monitor setups, but I think a custom resolution list would be even less desirable for those people. If you really wanted to use a custom resolution list, I guess you could supplement the list provided by SDL with it, but using the custom list alone doesn't sound like a good idea to me. I don't know if it will solve more problems than it will cause, though.

Re: Getting a list of available screen resolutions

PostPosted: 25 Jan 2010, 04:00
by andrewj
Should use SDL_ListModes, but also allow the user to specify a custom mode.

The only way to be sure a mode works is to call SDL_SetVideoMode and check the result. If it fails, try different depth, and if that fails, keep trying other resolutions until something works.

Note for OpenGL apps, all uploaded textures must be deleted before changing the video mode (and subsequently re-uploaded afterwards), otherwise you'll get texture corruption problems on various OSes.

Re: Getting a list of available screen resolutions

PostPosted: 25 Jan 2010, 15:52
by qubodup
andrewj {l Wrote}:...otherwise you'll get texture corruption problems on various OSes.

You mean fun stuff like this? :D

Re: Getting a list of available screen resolutions

PostPosted: 30 Jan 2010, 16:01
by Sauer2
Well, that might turn out hilarious, if the last image in the gfx memory was porn and the owner of a commercial game complains about it in the hotline. :)

Anyway, it seems that the SDL resolution choosing function doesn't like 1280 x 1024 (althought i think it is pretty common, ain't it?), because some SDL games set the wrong resolution at the beginning. Then my monitor says something like "%3°# crap!" and i have to change it by the configuration file.

So lection one: If you plan to make a game that supports fullscreen, never :!: forget a configuration file or command line parameters.