SDL Function To Return Desktop Screen Size?

SDL Function To Return Desktop Screen Size ?

JeZ+Lee
SLNTHERO at aol.com
www.SilentHeroProductions.com

Here’s what I do in Tux Paint (when you run “tuxpaint --fullscreen --native”):

if (native) {
screen = SDL_SetVideoMode(0, 0, {bpp}, SDL_FULLSCREEN | {other flags});

width = screen->w;
height = screen->h;
} else {
screen = SDL_SetVideoMode(width, height, {bpp}, {flags});
}

In other words, if you try to open a 0x0 full-screen display, SDL will
end up using the desktop’s resolution. (Then you can fetch the size
via the ‘w’ and ‘h’ of the surface it sent back.)

I know this isn’t the same as “querying”, but it might be all you need…On Mon, Sep 28, 2009 at 05:18:35PM -0400, Jesse Palser wrote:

SDL Function To Return Desktop Screen Size ?


-bill!
Sent from my computer

Also:On September 28, 2009, Bill Kendrick wrote:

On Mon, Sep 28, 2009 at 05:18:35PM -0400, Jesse Palser wrote:

SDL Function To Return Desktop Screen Size ?

Here’s what I do in Tux Paint (when you run “tuxpaint --fullscreen
–native”):

if (native) {
screen = SDL_SetVideoMode(0, 0, {bpp}, SDL_FULLSCREEN | {other
flags}); …
width = screen->w;
height = screen->h;
} else {
screen = SDL_SetVideoMode(width, height, {bpp}, {flags});
}

OK, lets try that again:

SDL_VideoInfo* info = SDL_GetVideoInfo();
width = info->current_w;
height = info->current_h;

This only works in SDL 1.2.11 or higher, I believe.

SAOn September 28, 2009, Bill Kendrick wrote:

On Mon, Sep 28, 2009 at 05:18:35PM -0400, Jesse Palser wrote:

SDL Function To Return Desktop Screen Size ?

Here’s what I do in Tux Paint (when you run “tuxpaint --fullscreen
–native”):

if (native) {
screen = SDL_SetVideoMode(0, 0, {bpp}, SDL_FULLSCREEN | {other
flags}); …
width = screen->w;
height = screen->h;
} else {
screen = SDL_SetVideoMode(width, height, {bpp}, {flags});
}

And in SDL 1.3:
SDL_GetDesktopDisplayMode()On Mon, Sep 28, 2009 at 3:06 PM, Stephen Anthony wrote:

On September 28, 2009, Bill Kendrick wrote:

On Mon, Sep 28, 2009 at 05:18:35PM -0400, Jesse Palser wrote:

SDL Function To Return Desktop Screen Size ?

Here’s what I do in Tux Paint (when you run “tuxpaint --fullscreen
–native”):

? if (native) {
? ? screen = SDL_SetVideoMode(0, 0, {bpp}, SDL_FULLSCREEN | {other
flags}); …
? ? width = screen->w;
? ? height = screen->h;
? } else {
? ? screen = SDL_SetVideoMode(width, height, {bpp}, {flags});
? }

OK, lets try that again:

?SDL_VideoInfo* info = SDL_GetVideoInfo();
?width = info->current_w;
?height = info->current_h;

This only works in SDL 1.2.11 or higher, I believe.

SA


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

Hello !

And in SDL 1.3:
SDL_GetDesktopDisplayMode()

This question is popping into my head right now :

Is there also a way to get the actual desktop colordepth,
like if it is 8, 16, 24, 32 bit colors ?

CU

If you look at the API, you’ll see it fills in one of these:
typedef struct
{
Uint32 format; /< pixel format */
int w; /
< width */
int h; /< height */
int refresh_rate; /
< refresh rate (or zero for unspecified) */
void *driverdata; /**< driver-specific data, initialize to 0 */
} SDL_DisplayMode;On Mon, Sep 28, 2009 at 6:54 PM, Torsten Giebl wrote:

Hello !

And in SDL 1.3:
SDL_GetDesktopDisplayMode()

This question is popping into my head right now :

Is there also a way to get the actual desktop colordepth,
like if it is 8, 16, 24, 32 bit colors ?

CU


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

Hi Bill,

Your code to get desktop screen resolution worked for me!

Thanks…

JeZ+Lee
SLNTHERO at aol.com
www.SilentHeroProductions.com

Bill Kendrick wrote:> On Mon, Sep 28, 2009 at 05:18:35PM -0400, Jesse Palser wrote:

SDL Function To Return Desktop Screen Size ?

Here’s what I do in Tux Paint (when you run “tuxpaint --fullscreen --native”):

if (native) {
screen = SDL_SetVideoMode(0, 0, {bpp}, SDL_FULLSCREEN | {other flags});

width = screen->w;
height = screen->h;
} else {
screen = SDL_SetVideoMode(width, height, {bpp}, {flags});
}

In other words, if you try to open a 0x0 full-screen display, SDL will
end up using the desktop’s resolution. (Then you can fetch the size
via the ‘w’ and ‘h’ of the surface it sent back.)

I know this isn’t the same as “querying”, but it might be all you need…

If you look at the API, you’ll see it fills in one of these:
typedef struct
{
Uint32 format; /**< pixel format */

Hm, and what does “pixel format” mean? That seems underdocumented to
me… :).

int w; /< width */
int h; /
< height */
int refresh_rate; /**< refresh rate (or zero for
unspecified) */

What unit? Hz, I guess? Would be nice if the doxygen comments would
specify that, saves us from having to RTFS :).

void *driverdata; /**< driver-specific data, initialize
to 0 */
} SDL_DisplayMode;

Cheers,
MaxAm 29.09.2009 um 04:16 schrieb Sam Lantinga: