Flickering after alt/tab in fullscreen

BlitzMax Forums/BlitzMax Beginners Area/Flickering after alt/tab in fullscreen

DrDaxxy(Posted 2008) [#1]
Hi,

I've got a problem: When I alt/tab out of my application and alt/tab back, the screen overwrites either the backbuffer or the frontbuffer (don't know which), which causes flickering. I don't know how to describe this problem any better, but here's my code:
http://pastebin.com/d52b22d8d
If I use the windowed mode and something gets over the window it fills it with its own graphics, too. But I don't know how to prevent that without having to draw all the stuff which was previously in the window again.
Could someone of you please help me?


ImaginaryHuman(Posted 2008) [#2]
Do you have enough video ram to be able to have a backbuffer for double-buffering? Cus if you are only single-buffered you might get something like this happen.


DrDaxxy(Posted 2008) [#3]
Yep, but if I write, flip once, write, flip once... I have half the graphics on one screen and the other half on another. Could you tell me how to avoid this? Write the graphics on both buffers? If yes, how?


xlsior(Posted 2008) [#4]
Yep, but if I write, flip once, write, flip once... I have half the graphics on one screen and the other half on another. Could you tell me how to avoid this? Write the graphics on both buffers? If yes, how?


If you switch fullscreen/windowed, skip your game logic one loop and draw/flip everything twice.

*however* -- it sounds like you are counting on the old content to remain in the buffer. Be aware that this is *very* unpredictable.

some video cards use one buffer, others have two, three or even four. Which means that if you run your game on one of those and expect the old content to remain steady in place, you'll be in for a surprise on many systems, and may end up with content jumping back and forth in a rather seizure-inducing manner.

The short version: you can *never* cound on the background to remain in place after a flip, and to ensure that your game works on all computers, you really ought to redraw everything every single frame.