Toggle fullscreen

Hi all,

Another question, if anyone can help, that would be greatly appreciated. :slight_smile:

In my game, I have tried using SDL_WM_ToggleFullScreen but it just will not work, so I have tried another method.

At the start of my game is a global variable declared and initialized as follows :

unsigned int Window_Mode(SDL_SWSURFACE);

During the course of the game when the player clicks on a FULLSCREEN toggle button, this code executes :

Window_Mode ^= SDL_FULLSCREEN;
SDL_SetVideoMode(800, 600, 24, Window_Mode);

This will XOR the current _Window_Mode _value so you will always get either SDL_SWSURFACE (windowed) or **SDL_FULLSCREEN **(fullscreen). This works perfectly, and the game flips from one mode to the other when the button is clicked, however…now onto my burning question : when looking at my Windows Task Manager I see that memory is being leaked, so is this because everytime i call SDL_SetVideoMode, the old window data in memory is abandoned, hence causing the leak? If so, how can I manually release the old window image from memory?

I know calling _SDL_Quit() _releases the old window, but then I will have to re-initialize everything again, as well as reload all my SDL_Surface* image pointers, etc.

Anyone have any ideas? Is using the long way round the best solution afterall?