diff options
author | Sven Gothel <[email protected]> | 2008-07-21 06:39:36 +0000 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2008-07-21 06:39:36 +0000 |
commit | 48e16d7085da1a283c22b01498c687882bede073 (patch) | |
tree | e89ba31b25668f1098f1086bdae79345469784ad /src/classes/com | |
parent | 6a1ad07ce8563a9ebd4e1d5be970621ffe1a7daf (diff) |
Add event handling method to modify the GL context switch due to performance issues (experimental)
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1732 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com')
-rw-r--r-- | src/classes/com/sun/javafx/newt/GLWindow.java | 58 |
1 files changed, 52 insertions, 6 deletions
diff --git a/src/classes/com/sun/javafx/newt/GLWindow.java b/src/classes/com/sun/javafx/newt/GLWindow.java index f4fa2c117..1922e3d5c 100644 --- a/src/classes/com/sun/javafx/newt/GLWindow.java +++ b/src/classes/com/sun/javafx/newt/GLWindow.java @@ -45,6 +45,27 @@ import com.sun.opengl.impl.GLDrawableHelper; * etc.). */ public class GLWindow extends Window implements GLAutoDrawable { + /** + * Event handling mode: EVENT_HANDLER_GL_NONE. + * No GL context is current, while calling the EventListener. + * This might be inconvenient, but don't impact the performance. + * + * @see com.sun.javafx.newt.GLWindow#setEventHandlerMode(int) + */ + public static final int EVENT_HANDLER_GL_NONE = 0; + + /** + * Event handling mode: EVENT_HANDLER_GL_CURRENT. + * The GL context is made current, while calling the EventListener. + * This might be convenient, but impacts the performance + * due to context switches. + * + * This is the default setting! + * + * @see com.sun.javafx.newt.GLWindow#setEventHandlerMode(int) + */ + public static final int EVENT_HANDLER_GL_CURRENT = (1 << 0); + private Window window; /** Constructor. Do not call this directly -- use {@link @@ -128,9 +149,37 @@ public class GLWindow extends Window implements GLAutoDrawable { return window.getDisplayHeight(); } + /** + * Sets the event handling mode. + * + * @see com.sun.javafx.newt.GLWindow#EVENT_HANDLER_GL_NONE + * @see com.sun.javafx.newt.GLWindow#EVENT_HANDLER_GL_CURRENT + */ + public void setEventHandlerMode(int mode) { + eventHandlerMode = mode; + } + + public int getEventHandlerMode() { + return eventHandlerMode; + } + public void pumpMessages(int eventMask) { - pumpMessagesWithEventMaskAction.eventMask = eventMask; - pumpMessagesImpl(pumpMessagesWithEventMaskAction); + if( 0 == (eventHandlerMode & EVENT_HANDLER_GL_CURRENT) ) { + window.pumpMessages(eventMask); + } else { + pumpMessagesWithEventMaskAction.eventMask = eventMask; + pumpMessagesImpl(pumpMessagesWithEventMaskAction); + } + } + + public void pumpMessages() { + if( 0 == (eventHandlerMode & EVENT_HANDLER_GL_CURRENT) ) { + System.err.println("pump direct"); + window.pumpMessages(); + } else { + System.err.println("pump indirect with GL"); + pumpMessagesImpl(pumpMessagesAction); + } } class PumpMessagesWithEventMaskAction implements Runnable { @@ -142,10 +191,6 @@ public class GLWindow extends Window implements GLAutoDrawable { } private PumpMessagesWithEventMaskAction pumpMessagesWithEventMaskAction = new PumpMessagesWithEventMaskAction(); - public void pumpMessages() { - pumpMessagesImpl(pumpMessagesAction); - } - class PumpMessagesAction implements Runnable { public void run() { window.pumpMessages(); @@ -257,6 +302,7 @@ public class GLWindow extends Window implements GLAutoDrawable { // OpenGL-related methods and state // + private int eventHandlerMode = EVENT_HANDLER_GL_CURRENT; private GLDrawableFactory factory; private GLCapabilities caps; private GLDrawable drawable; |