From 8d6db3172d571a9fd3303e78a4768cded9029fcf Mon Sep 17 00:00:00 2001 From: Carsten Weisse Date: Mon, 11 Dec 2006 21:56:10 +0000 Subject: hope this helps on win32 screen mode switching --- src/jake2/render/opengl/Jsr231Driver.java | 54 +++++++++++++++++++------------ 1 file changed, 33 insertions(+), 21 deletions(-) (limited to 'src/jake2') diff --git a/src/jake2/render/opengl/Jsr231Driver.java b/src/jake2/render/opengl/Jsr231Driver.java index 4b42f3a..f50ee4c 100644 --- a/src/jake2/render/opengl/Jsr231Driver.java +++ b/src/jake2/render/opengl/Jsr231Driver.java @@ -51,7 +51,7 @@ public abstract class Jsr231Driver extends Jsr231GL implements GLDriver { private GraphicsDevice device; private DisplayMode oldDisplayMode; - private Display display; + private volatile Display display; private volatile Frame window; // window position on the screen @@ -153,7 +153,7 @@ public abstract class Jsr231Driver extends Jsr231GL implements GLDriver { VID.Printf(Defines.PRINT_ALL, " " + newDim.width + " " + newDim.height + '\n'); // destroy the existing window - shutdown(); + if (window != null) shutdown(); window = new Frame("Jake2 (jsr231)"); ImageIcon icon = new ImageIcon(getClass().getResource("/icon-small.png")); @@ -240,28 +240,40 @@ public abstract class Jsr231Driver extends Jsr231GL implements GLDriver { } public void shutdown() { - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - if (oldDisplayMode != null - && device.getFullScreenWindow() != null) { - try { - if (device.isFullScreenSupported()) - device.setDisplayMode(oldDisplayMode); - device.setFullScreenWindow(null); - } catch (Exception e) { - e.printStackTrace(); + Thread exit = new Thread(new Runnable() { + public void run() { + + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + if (oldDisplayMode != null + && device.getFullScreenWindow() != null) { + try { + if (device.isFullScreenSupported()) + device.setDisplayMode(oldDisplayMode); + device.setFullScreenWindow(null); + } catch (Exception e) { + e.printStackTrace(); + } + } } - } + }); + } catch (Exception e) { + e.printStackTrace(); } - }); - } catch (Exception e) { - e.printStackTrace(); - } - if (window != null) { - display.destroy(); - window.dispose(); + if (window != null) { + display.destroy(); + window.dispose(); + } + } + }); + exit.start(); + try { + exit.join(); + } catch (InterruptedException e) { } + display = null; + } /** -- cgit v1.2.3