diff options
author | Kenneth Russel <[email protected]> | 2005-07-17 06:13:24 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-07-17 06:13:24 +0000 |
commit | 7e7e225eaf4fddb31152ab204bf1776f26079d40 (patch) | |
tree | 522044c1fb226235fa34b9d013945f320765edd8 /src/net/java/games/jogl/impl/GLDrawableHelper.java | |
parent | 9d28b7f7fffdaeee7353945000546cb73a00157b (diff) |
Further context-related changes for the JSR-231 API. The GLContext
implementations on all platforms have been split into orthogonal
GLDrawable and GLContext concepts. It is now possible to create more
than one GLContet per GLDrawable (though this has not been tested
yet). GLCanvas has been reimplemented in terms of
GLDrawableFactory.getGLDrawable(). More functionality has been moved
from GLDrawable to GLAutoDrawable. Reimplemented lazy sending of
reshape GLEventListener events in GLCanvas and GLJPanel and deleted
notion of deferred reshapes from GLDrawableHelper and elsewhere.
Sharing of textures and display lists is now expressed in terms of
GLContexts instead of GLDrawables. Still need to move pbuffer creation
into GLDrawableFactory from the onscreen GLContext implementations.
Added option to gleem ExaminerViewer to disable automatic redraws upon
mouse events and respecified more of gleem to work on GLAutoDrawables
rather than GLDrawables. Updated all JOGL demos to work with new APIs
and slightly different initialization sequences (in particular, for
pbuffers -- this will change with the addition of
GLDrawableFactory.createGLPbuffer()).
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@324 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/impl/GLDrawableHelper.java')
-rw-r--r-- | src/net/java/games/jogl/impl/GLDrawableHelper.java | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/net/java/games/jogl/impl/GLDrawableHelper.java b/src/net/java/games/jogl/impl/GLDrawableHelper.java index da164088f..0542b4db8 100644 --- a/src/net/java/games/jogl/impl/GLDrawableHelper.java +++ b/src/net/java/games/jogl/impl/GLDrawableHelper.java @@ -49,6 +49,7 @@ public class GLDrawableHelper { private volatile List listeners = new ArrayList(); private static final boolean DEBUG = Debug.debug("GLDrawableHelper"); private static final boolean VERBOSE = Debug.verbose(); + private boolean autoSwapBufferMode = true; public GLDrawableHelper() { } @@ -84,17 +85,24 @@ public class GLDrawableHelper { } } + public void setAutoSwapBufferMode(boolean onOrOff) { + autoSwapBufferMode = onOrOff; + } + + public boolean getAutoSwapBufferMode() { + return autoSwapBufferMode; + } + private static final ThreadLocal perThreadInitAction = new ThreadLocal(); - private Runnable deferredReshapeAction; /** Principal helper method which runs a Runnable with the context made current. This could have been made part of GLContext, but a desired goal is to be able to implement the GLCanvas in terms of the GLContext's public APIs, and putting it into a separate class helps ensure that we don't inadvertently use private methods of the GLContext or its implementing classes. */ - public void invokeGL(GLContext context, + public void invokeGL(GLDrawable drawable, + GLContext context, Runnable runnable, - boolean isReshape, Runnable initAction) { // Support for recursive makeCurrent() calls as well as calling // other drawables' display() methods from within another one's @@ -107,35 +115,19 @@ public class GLDrawableHelper { int res = 0; try { res = context.makeCurrent(); - if (res == GLContext.CONTEXT_NOT_CURRENT) { - if (isReshape) { - if (DEBUG) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Deferring reshape action"); - } - deferredReshapeAction = runnable; - } - } else { + if (res != GLContext.CONTEXT_NOT_CURRENT) { if (res == GLContext.CONTEXT_CURRENT_NEW) { if (DEBUG) { System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); } initAction.run(); } - if (deferredReshapeAction != null) { - if (DEBUG) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running deferred reshape action"); - } - Runnable act = deferredReshapeAction; - deferredReshapeAction = null; - act.run(); - } if (DEBUG && VERBOSE) { System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running runnable"); } runnable.run(); - // FIXME: must phrase this in terms of new GLDrawable swap buffer functionality - if (((GLContextImpl) context).getAutoSwapBufferMode()) { - ((GLContextImpl) context).swapBuffers(); + if (autoSwapBufferMode) { + drawable.swapBuffers(); } } } finally { |