The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Toggle fullscreen
djkarstenv


Joined: 29 Sep 2011
Posts: 34
Hi all,

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

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?