private static final DisplayMode[] PreferredModes = new DisplayMode[]{new DisplayMode(800,600,32,0),new DisplayMode(800,600,16,0), new DisplayMode(800,600,8,0)};
private final void FullScreen() {
final GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
final GraphicsDevice myDevice = env.getDefaultScreenDevice();
final DisplayMode dm = bestmode(myDevice);
if(dm == null || !myDevice.isFullScreenSupported()){
JOptionPane.showMessageDialog(null, Messages.getString("g.36")); //$NON-NLS-1$
fullScreen = false; //Fall back to window mode.
return;
}
gameWindow.setDone(true); //stops the canvas rendering.
//this.setVisible(false);
oldDisplayMode = myDevice.getDisplayMode();
try {
myDevice.setFullScreenWindow(this);
//validate();
if(myDevice.isDisplayChangeSupported()){ //windows bug fix
myDevice.setDisplayMode(dm);
this.setSize(dm.getWidth(), dm.getHeight());// fix for mac os x
fullScreen = true;
}
else{
myDevice.setFullScreenWindow(null);
fullScreen = false;
JOptionPane.showMessageDialog(null, Messages.getString("g.37")); //$NON-NLS-1$
}
}catch (final IllegalArgumentException ex) { //Fall back to window mode.
myDevice.setDisplayMode(oldDisplayMode);
myDevice.setFullScreenWindow(null);
fullScreen = false;
JOptionPane.showMessageDialog(null, Messages.getString("g.38")); //$NON-NLS-1$
}
//this.setVisible(true);
validate();
pack();
this.repaint();
gameWindow.setDone(false);
gameWindow.setVisible(true);
new Thread(gameWindow).start();//starts the canvas rendering.
gameWindow.validate();
}
Many of my users are unable to use full screen, so I wonder if there can be any improvement on the current code I have.
Also sometimes I see this error when changing to full screen mode. I’m able to get full screen with this error but the game window is blank but not the gui.
[quote]Exception in thread “Thread-8” java.lang.InternalError: Unsupported depth 25
at sun.awt.image.WritableRasterNative.createNativeRaster(Unknown Source)
at sun.java2d.windows.Win32OffScreenSurfaceData.getRaster(Unknown Source)
at sun.java2d.loops.OpaqueCopyAnyToArgb.Blit(Unknown Source)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(Unknown Source)
at sun.java2d.loops.GraphicsPrimitive.convertFrom(Unknown Source)
at sun.java2d.loops.MaskBlit$General.MaskBlit(Unknown Source)
at sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Unknown Source)
at sun.java2d.pipe.DrawImage.blitSurfaceData(Unknown Source)
at sun.java2d.pipe.DrawImage.renderImageCopy(Unknown Source)
at sun.java2d.pipe.DrawImage.copyImage(Unknown Source)
at sun.java2d.pipe.DrawImage.transformImage(Unknown Source)
at sun.java2d.SunGraphics2D.drawImage(Unknown Source)
at GameWindow.render(GameWindow.java:419)
at GameWindow.PaintScreen(GameWindow.java:378)
at GameWindow.myRenderingLoop(GameWindow.java:335)
at GameWindow.run(GameWindow.java:503)
at java.lang.Thread.run(Unknown Source)
[/quote]
If you need more details just post.