aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/render
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-27 16:41:10 +0200
committerSven Gothel <[email protected]>2013-06-27 16:41:10 +0200
commitc15865e0f62a3af9508245554ed9d4000403e2e0 (patch)
tree3fa5f938f9e197ce2cbeac95814911fde1c367aa /src/jake2/render
parent4c41e7d4286d3ce1f3ef7c8e920ec3cca99e67b8 (diff)
Fix Window destroyNotify() -> QUIT
Diffstat (limited to 'src/jake2/render')
-rw-r--r--src/jake2/render/opengl/GLDriver.java1
-rw-r--r--src/jake2/render/opengl/JoglDummyDriver.java4
-rw-r--r--src/jake2/render/opengl/JoglES1Driver.java3
-rw-r--r--src/jake2/render/opengl/JoglES2Driver.java3
-rw-r--r--src/jake2/render/opengl/JoglGL2Driver.java3
-rw-r--r--src/jake2/render/opengl/NEWTWin.java26
6 files changed, 27 insertions, 13 deletions
diff --git a/src/jake2/render/opengl/GLDriver.java b/src/jake2/render/opengl/GLDriver.java
index d350811..7f86430 100644
--- a/src/jake2/render/opengl/GLDriver.java
+++ b/src/jake2/render/opengl/GLDriver.java
@@ -18,6 +18,7 @@ public interface GLDriver {
void beginFrame(float camera_separation);
+ /** Performs <code>swapBuffers()</code>, ticks the fps counter and performs <code>QUIT</code> if requested. */
void endFrame();
void appActivate(boolean activate);
diff --git a/src/jake2/render/opengl/JoglDummyDriver.java b/src/jake2/render/opengl/JoglDummyDriver.java
index 73620b2..e962c37 100644
--- a/src/jake2/render/opengl/JoglDummyDriver.java
+++ b/src/jake2/render/opengl/JoglDummyDriver.java
@@ -102,9 +102,9 @@ public abstract class JoglDummyDriver extends DummyGL implements GLDriver {
}
public void endFrame() {
- // newtWin.window.swapBuffers();
+ newtWin.checkQuit();
+ // newtWin.swapBuffers();
// deactivate();
- newtWin.fpsCounter.tickFPS();
}
public void appActivate(boolean activate) {
diff --git a/src/jake2/render/opengl/JoglES1Driver.java b/src/jake2/render/opengl/JoglES1Driver.java
index f9a29f8..6f138cd 100644
--- a/src/jake2/render/opengl/JoglES1Driver.java
+++ b/src/jake2/render/opengl/JoglES1Driver.java
@@ -113,9 +113,8 @@ public abstract class JoglES1Driver extends JoglGL2ES1 implements GLDriver {
}
public void endFrame() {
- newtWin.window.swapBuffers();
+ newtWin.endFrame();
// deactivate();
- newtWin.fpsCounter.tickFPS();
}
public void appActivate(boolean activate) {
diff --git a/src/jake2/render/opengl/JoglES2Driver.java b/src/jake2/render/opengl/JoglES2Driver.java
index 2548b62..08c95b9 100644
--- a/src/jake2/render/opengl/JoglES2Driver.java
+++ b/src/jake2/render/opengl/JoglES2Driver.java
@@ -118,9 +118,8 @@ public abstract class JoglES2Driver extends JoglGL2ES1 implements GLDriver {
}
public void endFrame() {
- newtWin.window.swapBuffers();
+ newtWin.endFrame();
// deactivate();
- newtWin.fpsCounter.tickFPS();
}
public void appActivate(boolean activate) {
diff --git a/src/jake2/render/opengl/JoglGL2Driver.java b/src/jake2/render/opengl/JoglGL2Driver.java
index cad9c0a..0c95680 100644
--- a/src/jake2/render/opengl/JoglGL2Driver.java
+++ b/src/jake2/render/opengl/JoglGL2Driver.java
@@ -114,9 +114,8 @@ public abstract class JoglGL2Driver extends JoglGL2ES1 implements GLDriver {
}
public void endFrame() {
- newtWin.window.swapBuffers();
+ newtWin.endFrame();
// deactivate();
- newtWin.fpsCounter.tickFPS();
}
public void appActivate(boolean activate) {
diff --git a/src/jake2/render/opengl/NEWTWin.java b/src/jake2/render/opengl/NEWTWin.java
index bc514ed..ff7b949 100644
--- a/src/jake2/render/opengl/NEWTWin.java
+++ b/src/jake2/render/opengl/NEWTWin.java
@@ -18,6 +18,7 @@ import jake2.sys.NEWTKBD;
import java.util.List;
import javax.media.nativewindow.CapabilitiesChooser;
+import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode;
import javax.media.nativewindow.util.Dimension;
import javax.media.nativewindow.util.DimensionImmutable;
import javax.media.nativewindow.util.SurfaceSize;
@@ -39,6 +40,7 @@ public class NEWTWin {
MonitorMode oldDisplayMode = null;
volatile Screen screen = null;
volatile GLWindow window = null;
+ volatile boolean shouldQuit = false;
final FPSCounterImpl fpsCounter = new FPSCounterImpl();
public List<MonitorMode> getModeList() {
@@ -119,14 +121,11 @@ public class NEWTWin {
}
}
window = GLWindow.create(screen, caps);
+ window.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); // we do handle QUIT on our own, no GLWindow.display() called.
window.setCapabilitiesChooser(chooser);
window.addWindowListener(new WindowAdapter() {
public void windowDestroyNotify(WindowEvent e) {
- if (!Globals.appletMode) {
- if( null != window ) { // already in shutdown ?
- Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit");
- }
- }
+ shouldQuit = !Globals.appletMode && null != window; // not applet and not already in shutdown ?
}
public void windowResized(WindowEvent e) {
@@ -220,6 +219,23 @@ public class NEWTWin {
}
}
+ /** Performs {@link GLWindow#swapBuffers()}, ticks the fps counter and performs <code>QUIT</code> if requested. */
+ public final void endFrame() {
+ window.swapBuffers();
+ fpsCounter.tickFPS();
+ if( shouldQuit ) {
+ deactivateGLContext();
+ Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit");
+ }
+ }
+ /** Performs <code>QUIT</code> if requested. */
+ public final void checkQuit() {
+ if( shouldQuit ) {
+ deactivateGLContext();
+ Cbuf.ExecuteText(Defines.EXEC_APPEND, "quit");
+ }
+ }
+
void shutdown() {
shutdownImpl(true);
}