From a0be832ec24145cb724a3a7a6cec72edcb4e95f9 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Mon, 19 Jun 2006 20:56:54 +0000 Subject: 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 --- src/classes/com/sun/opengl/impl/Java2D.java | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/classes/com/sun/opengl/impl/Java2D.java') 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 -- cgit v1.2.3