Toggle between fullscreen and windowed with alt+enter
EDIT: Forgot to write that this is an Allegro 5 question (of course)!
Tried to add a check for keys ALT+ENTER which toggles between a fullscreen and a windowed display. The switch is made by destroying the current display and creating a new one but after doing that a lot of white rectangular artifacts are visible on screen and framerate goes down from 60 to less than 1. I guess something does not approve of this operation but what/why? All my loaded and drawn bitmaps are stored as video bitmaps, but feels like the are changed to memory bitmaps when the display is updated.
Anyone know what could be wrong, and/or even better how should this be done to keep performance.
Note that if I change to windowed/fullscreen between runs (and not while running) the application it work just fine without any visual errors and low framerate.
Can't you just say al_upload_bitmaps();
You can al_clone_bitmap each one of them if you're using 5.0 IIRC. Just remember this takes twice the memory till you free the old bitmaps.
Thread #611606. Printed from Allegro.cc
When you switch display modes, everything loaded into video memory will be lost. There are a number of ways to get around this (as you can tell from all of the above suggestions) but my recommendation is to actually clear and destroy all of your bitmaps manually before the switch, then do the switch, then reload and recreate them all. So long as the player hasn't been task switching and doing other things, everything that was previously loaded into video memory should still be cached and should reload very quickly.