summaryrefslogtreecommitdiffstats
path: root/src/classes/javax/media
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-02-06 04:52:15 +0000
committerKenneth Russel <[email protected]>2006-02-06 04:52:15 +0000
commita302c87258a1a17dc0eef5ae112cb0d4357be238 (patch)
tree5068ba77f80cd112f741f8d3e2bc9d89537702bc /src/classes/javax/media
parentced30725fdaa23c108605104d0d364055e629a63 (diff)
Further work on FBO support in Java2D/JOGL bridge. Recast how
GLObjectTrackers are specified between contexts and separated this from the maintenance of the GLContextShareSet, although the API (registerForObjectTracking) is in the GLContextShareSet class. If the Java2D/OpenGL pipeline and FBOs are active, causes all JOGL contexts created to share textures and display lists with a context from Java2D (currently acquired from a VolatileImage, but will probably need to change how this is done). GLObjectTrackers however are only shared between JOGL contexts where the user has explicitly requested sharing. This yields the expected semantics of server-side object deletion when the context is destroyed. Upgraded GLJPanel to handle FBO manipulation. Not working yet; more debugging necessary on Java2D side as well. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@585 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/javax/media')
-rw-r--r--src/classes/javax/media/opengl/GLJPanel.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/classes/javax/media/opengl/GLJPanel.java b/src/classes/javax/media/opengl/GLJPanel.java
index ad5a7f769..1dd204239 100644
--- a/src/classes/javax/media/opengl/GLJPanel.java
+++ b/src/classes/javax/media/opengl/GLJPanel.java
@@ -80,6 +80,10 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
private static final boolean DEBUG = Debug.debug("GLJPanel");
private static final boolean VERBOSE = Debug.verbose();
+ // FIXME: remove these once debugging is done
+ private static final boolean HACK1 = Debug.debug("GLJPanel.hack1");
+ private static final boolean HACK2 = Debug.debug("GLJPanel.hack2");
+
private GLDrawableHelper drawableHelper = new GLDrawableHelper();
private volatile boolean isInitialized;
private volatile boolean shouldInitialize = false;
@@ -159,11 +163,23 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
// properly render into Java2D back buffer
private int[] drawBuffer = new int[1];
private int[] readBuffer = new int[1];
+ // This is required when the FBO option of the Java2D / OpenGL
+ // pipeline is active
+ private int[] frameBuffer = new int[1];
// These are always set to (0, 0) except when the Java2D / OpenGL
// pipeline is active
private int viewportX;
private int viewportY;
+ static {
+ // Force eager initialization of part of the Java2D class since
+ // otherwise it's likely it will try to be initialized while on
+ // the Queue Flusher Thread, which is not allowed
+ if (Java2D.isOGLPipelineActive() && Java2D.isFBOEnabled()) {
+ Java2D.getShareContext();
+ }
+ }
+
/** Creates a new GLJPanel component with a default set of OpenGL
capabilities and using the default OpenGL capabilities selection
mechanism. */
@@ -220,6 +236,9 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
private void captureJ2DState(GL gl) {
gl.glGetIntegerv(GL.GL_DRAW_BUFFER, drawBuffer, 0);
gl.glGetIntegerv(GL.GL_READ_BUFFER, readBuffer, 0);
+ if (Java2D.isFBOEnabled()) {
+ gl.glGetIntegerv(GL.GL_FRAMEBUFFER_BINDING_EXT, frameBuffer, 0);
+ }
}
private boolean preGL(Graphics g) {
@@ -249,6 +268,22 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
gl.glDrawBuffer(drawBuffer[0]);
gl.glReadBuffer(readBuffer[0]);
+
+ // If the FBO option is active, bind to the FBO from the Java2D
+ // context.
+ // Note that all of the plumbing in the context sharing stuff will
+ // allow us to bind to this object since it's in our namespace.
+ if (Java2D.isFBOEnabled()) {
+ if (DEBUG && VERBOSE) {
+ System.err.println("Binding to framebuffer object " + frameBuffer[0]);
+ }
+
+ gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
+ gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBuffer[0]);
+ // FIXME: do we need to do anything else? Bind Texture2D state
+ // or something else?
+ }
+
return true;
}
@@ -346,6 +381,28 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
joglDrawable = GLDrawableFactory.getFactory().createExternalGLDrawable();
joglContext = joglDrawable.createContext(shareWith);
}
+
+ // FIXME: remove these once debugging is done
+ if (HACK1) {
+ // Skip all GLContext manipulation This fixes the
+ // display of the icons and text (done with Java2D)
+ // in the JGears demo when FBO is active
+ return;
+ }
+ if (HACK2) {
+ // Do a little GLContext manipulation but skip all
+ // FBO-related manipulation and other stuff (as well
+ // as the user rendering).
+
+ // Note that the icons and text in the JGears demo
+ // disappear when this flag is used, so clearly any
+ // OpenGL context manipulation is messing up the
+ // Java2D context state when FBO is active.
+ joglContext.makeCurrent();
+ joglContext.release();
+ return;
+ }
+
drawableHelper.invokeGL(joglDrawable, joglContext, displayAction, initAction);
}
} finally {