diff options
author | Kenneth Russel <kbrussel@alum.mit.edu> | 2005-07-10 23:17:43 +0000 |
---|---|---|
committer | Kenneth Russel <kbrussel@alum.mit.edu> | 2005-07-10 23:17:43 +0000 |
commit | 8a4e964a88703bcab4a8888b25ea9e997953180a (patch) | |
tree | 073e1a11d44a0f4cb407419c90f89aee0979403d /src/net/java/games/jogl/GLCanvas.java | |
parent | 6e8dd12319e2d6f702cf66728b177e6ea0152c2c (diff) |
Initial set of context-related changes for the JSR-231 API. GLContext
has been exposed in the public API. The GLEventListener callback
mechanism has been removed from the core GLContext implementation and
moved up to a higher level. GLAutoDrawable now contains the
GLEventListener-related methods, and the GLEventListener's methods now
receive a GLAutoDrawable as argument. All JOGL demos have been updated
for the new APIs. Many FIXMEs and much unimplemented functionality
remain. There is slightly different initialization behavior for the
demos containing pbuffers, and the deferring of reshape callbacks
needs to be rethought.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@320 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/net/java/games/jogl/GLCanvas.java')
-rw-r--r-- | src/net/java/games/jogl/GLCanvas.java | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/src/net/java/games/jogl/GLCanvas.java b/src/net/java/games/jogl/GLCanvas.java index f73a006ae..e7a15ccf9 100644 --- a/src/net/java/games/jogl/GLCanvas.java +++ b/src/net/java/games/jogl/GLCanvas.java @@ -43,6 +43,7 @@ import java.awt.Canvas; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; import net.java.games.jogl.impl.*; // FIXME: Subclasses need to call resetGLFunctionAvailability() on their @@ -57,20 +58,21 @@ import net.java.games.jogl.impl.*; instantiated directly; use {@link GLDrawableFactory} to construct them. */ -public final class GLCanvas extends Canvas implements GLDrawable { +public class GLCanvas extends Canvas implements GLAutoDrawable { protected static final boolean DEBUG = Debug.debug("GLCanvas"); private GLDrawableHelper drawableHelper = new GLDrawableHelper(); - private GLContext context; - - GLCanvas(GraphicsConfiguration config, - GLCapabilities capabilities, - GLCapabilitiesChooser chooser, - GLDrawable shareWith) { - super(config); - context = GLContextFactory.getFactory().createGLContext(this, capabilities, chooser, - GLContextHelper.getContext(shareWith)); + private GLContextImpl context; + + public GLCanvas(GLCapabilities capabilities, + GLCapabilitiesChooser chooser, + GLDrawable shareWith, + GraphicsDevice device) { + super(GLDrawableFactory.getFactory().chooseGraphicsConfiguration(capabilities, chooser, device)); + context = (GLContextImpl) GLContextFactory.getFactory().createGLContext(this, capabilities, chooser, + GLContextHelper.getContext(shareWith)); + context.setSynchronized(true); } public void display() { @@ -82,9 +84,7 @@ public final class GLCanvas extends Canvas implements GLDrawable { /** Overridden from Canvas; calls {@link #display}. Should not be invoked by applications directly. */ public void paint(Graphics g) { - if (!context.getNoAutoRedrawMode()) { - display(); - } + display(); } /** Overridden from Canvas; used to indicate when it's safe to @@ -127,7 +127,7 @@ public final class GLCanvas extends Canvas implements GLDrawable { }; final Runnable reshapeOnEDTRunnable = new Runnable() { public void run() { - context.invokeGL(reshapeRunnable, true, initAction); + drawableHelper.invokeGL(context, reshapeRunnable, true, initAction); } }; maybeDoSingleThreadedWorkaround(reshapeOnEDTRunnable, reshapeRunnable, true); @@ -163,26 +163,6 @@ public final class GLCanvas extends Canvas implements GLDrawable { context.setGLU(glu); } - void willSetRenderingThread() { - context.willSetRenderingThread(); - } - - public void setRenderingThread(Thread currentThreadOrNull) throws GLException { - context.setRenderingThread(currentThreadOrNull, initAction); - } - - public Thread getRenderingThread() { - return context.getRenderingThread(); - } - - public void setNoAutoRedrawMode(boolean noAutoRedraw) { - context.setNoAutoRedrawMode(noAutoRedraw); - } - - public boolean getNoAutoRedrawMode() { - return context.getNoAutoRedrawMode(); - } - public void setAutoSwapBufferMode(boolean onOrOff) { context.setAutoSwapBufferMode(onOrOff); } @@ -233,7 +213,7 @@ public final class GLCanvas extends Canvas implements GLDrawable { throw new GLException(e); } } else { - context.invokeGL(invokeGLAction, isReshape, initAction); + drawableHelper.invokeGL(context, invokeGLAction, isReshape, initAction); } } @@ -263,14 +243,14 @@ public final class GLCanvas extends Canvas implements GLDrawable { // being resized on the AWT event dispatch thread class DisplayOnEventDispatchThreadAction implements Runnable { public void run() { - context.invokeGL(displayAction, false, initAction); + drawableHelper.invokeGL(context, displayAction, false, initAction); } } private DisplayOnEventDispatchThreadAction displayOnEventDispatchThreadAction = new DisplayOnEventDispatchThreadAction(); class SwapBuffersOnEventDispatchThreadAction implements Runnable { public void run() { - context.invokeGL(swapBuffersAction, false, initAction); + drawableHelper.invokeGL(context, swapBuffersAction, false, initAction); } } private SwapBuffersOnEventDispatchThreadAction swapBuffersOnEventDispatchThreadAction = |