Stepping in and out for fullscreen

this is my third thread in a short time, bear with me here guys, almost done :stuck_out_tongue:

i’m stepping in and out of fullscreen to be able to show swing components properly, but when step back in, i either get really bad flickering, or a white screen. the code is

for the render loop

    // Render single frame
    do {
        // The following loop ensures that the contents of the drawing buffer
        // are consistent in case the underlying surface was recreated
        do {
        	doRendering(start, true, true);

            // Repeat the rendering if the drawing buffer contents 
            // were restored
        } while (bufferStrategy.contentsRestored());

            // Display the buffer
            bufferStrategy.show();

        // Repeat the rendering if the drawing buffer was lost
    } while (bufferStrategy.contentsLost());

and when i step back in i do

                        mainFrame.setVisible(true);
                        mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
                        if(device.isFullScreenSupported())
                        	device.setFullScreenWindow(mainFrame);
                        if(device.isDisplayChangeSupported())
                        	device.setDisplayMode(best);

try switching twice from Window to FS, the second time it can recover the buffer properly !

If you’re using 6uN b10 or earlier you may be running into some issues
that might be fixed in b11.

A few general suggestions which could improve the stability
of your FS app (which should go into that fullscreen
tutorial at some point, preferably in a way of an example
or framework):

  • try to enter/exit fs mode on event queue thread
    This may not be an issue with the latest 6uN but it would
    help with earlier releases
  • if possible make sure that your rendering thread waits
    until the you enter/exit fs or change the display mode

This may mean that you’ll need to enter/exit fs mode
from your rendering thread using EventQueue.invokeAndWait()
to execute the code on EDT.

If that’s not too clear, it’s because I’ve had one too many beers tonight…

Dmitri

Cool, i’ll try all 3 of these.

[quote] - if possible make sure that your rendering thread waits
until the you enter/exit fs or change the display mode
[/quote]
it already does,when existing fullscreenmode i have a join on the drawthread. continues only when it’s terminated, and when reintering the semaphores prevent it from starting untill the function finishes

it’s also a requirement for switching fast on the current DisplayMode that the rendering task refreshes quickly enough so that its buffer updates with the correct dimensions. As a clue, JComponent getSize() mehtods are known to be not as fast than the dedicated getWidth() and getHeight() functions, I’m saying. :smiley:

I changed the code to always switch from the EDT using EventQueue or if the switch was trigger by an action and thus it’s already executing on the edt to continue.

but then still worked on certain pcs and other not, then i tried what broumbroum said and setting it 2 times seems to work like a charm. lol.

ain’t it, uh? ;D