summaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/impl/Java2D.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-07-10 20:18:26 +0000
committerKenneth Russel <[email protected]>2006-07-10 20:18:26 +0000
commita0c04406276133db40cd39799a0f845369385400 (patch)
treed9ce03523d051be40d49b546844cb60d0554b7ce /src/classes/com/sun/opengl/impl/Java2D.java
parent67cf653d9a50a04a734c7cb4494392bc2687582c (diff)
Added code to support new entry points in
sun.java2d.opengl.CGLSurfaceData added by gziemski to enable the Java2D/JOGL bridge on Mac OS X. Currently untested. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@838 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/impl/Java2D.java')
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/Java2D.java88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/classes/com/sun/opengl/impl/Java2D.java b/src/classes/com/sun/opengl/impl/Java2D.java
index 457c819bd..137545512 100755
--- a/src/classes/com/sun/opengl/impl/Java2D.java
+++ b/src/classes/com/sun/opengl/impl/Java2D.java
@@ -88,6 +88,15 @@ public class Java2D {
private static boolean initializedJ2DFBOShareContext;
private static GLContext j2dFBOShareContext;
+ // Accessors for new methods in sun.java2d.opengl.CGLSurfaceData
+ // class on OS X for enabling bridge
+ // public static long createOGLContextOnSurface(Graphics g);
+ // public static boolean makeOGLContextCurrentOnSurface(Graphics g, long ctx);
+ // public static void destroyOGLContext(long ctx);
+ private static Method createOGLContextOnSurfaceMethod;
+ private static Method makeOGLContextCurrentOnSurfaceMethod;
+ private static Method destroyOGLContextMethod;
+
static {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
@@ -177,6 +186,40 @@ public class Java2D {
System.err.println("GL_ARB_texture_rectangle FBO support disabled");
}
}
+
+ // Try to set up APIs for enabling the bridge on OS X,
+ // where it isn't possible to create generalized
+ // external GLDrawables
+ Class cglSurfaceData = null;
+ try {
+ cglSurfaceData = Class.forName("sun.java2d.opengl.CGLSurfaceData");
+ } catch (Exception e) {
+ if (DEBUG && VERBOSE) {
+ e.printStackTrace();
+ System.err.println("Unable to find class sun.java2d.opengl.CGLSurfaceData for OS X");
+ }
+ }
+ if (cglSurfaceData != null) {
+ // We need to find these methods in order to make the bridge work on OS X
+ createOGLContextOnSurfaceMethod = cglSurfaceData.getDeclaredMethod("createOGLContextOnSurface",
+ new Class[] {
+ Graphics.class
+ });
+ createOGLContextOnSurfaceMethod.setAccessible(true);
+
+ makeOGLContextCurrentOnSurfaceMethod = cglSurfaceData.getDeclaredMethod("makeOGLContextCurrentOnSurface",
+ new Class[] {
+ Graphics.class,
+ Long.TYPE
+ });
+ makeOGLContextCurrentOnSurfaceMethod.setAccessible(true);
+
+ destroyOGLContextMethod = cglSurfaceData.getDeclaredMethod("destroyOGLContext",
+ new Class[] {
+ Long.TYPE
+ });
+ destroyOGLContextMethod.setAccessible(true);
+ }
} catch (Exception e) {
if (DEBUG && VERBOSE) {
e.printStackTrace();
@@ -397,6 +440,51 @@ public class Java2D {
}
//----------------------------------------------------------------------
+ // Mac OS X-specific methods
+ //
+
+ /** (Mac OS X-specific) Creates a new OpenGL context on the surface associated with the
+ given Graphics object. */
+ public static long createOGLContextOnSurface(Graphics g) {
+ checkActive();
+
+ try {
+ return ((Long) createOGLContextOnSurfaceMethod.invoke(null, new Object[] { g })).longValue();
+ } catch (InvocationTargetException e) {
+ throw new GLException(e.getTargetException());
+ } catch (Exception e) {
+ throw (InternalError) new InternalError().initCause(e);
+ }
+ }
+
+ /** (Mac OS X-specific) Makes the given OpenGL context current on
+ the surface associated with the given Graphics object. */
+ public static boolean makeOGLContextCurrentOnSurface(Graphics g, long ctx) {
+ checkActive();
+
+ try {
+ return ((Boolean) makeOGLContextCurrentOnSurfaceMethod.invoke(null, new Object[] { g, new Long(ctx) })).booleanValue();
+ } catch (InvocationTargetException e) {
+ throw new GLException(e.getTargetException());
+ } catch (Exception e) {
+ throw (InternalError) new InternalError().initCause(e);
+ }
+ }
+
+ /** (Mac OS X-specific) Destroys the given OpenGL context. */
+ public static void destroyOGLContext(long ctx) {
+ checkActive();
+
+ try {
+ destroyOGLContextMethod.invoke(null, new Object[] { new Long(ctx) });
+ } catch (InvocationTargetException e) {
+ throw new GLException(e.getTargetException());
+ } catch (Exception e) {
+ throw (InternalError) new InternalError().initCause(e);
+ }
+ }
+
+ //----------------------------------------------------------------------
// Internals only below this point
//