summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java2
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/Java2D.java14
-rw-r--r--src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java4
-rw-r--r--src/classes/com/sun/opengl/impl/macosx/MacOSXJava2DGLContext.java29
-rw-r--r--src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java2
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java2
-rw-r--r--src/classes/javax/media/opengl/GLJPanel.java2
7 files changed, 40 insertions, 15 deletions
diff --git a/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java b/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
index 2991263b6..d5b14c099 100644
--- a/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
+++ b/src/classes/com/sun/opengl/impl/GLDrawableFactoryImpl.java
@@ -89,7 +89,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory implements
public abstract boolean canCreateContextOnJava2DSurface();
- public abstract GLContext createContextOnJava2DSurface(Graphics g)
+ public abstract GLContext createContextOnJava2DSurface(Graphics g, GLContext shareWith)
throws GLException;
//----------------------------------------------------------------------
diff --git a/src/classes/com/sun/opengl/impl/Java2D.java b/src/classes/com/sun/opengl/impl/Java2D.java
index 515cc578c..9b9cff29d 100755
--- a/src/classes/com/sun/opengl/impl/Java2D.java
+++ b/src/classes/com/sun/opengl/impl/Java2D.java
@@ -90,7 +90,7 @@ public class Java2D {
// Accessors for new methods in sun.java2d.opengl.CGLSurfaceData
// class on OS X for enabling bridge
- // public static long createOGLContextOnSurface(Graphics g);
+ // public static long createOGLContextOnSurface(Graphics g, long ctx);
// public static boolean makeOGLContextCurrentOnSurface(Graphics g, long ctx);
// public static void destroyOGLContext(long ctx);
private static Method createOGLContextOnSurfaceMethod;
@@ -206,7 +206,8 @@ public class Java2D {
// We need to find these methods in order to make the bridge work on OS X
createOGLContextOnSurfaceMethod = cglSurfaceData.getDeclaredMethod("createOGLContextOnSurface",
new Class[] {
- Graphics.class
+ Graphics.class,
+ Long.TYPE
});
createOGLContextOnSurfaceMethod.setAccessible(true);
@@ -446,13 +447,14 @@ 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) {
+ /** (Mac OS X-specific) Creates a new OpenGL context on the surface
+ associated with the given Graphics object, sharing textures and
+ display lists with the specified (CGLContextObj) share context. */
+ public static long createOGLContextOnSurface(Graphics g, long shareCtx) {
checkActive();
try {
- return ((Long) createOGLContextOnSurfaceMethod.invoke(null, new Object[] { g })).longValue();
+ return ((Long) createOGLContextOnSurfaceMethod.invoke(null, new Object[] { g, new Long(shareCtx) })).longValue();
} catch (InvocationTargetException e) {
throw new GLException(e.getTargetException());
} catch (Exception e) {
diff --git a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java
index 855512213..6c56a2b6d 100644
--- a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java
@@ -147,9 +147,9 @@ public class MacOSXGLDrawableFactory extends GLDrawableFactoryImpl {
return true;
}
- public GLContext createContextOnJava2DSurface(Graphics g)
+ public GLContext createContextOnJava2DSurface(Graphics g, GLContext shareWith)
throws GLException {
- return new MacOSXJava2DGLContext();
+ return new MacOSXJava2DGLContext(shareWith);
}
diff --git a/src/classes/com/sun/opengl/impl/macosx/MacOSXJava2DGLContext.java b/src/classes/com/sun/opengl/impl/macosx/MacOSXJava2DGLContext.java
index 3082dd200..5f4de0464 100644
--- a/src/classes/com/sun/opengl/impl/macosx/MacOSXJava2DGLContext.java
+++ b/src/classes/com/sun/opengl/impl/macosx/MacOSXJava2DGLContext.java
@@ -58,8 +58,8 @@ public class MacOSXJava2DGLContext extends MacOSXGLContext implements Java2DGLCo
// rethink this in particular if using FBOs to implement the
// Java2D/OpenGL pipeline on Mac OS X
- public MacOSXJava2DGLContext() {
- super(null, null);
+ public MacOSXJava2DGLContext(GLContext shareWith) {
+ super(null, shareWith);
}
public void setGraphics(Graphics g) {
@@ -90,7 +90,30 @@ public class MacOSXJava2DGLContext extends MacOSXGLContext implements Java2DGLCo
}
protected boolean create() {
- long ctx = Java2D.createOGLContextOnSurface(graphics);
+ // Find and configure share context
+ MacOSXGLContext other = (MacOSXGLContext) GLContextShareSet.getShareContext(this);
+ long share = 0;
+ if (other != null) {
+ // Reconfigure pbuffer-based GLContexts
+ if (other instanceof MacOSXPbufferGLContext) {
+ MacOSXPbufferGLContext ctx = (MacOSXPbufferGLContext) other;
+ ctx.setOpenGLMode(MacOSXGLDrawable.CGL_MODE);
+ } else {
+ if (other.getOpenGLMode() != MacOSXGLDrawable.CGL_MODE) {
+ throw new GLException("Can't share between NSOpenGLContexts and CGLContextObjs");
+ }
+ }
+ share = other.getNSContext();
+ // Note we don't check for a 0 return value, since switching
+ // the context's mode causes it to be destroyed and not
+ // re-initialized until the next makeCurrent
+ }
+
+ if (DEBUG) {
+ System.err.println("!!! Share context is " + toHexString(share) + " for " + getClass().getName());
+ }
+
+ long ctx = Java2D.createOGLContextOnSurface(graphics, share);
if (ctx == 0) {
return false;
}
diff --git a/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java
index dada5d0c3..1c77d5b04 100644
--- a/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/windows/WindowsGLDrawableFactory.java
@@ -227,7 +227,7 @@ public class WindowsGLDrawableFactory extends GLDrawableFactoryImpl {
return false;
}
- public GLContext createContextOnJava2DSurface(Graphics g)
+ public GLContext createContextOnJava2DSurface(Graphics g, GLContext shareWith)
throws GLException {
throw new GLException("Unimplemented on this platform");
}
diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
index a5a174236..12a36e350 100644
--- a/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/x11/X11GLDrawableFactory.java
@@ -531,7 +531,7 @@ public class X11GLDrawableFactory extends GLDrawableFactoryImpl {
return false;
}
- public GLContext createContextOnJava2DSurface(Graphics g)
+ public GLContext createContextOnJava2DSurface(Graphics g, GLContext shareWith)
throws GLException {
throw new GLException("Unimplemented on this platform");
}
diff --git a/src/classes/javax/media/opengl/GLJPanel.java b/src/classes/javax/media/opengl/GLJPanel.java
index 6ab2a9ec7..f4c59159f 100644
--- a/src/classes/javax/media/opengl/GLJPanel.java
+++ b/src/classes/javax/media/opengl/GLJPanel.java
@@ -556,7 +556,7 @@ public class GLJPanel extends JPanel implements GLAutoDrawable {
joglContext = joglDrawable.createContext(shareWith);
} else if (GLDrawableFactoryImpl.getFactoryImpl().canCreateContextOnJava2DSurface()) {
// Mac OS X code path
- joglContext = GLDrawableFactoryImpl.getFactoryImpl().createContextOnJava2DSurface(g);
+ joglContext = GLDrawableFactoryImpl.getFactoryImpl().createContextOnJava2DSurface(g, shareWith);
}
if (DEBUG) {
joglContext.setGL(new DebugGL(joglContext.getGL()));