In other words, is it better to free Surface before or after SDL_Quit? Or, does
SDL_Quit delete any surfaces created by SDL_SetVideoMode automatically?
Note that I’ve left out any error checking code to make the code samples simple.
But will work SDL_FreeSurface( Surface ); to delete the current video
mode?..
Is there another way to unset that video mode? (another than
SDL_QuitSubsystem…);
CU
2006/8/15, Torsten Giebl :>
Hello !
This would be right :
SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE );
Surface = SDL_SetVideoMode( 640, 480, 32, SDL_HWSURFACE|SDL_DOUBLEBUF );
// use surface here
SDL_Quit();
Both are wrong, SDL_Quit itself removes the Screen Surface.
But will work SDL_FreeSurface( Surface ); to delete the current video
mode?.. Is there another way to unset that video mode? (another than
SDL_QuitSubsystem…);
I think no. SDL_QuitSubsystem is the safest way to do it.
Even better than that would be using SDL_Quit as on some systems
the Audiocontext maybe connected to the Window directly.
What Torsten said is correct. Here’s a snipplet from the SDL wiki.
“The surface returned is freed by SDL_Quit and should not be freed by
the caller. Note: This rule includes consecutive calls to
SDL_SetVideoMode (i.e. resize or rez change) - the pre-existing surface
will be released automatically.”
Also, calling SDL_FreeSurface() after SDL_Quit() will probably crash
your program.