aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-06-19 20:56:54 +0000
committerKenneth Russel <[email protected]>2006-06-19 20:56:54 +0000
commita0be832ec24145cb724a3a7a6cec72edcb4e95f9 (patch)
tree2553fb665ebe3d917b5d3a45229913eb9048aa9d /src
parentf835b2a9298bce7790352b5750a47b0fead1e9c5 (diff)
Added support to Java2D/JOGL bridge for GL_ARB_texture_rectangle
support in Java2D/OpenGL pipeline's FBO code path git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@816 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/Java2D.java35
-rw-r--r--src/classes/javax/media/opengl/GLJPanel.java17
2 files changed, 46 insertions, 6 deletions
diff --git a/src/classes/com/sun/opengl/impl/Java2D.java b/src/classes/com/sun/opengl/impl/Java2D.java
index 11a8f3da3..457c819bd 100755
--- a/src/classes/com/sun/opengl/impl/Java2D.java
+++ b/src/classes/com/sun/opengl/impl/Java2D.java
@@ -58,6 +58,8 @@ public class Java2D {
private static Method getOGLViewportMethod;
private static Method getOGLScissorBoxMethod;
private static Method getOGLSurfaceIdentifierMethod;
+ // This one is currently optional and is only in very recent Mustang builds
+ private static Method getOGLTextureTypeMethod;
// The following methods and fields are needed for proper support of
// Frame Buffer Objects in the Java2D/OpenGL pipeline
@@ -161,6 +163,20 @@ public class Java2D {
System.err.println("Disabling Java2D/JOGL FBO support");
}
}
+
+ // Try to get an additional method for FBO support in recent Mustang builds
+ try {
+ getOGLTextureTypeMethod = utils.getDeclaredMethod("getOGLTextureType",
+ new Class[] {
+ Graphics.class
+ });
+ getOGLTextureTypeMethod.setAccessible(true);
+ } catch (Exception e) {
+ if (DEBUG && VERBOSE) {
+ e.printStackTrace();
+ System.err.println("GL_ARB_texture_rectangle FBO support disabled");
+ }
+ }
} catch (Exception e) {
if (DEBUG && VERBOSE) {
e.printStackTrace();
@@ -332,6 +348,25 @@ public class Java2D {
}
}
+ /** Returns the underlying texture target of the given Graphics
+ object assuming it is rendering to an FBO. Returns either
+ GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB. */
+ public static int getOGLTextureType(Graphics g) {
+ checkActive();
+
+ if (getOGLTextureTypeMethod == null) {
+ return GL.GL_TEXTURE_2D;
+ }
+
+ try {
+ return ((Integer) getOGLTextureTypeMethod.invoke(null, new Object[] { g })).intValue();
+ } catch (InvocationTargetException e) {
+ throw new GLException(e.getTargetException());
+ } catch (Exception e) {
+ throw (InternalError) new InternalError().initCause(e);
+ }
+ }
+
/** Returns either the given GLContext or a substitute one with
which clients should share textures and display lists. Needed
when the Java2D/OpenGL pipeline is active and FBOs are being
diff --git a/src/classes/javax/media/opengl/GLJPanel.java b/src/classes/javax/media/opengl/GLJPanel.java
index b4b6b2c52..f98df3c5f 100644
--- a/src/classes/javax/media/opengl/GLJPanel.java
+++ b/src/classes/javax/media/opengl/GLJPanel.java
@@ -182,6 +182,9 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
// incomplete in our context.
private boolean checkedGLVendor;
private boolean vendorIsATI;
+ // The texture target for Java2D's OpenGL pipeline when using FBOs
+ // -- either GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE_ARB
+ private int fboTextureTarget;
// These are always set to (0, 0) except when the Java2D / OpenGL
// pipeline is active
@@ -345,9 +348,11 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
System.err.println("GLJPanel: Binding to framebuffer object " + frameBuffer[0]);
}
+ fboTextureTarget = Java2D.getOGLTextureType(g);
+
if (!checkedForFBObjectWorkarounds) {
checkedForFBObjectWorkarounds = true;
- gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
+ gl.glBindTexture(fboTextureTarget, 0);
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBuffer[0]);
if (gl.glCheckFramebufferStatusEXT(GL.GL_FRAMEBUFFER_EXT) !=
GL.GL_FRAMEBUFFER_COMPLETE_EXT) {
@@ -374,11 +379,11 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
frameBufferDepthBuffer[0] = 0;
}
- gl.glBindTexture(GL.GL_TEXTURE_2D, frameBufferTexture[0]);
+ gl.glBindTexture(fboTextureTarget, frameBufferTexture[0]);
int[] width = new int[1];
int[] height = new int[1];
- gl.glGetTexLevelParameteriv(GL.GL_TEXTURE_2D, 0, GL.GL_TEXTURE_WIDTH, width, 0);
- gl.glGetTexLevelParameteriv(GL.GL_TEXTURE_2D, 0, GL.GL_TEXTURE_HEIGHT, height, 0);
+ gl.glGetTexLevelParameteriv(fboTextureTarget, 0, GL.GL_TEXTURE_WIDTH, width, 0);
+ gl.glGetTexLevelParameteriv(fboTextureTarget, 0, GL.GL_TEXTURE_HEIGHT, height, 0);
gl.glGenRenderbuffersEXT(1, frameBufferDepthBuffer, 0);
if (DEBUG) {
@@ -394,14 +399,14 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
createNewDepthBuffer = false;
}
- gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
+ gl.glBindTexture(fboTextureTarget, 0);
gl.glBindFramebufferEXT(GL.GL_FRAMEBUFFER_EXT, frameBuffer[0]);
if (fbObjectWorkarounds) {
// Hook up the color and depth buffer attachment points for this framebuffer
gl.glFramebufferTexture2DEXT(GL.GL_FRAMEBUFFER_EXT,
GL.GL_COLOR_ATTACHMENT0_EXT,
- GL.GL_TEXTURE_2D,
+ fboTextureTarget,
frameBufferTexture[0],
0);
if (DEBUG && VERBOSE) {