I want my game can run in both windowed/fullscreen mode.
Before I call SetVideoMode twice, need I free the primary surface
first?
need I do sth like following or not:
SDL_Surface *screen = SetVideoMode(…);
// …
//
SDL_Surface *tmpsurface = screen;
SDL_Surface *screen = SetVideoMode(…);
SDL_FreeSurface( tmpsurface );
Thanks for help. _
Quoth kasicass , on 2005-05-26 10:38:51 +0000:
I want my game can run in both windowed/fullscreen mode.
Before I call SetVideoMode twice, need I free the primary surface
first?
No. Read the manual.
RETURN VALUE
The framebuffer surface, or NULL if it fails. The surface
returned is freed by SDL_Quit() and should not be freed by the
caller.
(emphasis mine)
—> Drake Wilson
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20050526/4ad50458/attachment.pgp
I want my game can run in both windowed/fullscreen mode. Before I call SetVideoMode twice, need I free the primary surface first?
No.
My toggle code (minus irrelevant parts) is this -
void SDLVideoDriver::toggleFullScreen (void)
{
bool bFullScreen = !getFullScreen();
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_InitSubSystem(SDL_INIT_VIDEO);
SDL_Surface* pNewSurf = setVideoBestBPP(m_nWidth, m_nHeight,
bFullScreen ? SDL_FULLSCREEN : 0);
if (pNewSurf == NULL)
{
GameApp::writeToLog(String::fromFormat("S: Toggle failed (%c -> %c) [%
s]\n", bFullScreen ? ‘W’ : ‘F’, bFullScreen ? ‘F’ : ‘W’, SDL_GetError
()));
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_InitSubSystem(SDL_INIT_VIDEO);
bFullScreen = !bFullScreen;
pNewSurf = setVideoBestBPP(m_nWidth, m_nHeight, bFullScreen ?
SDL_FULLSCREEN : 0);
if (pNewSurf == NULL)
GFC_FATAL(String::fromFormat("S: Couldn't restore old video mode,
aborting [%s]", SDL_GetError()));
}
m_pScreenSurf = pNewSurf;
}
setVideoBestBPP() just tries different bit depths using SDL_VideoModeOK
() and sets the first one available.
--Gabriel
I do not believe you have to quit and init the subsystem. Just go
ahead and set the video mode to what you want.
ChrisOn 5/26/05, Gabriel wrote:
I want my game can run in both windowed/fullscreen mode. Before I call SetVideoMode twice, need I free the primary surface first?
No.
My toggle code (minus irrelevant parts) is this -
void SDLVideoDriver::toggleFullScreen (void)
{
bool bFullScreen = !getFullScreen();
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_InitSubSystem(SDL_INIT_VIDEO);
–
E-Mail: Chris Nystrom
Business: http://www.shaklee.net/austin
Blog: http://conversazione.blogspot.com/
AIM: nystromchris
El mi?, 01-06-2005 a las 07:48 -0500, Chris Nystrom escribi?:
My toggle code (minus irrelevant parts) is this -
void SDLVideoDriver::toggleFullScreen (void)
{
bool bFullScreen = !getFullScreen();
SDL_QuitSubSystem(SDL_INIT_VIDEO);
SDL_InitSubSystem(SDL_INIT_VIDEO);
I do not believe you have to quit and init the subsystem. Just go
ahead and set the video mode to what you want.
That’s what I had, and got a lot of crashes saying DirectDraw couldn’t
set the video mode because it was already initialized or something like
that. This new code works just fine.
--Gabriel