LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Possible screen resolutions in C/C++ (http://www.linuxquestions.org/questions/programming-9/possible-screen-resolutions-in-c-c-744987/)

yezu 08-04-2009 06:43 AM

Possible screen resolutions in C/C++
 
Hi!
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 07:40 AM

SDL_GetVideoInfo
Quote:

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 08:09 AM

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

dmail 08-04-2009 08:20 AM

Code:

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);
        do
        {
                //format.BitsPerPixel seems to get zeroed out on my windows box
                switch(loops)
                {
                        case 0://32 bpp
                                format.BitsPerPixel = 32;
                                bpp = 32;
                                break;
                        case 1://24 bpp
                                format.BitsPerPixel = 24;
                                bpp = 24;
                                break;
                        case 2://16 bpp
                                format.BitsPerPixel = 16;
                                bpp = 16;
                                break;
                }

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


knudfl 08-04-2009 08:54 AM

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


All times are GMT -5. The time now is 07:20 PM.