Enumerating GL modes portably

Hi everyone,

I’m new to SDL and I would like to use it just as portable GL context
creation layer. So, is there a portable and lightweight way to query
OpenGL display formats available on client’s machine?

Thanks in advance,
Alex

I’m new to SDL and I would like to use it just as portable GL context
creation layer. So, is there a portable and lightweight way to query
OpenGL display formats available on client’s machine?

You can use SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_OPENGL) to get a
list of resolutions, but it’s a little more complicated to find the
"best" GL display format.

Generally you’ll have to set everything as high as you want it, and see
if you can get it, and if not, slowly start reducing values until you
either get something, or can’t get an acceptable minimum.

Quake 3 has a fairly complex method of doing this, but it’s pretty
robust. Look for the “for (i = 0; i < 16; i++)” in GLimp_SetMode() …

http://svn.icculus.org/checkout/quake3/trunk/code/sdl/sdl_glimp.c

Although, in my experience, you can usually just do…

SDL_SetVideoMode(640, 480, 0, SDL_OPENGL);

…and deal with whatever on reasonable hardware. :slight_smile:

–ryan.

Thank you, Ryan.

And, may be I should reformulate my question: is there a portable
SDL-style alternative to glxinfo?

Alex