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

Hi there,

re: Writing configuration dialog for AlteredSaver.
I can get a user’s current bit depth as follows:

if (0 == SDL_Init(SDL_INIT_VIDEO))
{
const SDL_VideoInfo* info = SDL_GetVideoInfo();
currentBPP = info->vfmt->BitsPerPixel;
//blah blah…
SDL_Quit();
}

How can I get the current display dimensions? I tried adding the
following, but (perhaps not suprisingly) it didn’t work:
SDL_Surface* getDim = SDL_GetVideoSurface();
if (getDim)
{
curWidth = getDim->w;
curHeight= getDim->h;
}

Any ideas?
thanks,

Tom Gilbert
http://www.AlteredWorlds.com

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

re: Writing configuration dialog for AlteredSaver.
I can get a user’s current bit depth as follows:

always use SDL_SetVideoMode()

How can I get the current display dimensions?

It might not have any. Think windowed buffers

Thanks Sam, and happy birthday!

Tom Gilbert
http://www.AlteredWorlds.com

Sam Lantinga wrote:>

How can I get the current display dimensions?

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