diff options
author | Kenneth Russel <[email protected]> | 2006-02-11 01:11:57 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2006-02-11 01:11:57 +0000 |
commit | 8ebdef6860e34bf16b9b13c657f651bf9ce32ab3 (patch) | |
tree | e1b51b0c8cacf3987f219b2e992af089aea5d1b4 /src/classes/javax/media/opengl/GLJPanel.java | |
parent | b75d4a3718b1a5744218e19c4f5c1a9ff0311f34 (diff) |
Further work on FBO support in Java2D/JOGL bridge. Upgraded JOGL's
Java2D class to latest proposed set of APIs in OGLUtilities and
changed usage of these APIs to be approximately correct. Left in
fallback path for working with non-FBO case in current Mustang builds.
Not working yet, and don't yet understand why; checking in at this
intermediate point to be able to more easily test on more machines.
Added error checking to creation of external GLContexts and
GLDrawables on Windows and X11 platforms.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@597 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/javax/media/opengl/GLJPanel.java')
-rw-r--r-- | src/classes/javax/media/opengl/GLJPanel.java | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/classes/javax/media/opengl/GLJPanel.java b/src/classes/javax/media/opengl/GLJPanel.java index 6f8340aff..929975f13 100644 --- a/src/classes/javax/media/opengl/GLJPanel.java +++ b/src/classes/javax/media/opengl/GLJPanel.java @@ -178,7 +178,10 @@ public class GLJPanel extends JPanel implements GLAutoDrawable { // 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(); + Java2D.getShareContext(GraphicsEnvironment. + getLocalGraphicsEnvironment(). + getDefaultScreenDevice(). + getDefaultConfiguration()); } } @@ -235,11 +238,19 @@ public class GLJPanel extends JPanel implements GLAutoDrawable { } } - private void captureJ2DState(GL gl) { + private void captureJ2DState(GL gl, Graphics g) { gl.glGetIntegerv(GL.GL_DRAW_BUFFER, drawBuffer, 0); gl.glGetIntegerv(GL.GL_READ_BUFFER, readBuffer, 0); - if (Java2D.isFBOEnabled()) { + if (Java2D.isFBOEnabled() && + Java2D.getOGLSurfaceType(g) == Java2D.FBOBJECT) { + if (DEBUG && VERBOSE) { + System.err.println("-- Fetching GL_FRAMEBUFFER_BINDING_EXT"); + } gl.glGetIntegerv(GL.GL_FRAMEBUFFER_BINDING_EXT, frameBuffer, 0); + + // Unbind the framebuffer from this context before attempting to + // bind it to ours (may not be necessary) + // gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, 0); } } @@ -268,14 +279,12 @@ public class GLJPanel extends JPanel implements GLAutoDrawable { viewportX = oglViewport.x; viewportY = oglViewport.y; - 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 (Java2D.isFBOEnabled() && + Java2D.getOGLSurfaceType(g) == Java2D.FBOBJECT) { if (DEBUG && VERBOSE) { System.err.println("Binding to framebuffer object " + frameBuffer[0]); } @@ -284,6 +293,14 @@ public class GLJPanel extends JPanel implements GLAutoDrawable { gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBuffer[0]); // FIXME: do we need to do anything else? Bind Texture2D state // or something else? + } else { + if (DEBUG && VERBOSE) { + System.err.println("Setting up drawBuffer " + drawBuffer[0] + + " and readBuffer " + readBuffer[0]); + } + + gl.glDrawBuffer(drawBuffer[0]); + gl.glReadBuffer(readBuffer[0]); } return true; @@ -363,7 +380,7 @@ public class GLJPanel extends JPanel implements GLAutoDrawable { j2dContext.makeCurrent(); try { - captureJ2DState(j2dContext.getGL()); + captureJ2DState(j2dContext.getGL(), g); Object curSurface = Java2D.getOGLSurfaceIdentifier(g); if (curSurface != null) { if (j2dSurface != curSurface) { |