Toggling Fullscreen

Hi :slight_smile:

I’d like to include the option to switch from Fullscreen to Window mode for
my game (during the game via the options screen). Can anyone tell me the
correct way in which to do this…

If my main screen is

SDL_Surface *screen = SDL_SetVideoMode(640, 480, 8,
SDL_HWSURFACE|SDL_HWPALETTE);

is it safe to,

SDL_FreeSurface(screen)

and then

screen = SDL_SetVideoMode(640, 480, 8,
SDL_HWSURFACE|SDL_HWPALETTE|SDL_FULLSCREEN);

Or will that cause problems?

Cheers :slight_smile:

http://sdldoc.csn.ul.ie/sdlwmtogglefullscreen.phpOn Thu, 2002-12-19 at 10:37, Sweeney, Steven (FNB) wrote:

Hi :slight_smile:

I’d like to include the option to switch from Fullscreen to Window mode for
my game (during the game via the options screen). Can anyone tell me the
correct way in which to do this…

Also know as Read the Manual! :slight_smile:

Thank You :))> -----Original Message-----

From: Shawn [SMTP:drevil at warpcore.org]
Sent: Thursday, December 19, 2002 5:20 PM
To: sdl at libsdl.org
Subject: Re: [SDL] Toggling Fullscreen

On Thu, 2002-12-19 at 10:37, Sweeney, Steven (FNB) wrote:

Hi :slight_smile:

I’d like to include the option to switch from Fullscreen to Window mode
for
my game (during the game via the options screen). Can anyone tell me the
correct way in which to do this…

http://sdldoc.csn.ul.ie/sdlwmtogglefullscreen.php


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

.sophos.3.64.12.19.

So according to that man page, it won’t work on Windows. Is there a way to
toggle between full screen and windowed on Windows?On December 19, 2002 10:19 am, Shawn wrote:

On Thu, 2002-12-19 at 10:37, Sweeney, Steven (FNB) wrote:

Hi :slight_smile:

I’d like to include the option to switch from Fullscreen to Window mode
for my game (during the game via the options screen). Can anyone tell me
the correct way in which to do this…

http://sdldoc.csn.ul.ie/sdlwmtogglefullscreen.php


Brad Pepers
@Brad_Pepers

“Sweeney, Steven (FNB)” wrote:

Hi :slight_smile:

I’d like to include the option to switch from Fullscreen to Window mode for
my game (during the game via the options screen). Can anyone tell me the
correct way in which to do this…

If my main screen is

SDL_Surface *screen = SDL_SetVideoMode(640, 480, 8,
SDL_HWSURFACE|SDL_HWPALETTE);

is it safe to,

SDL_FreeSurface(screen)

It is NEVER safe to SDL_FreeSurface(screen) imho. SDL handles it totally for
you.

and then

screen = SDL_SetVideoMode(640, 480, 8,
SDL_HWSURFACE|SDL_HWPALETTE|SDL_FULLSCREEN);

That oughta work; experimented with this myself, works without difficulty.> Cheers :slight_smile:


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Brad Pepers wrote:

So according to that man page, it won’t work on Windows. Is there a way to
toggle between full screen and windowed on Windows?


Brad Pepers
brad at linuxcanada.com

Calling ‘screen = SDL_SetVideoMode(yadayadayada);’ again with the
SDL_FULLSCREEN flag will do it. As for the manpage, the comments there are
nearly two years old; that might be fixed by now. Only way to know for sure is
to try it.

It’s not safe to free your main screen?

I do that at the end of all my progs, right before SDL_Quit()… is this
bad?> -----Original Message-----

From: Corona688 [SMTP:tsm at accesscomm.ca]
Sent: Thursday, December 19, 2002 5:47 PM
To: sdl at libsdl.org
Subject: Re: [SDL] Toggling Fullscreen

“Sweeney, Steven (FNB)” wrote:

Hi :slight_smile:

I’d like to include the option to switch from Fullscreen to Window mode
for
my game (during the game via the options screen). Can anyone tell me the
correct way in which to do this…

If my main screen is

SDL_Surface *screen = SDL_SetVideoMode(640, 480, 8,
SDL_HWSURFACE|SDL_HWPALETTE);

is it safe to,

SDL_FreeSurface(screen)

It is NEVER safe to SDL_FreeSurface(screen) imho. SDL handles it totally
for
you.

and then

screen = SDL_SetVideoMode(640, 480, 8,
SDL_HWSURFACE|SDL_HWPALETTE|SDL_FULLSCREEN);

That oughta work; experimented with this myself, works without
difficulty.

Cheers :slight_smile:


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

.sophos.3.64.12.19.

“Sweeney, Steven (FNB)” wrote:

It’s not safe to free your main screen?

Nope. See http://sdldoc.csn.ul.ie/sdlsetvideomode.php

“Return Value - The framebuffer surface, or NULL if it fails. The surface
returned is freed by SDL_Quit() and shouldn’t be freed by the caller.”

I do that at the end of all my progs, right before SDL_Quit()… is this bad?

Yup. It’s amazing what sort of memory corruption Windows can let you get away
with, though; I once accidentally set a program of mine to free the video
surface - EVERY FRAME - and actually got away with it for a few weeks. Only
when I added more code and started using more memory did it start crashing on
me, and I had a heck of a time trying to find out why. >.>

Okay, thanks :slight_smile:

I know what you mean about Windows letting you get away with stuff… My
first SDL app was written in Windows and it seemed fine. I ported it to
Linux and it crashed immediately. It was after that I noticed how many
stupid mistakes I had made and was stunned that Windows was letting me get
away with them!> -----Original Message-----

From: Corona688 [SMTP:tsm at accesscomm.ca]
Sent: Thursday, December 19, 2002 10:33 PM
To: sdl at libsdl.org
Subject: Re: [SDL] Toggling Fullscreen

“Sweeney, Steven (FNB)” wrote:

It’s not safe to free your main screen?

Nope. See http://sdldoc.csn.ul.ie/sdlsetvideomode.php

“Return Value - The framebuffer surface, or NULL if it fails. The surface
returned is freed by SDL_Quit() and shouldn’t be freed by the caller.”

I do that at the end of all my progs, right before SDL_Quit()… is this
bad?

Yup. It’s amazing what sort of memory corruption Windows can let you get
away
with, though; I once accidentally set a program of mine to free the video
surface - EVERY FRAME - and actually got away with it for a few weeks.
Only
when I added more code and started using more memory did it start crashing
on
me, and I had a heck of a time trying to find out why. >.>


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

.sophos.3.64.12.19.