[SDL] How to get user's current window dimensions & bit depth?

Sam Lantinga slouken at devolution.com
Mon Aug 7 12:33:53 PDT 2000


> How can I get the current display dimensions?

Here's a snippet of code we use at Loki:

int sdl_GetScreenSize(int *width, int *height)
{
    SDL_SysWMinfo info;
    int retval;

    retval = 0;
    SDL_VERSION(&info.version);
    if ( SDL_GetWMInfo(&info) > 0 ) {
#ifdef unix
        if ( info.subsystem == SDL_SYSWM_X11 ) {
            info.info.x11.lock_func();
            if ( width ) {
                *width = DisplayWidth(info.info.x11.display,
                            DefaultScreen(info.info.x11.display));
            }
            if ( height ) {
                *height = DisplayHeight(info.info.x11.display,
                            DefaultScreen(info.info.x11.display));
            }
            info.info.x11.unlock_func();
            retval = 1;
        }
#else
#error Need to implement these functions for other systems
#endif // unix
    }
    return retval;
}

See ya!
	-Sam Lantinga, Lead Programmer, Loki Entertainment Software



More information about the SDL mailing list