Fullscreen mode + Double buffering + alt-tab

Hi,

I’m new to this forum and to fullscreen mode so my question is: when i am in fullscreen mode, and i switch to another application and then come back to my application, it cease rendering (in fact a have a white screen)…

I have Java 2 Tiger…

What’s the problem …

thanks in advance…

I just fixed this in my code a few days ago.

public void render()
{
// If we’ve lost our video memory, don’t bother drawing anything
// This happens when resizing a window or deiconifying the application
if (!bufferStrategy.contentsLost())
{
Graphics2D g = (Graphics2D) bufferStrategy.getDrawGraphics();

       fwm.screenManager.render(g);

       bufferStrategy.show();
       g.dispose();
}
else     //Try to recover the buffer strategy contents
{
                   //System.out.println("bufferStrategy, contents lost!");
                   baseFrame.createBufferStrategy( 3 );
                   bufferStrategy = baseFrame.getBufferStrategy();
                   //System.out.println("recovered if false : "+bufferStrategy.contentsLost());
                   if(!bufferStrategy.contentsLost())
                                     render();// we recovered so render stuff
 }

}

If you resize a window larger or iconify/deiconify the app you will almost always lose the BufferStrategy.
Remove the comments on the print lines to see it happen. Its odd that in the sample I was looking at, it had the first if() statement to not draw if the contents were lost but it didnt have the recovery step :slight_smile: