1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| 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")); fullScreen = false; return; } gameWindow.setDone(true); oldDisplayMode = myDevice.getDisplayMode(); try { myDevice.setFullScreenWindow(this); if(myDevice.isDisplayChangeSupported()){
myDevice.setDisplayMode(dm); this.setSize(dm.getWidth(), dm.getHeight()); fullScreen = true; } else{ myDevice.setFullScreenWindow(null); fullScreen = false; JOptionPane.showMessageDialog(null, Messages.getString("g.37")); } }catch (final IllegalArgumentException ex) { myDevice.setDisplayMode(oldDisplayMode); myDevice.setFullScreenWindow(null); fullScreen = false; JOptionPane.showMessageDialog(null, Messages.getString("g.38"));
} validate(); pack(); this.repaint();
gameWindow.setDone(false); gameWindow.setVisible(true); new Thread(gameWindow).start(); 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.
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)
If you need more details just post.