Getting a list of available screen resolutions

Getting a list of available screen resolutions

Postby qubodup » 23 Jan 2010, 21:04

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?
User avatar
qubodup
Global Moderator
 
Posts: 1671
Joined: 08 Nov 2009, 22:52
Location: Berlin, Germany

Re: Getting a list of available screen resolutions

Postby amuzen » 24 Jan 2010, 15:18

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.
User avatar
amuzen
LoS Moderator
 
Posts: 327
Joined: 05 Dec 2009, 02:49

Re: Getting a list of available screen resolutions

Postby andrewj » 25 Jan 2010, 04:00

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.
User avatar
andrewj
 
Posts: 194
Joined: 15 Dec 2009, 16:32
Location: Tasmania

Re: Getting a list of available screen resolutions

Postby qubodup » 25 Jan 2010, 15:52

andrewj {l Wrote}:...otherwise you'll get texture corruption problems on various OSes.

You mean fun stuff like this? :D
User avatar
qubodup
Global Moderator
 
Posts: 1671
Joined: 08 Nov 2009, 22:52
Location: Berlin, Germany

Re: Getting a list of available screen resolutions

Postby Sauer2 » 30 Jan 2010, 16:01

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.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Who is online

Users browsing this forum: No registered users and 1 guest