I have been having issues when trying to convert my raytracer to run in fullscreen exculsive mode. It was correctly changing mode however no image was being displayed (i.e. a grey screen is displayed).
From searching these forums i came across some code which had introducted a delay after changing modes and creating the buffer strategy. I put a similar delay in and found that the image is now being updated!
My question is why is this delay needed? and surely if it necessary there must be a method to call to wait until the screen is in a appropriate state before continuing to execute the program.
This is the code I am using to change to full screen and create the bufferstrategy:
GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0];
setUndecorated(true);
device.setFullScreenWindow(this);
createBufferStrategy(2);
device.setDisplayMode(new DisplayMode(renderWidth, renderHeight, 32,DisplayMode.REFRESH_RATE_UNKNOWN));
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
To illustrate the problem i have two versions of the program:
With Delay (program works correctly)
With NO Delay (only grey screen displayed)
Not sure what really made it work for me, just happy that it does! It could be that the JFrame-JPanel voodoo was the trick. Might be extra code in there not needed, but no sleep or anything like that needed for me.