Is there a portable way to get the current desktop resolution, so my
program can default to that resolution when it opens a full-screen
window?
It used to be reasonable to just start at a low resolution like 640x480
and let the user choose to switch to a higher one, but these days
that’s not very practical any more, with the widespread use of LCD
monitors (which look really crappy at the wrong resolution) and
widescreen monitors (which look even more crappy at the wrong
resolution; you can’t take a 4x3 aspect ratio for granted now).–
Ross Smith … @Ross_Smith … Auckland, New Zealand
"Those who can make you believe absurdities can
make you commit atrocities." – Voltaire
FLTK does it (static functions of the Monitor class), but if you only
want to use this small set of functions it might be a bit oversized.
I think, the better way is waiting for SDL 1.3. This is just like
Christmas, when SDL 1.3 will get released.
Ross Smith schrieb:> Is there a portable way to get the current desktop resolution, so my
program can default to that resolution when it opens a full-screen
window?
It used to be reasonable to just start at a low resolution like 640x480
and let the user choose to switch to a higher one, but these days
that’s not very practical any more, with the widespread use of LCD
monitors (which look really crappy at the wrong resolution) and
widescreen monitors (which look even more crappy at the wrong
resolution; you can’t take a 4x3 aspect ratio for granted now).
Le Vendredi 18 Ao?t 2006 11:01, Ross Smith a ?crit?:
Is there a portable way to get the current desktop resolution, so my
program can default to that resolution when it opens a full-screen
window?
It used to be reasonable to just start at a low resolution like 640x480
and let the user choose to switch to a higher one, but these days
that’s not very practical any more, with the widespread use of LCD
monitors (which look really crappy at the wrong resolution) and
widescreen monitors (which look even more crappy at the wrong
resolution; you can’t take a 4x3 aspect ratio for granted now).
int with = 0;
int height = 0;
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWMInfo(&info) > 0 ) {
#ifdef unix
if (info.subsystem == SDL_SYSWM_X11) {
info.info.x11.lock_func();
width = DisplayWidth(info.info.x11.display,
DefaultScreen(info.info.x11.display));
height = DisplayHeight(info.info.x11.display,
DefaultScreen(info.info.x11.display));
info.info.x11.unlock_func();
}
#elif defined(WIN32)
RECT desktopRect;
HWND desktop = GetDesktopWindow();
GetWindowRect(desktop, &desktopRect);
width = desktopRect.right - desktopRect.left;
height = desktopRect.bottom - desktopRect.top;
#else
#warning blah not implemented
width = 640;
height = 480;
#endif
You might need to adjust the env vars …
Regards,
Johannes
Taken from the SDL 1.2.10 announcement back a few months:
- Added current_w and current_h to the SDL_VideoInfo structure, which is set
to the desktop resolution during video intialization, and then set to the
current resolution when a video mode is set.
You can also specify 0 for width and height, when calling SetVideoMode and
it will default to the desktop size.
Talk about portable!
-Dave> ----- Original Message -----
From: r-smith@ihug.co.nz (Ross Smith)
To:
Sent: Friday, August 18, 2006 4:01 AM
Subject: [SDL] Desktop resolution
Is there a portable way to get the current desktop resolution, so my
program can default to that resolution when it opens a full-screen
window?
It used to be reasonable to just start at a low resolution like 640x480
and let the user choose to switch to a higher one, but these days
that’s not very practical any more, with the widespread use of LCD
monitors (which look really crappy at the wrong resolution) and
widescreen monitors (which look even more crappy at the wrong
resolution; you can’t take a 4x3 aspect ratio for granted now).
–
Ross Smith … r-smith at ihug.co.nz … Auckland, New Zealand
"Those who can make you believe absurdities can
make you commit atrocities." – Voltaire
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl