Does SDL know size of SDL_FULLSCREEN?

Member
Posts: 321
Joined: 2004.10
Post: #1
My program is creating a full screen, but my rendering is still just doing the 1000x1000. Is there a way that I can query SDL so that it will tell me the size of
its full screen? Or am I just suppose to know ahead of time what sizes to use?

Code:
height = 1000;
width = 1000;

flags = SDL_OPENGL | SDL_FULLSCREEN;      
drawContext = SDL_SetVideoMode(height, width, 0, flags);
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
SDL has a mechanism for listing video modes, which you should be using to choose your window size. I'm sure it also has a mechanism for retrieving the current window size. You should read the documentation!

http://www.libsdl.org/cgi/docwiki.cgi/

[edit]I found specific answers within the first 20 seconds of looking at the documentation page[/edit]
Quote this message in a reply
Member
Posts: 72
Joined: 2006.10
Post: #3
You can use SDL_VideoInfo() wich, if called before SDL_SetVideoMode(), returns info about the desktop video mode.

Code:
const SDL_VideoInfo * lInfo = SDL_GetVideoInfo(void);

height = lInfo->current_w ;
width =  lInfo->current_h ;

Wich would set a context in the current resolution. There must be a more elegant way to do this, but my SDL memories are a bit foggy.
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #4
I think sohta answered your question, but the mechanism OSC was talking about is probably SDL_ListModes and my implementation looks like this:

Code:
SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
    if(modes == (SDL_Rect **)0)
    {
        printf("No fullscreen display modes available!\n");
    }
    else
    {
        for(int i=0; modes[i]; ++i)
        {
            DisplayMode displayMode;
            displayMode.width = modes[i]->w;
            displayMode.height = modes[i]->h;
            
            _availableDisplayModes.push_back(displayMode);
        }
    }

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Post Reply