-   Programming (
-   -   Possible screen resolutions in C/C++ (

yezu 08-04-2009 05:43 AM

Possible screen resolutions in C/C++
I am writing a game in OpenGL and I have encountered a problem.
I cannot find a way to get all possible screen resolutions.

SDL is not much of help unfortunately as SDL_ListModes tells me that "all resolutions are supported" which is pretty much useless :/

I have been looking for the xrandr code, and I found it a bit overwhelming :/

Can anyone help me find a solution, or at least provide some hints?

thanks :)

dmail 08-04-2009 06:40 AM


If it is called before SDL_SetVideoMode, the vfmt member of the returned structure will contain the pixel format of the best video mode.
... This read-only structure is returned by SDL_GetVideoInfo. It contains information on either the best available mode if called before SDL_SetVideoMode or the current video mode if called after SDL_SetVideoMode.

yezu 08-04-2009 07:09 AM

Thanks but SDL_GetVideoInfo is also useless as it only gives me the CURRENT resolution :/

dmail 08-04-2009 07:20 AM


std::list<LVD::Renderer::Resoultion> create_mode_list()
        SDL_PixelFormat format;
        SDL_Rect **modes;
        std::list<Resoultion_entry> mode_list;
        int loops(0);
        int bpp(0);
                //format.BitsPerPixel seems to get zeroed out on my windows box
                        case 0://32 bpp
                                format.BitsPerPixel = 32;
                                bpp = 32;
                        case 1://24 bpp
                                format.BitsPerPixel = 24;
                                bpp = 24;
                        case 2://16 bpp
                                format.BitsPerPixel = 16;
                                bpp = 16;

                //get available fullscreen/hardware modes
                modes=SDL::SDL_ListModes(&format, SDL_FULLSCREEN);
                        for(int i=0;modes[i];++i)
                                LVD::Renderer::Resoultion entry(modes[i]->w,modes[i]->h, bpp/*format.BitsPerPixel*/, 0);
        }while(++loops != 3);
        return mode_list;

knudfl 08-04-2009 07:54 AM

Do you mean
640x480, 800x600, 1024x768, 1152x864, 1280x768, 1280x960, 1280x1024
like the settings in 'gl-117' ?
(( gl-117-1.3.2-src/src/conf.cpp ))
Other OpenGL game with res. settings : Emilia Pinball

All times are GMT -5. The time now is 06:23 PM.