diff options
6 files changed, 84 insertions, 0 deletions
diff --git a/make/stub_includes/opengl/macosx-window-system.h b/make/stub_includes/opengl/macosx-window-system.h index ed07ce74d..0d3865350 100644 --- a/make/stub_includes/opengl/macosx-window-system.h +++ b/make/stub_includes/opengl/macosx-window-system.h @@ -22,6 +22,7 @@ Bool clearCurrentContext(void* nsContext); Bool deleteContext(void* nsContext); Bool flushBuffer(void* nsContext); void updateContext(void* nsContext); +void copyContext(void* destContext, void* srcContext, int mask); void* updateContextRegister(void* nsContext, void* nsView); void updateContextUnregister(void* nsContext, void* nsView, void* updater); diff --git a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLContext.java b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLContext.java index 16855efb8..02bf81f2e 100644 --- a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLContext.java +++ b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLContext.java @@ -277,6 +277,18 @@ public abstract class MacOSXGLContext extends GLContextImpl return (nsContext != 0); } + public void copy(GLContext source, int mask) throws GLException { + long dst = getNSContext(); + long src = ((MacOSXGLContext) source).getNSContext(); + if (src == 0) { + throw new GLException("Source OpenGL context has not been created"); + } + if (dst == 0) { + throw new GLException("Destination OpenGL context has not been created"); + } + CGL.copyContext(dst, src, mask); + } + protected void resetGLFunctionAvailability() { super.resetGLFunctionAvailability(); diff --git a/src/classes/com/sun/opengl/impl/windows/WindowsGLContext.java b/src/classes/com/sun/opengl/impl/windows/WindowsGLContext.java index 7a4b73351..1276aea92 100644 --- a/src/classes/com/sun/opengl/impl/windows/WindowsGLContext.java +++ b/src/classes/com/sun/opengl/impl/windows/WindowsGLContext.java @@ -207,6 +207,20 @@ public class WindowsGLContext extends GLContextImpl { return (hglrc != 0); } + public void copy(GLContext source, int mask) throws GLException { + long dst = getHGLRC(); + long src = ((WindowsGLContext) source).getHGLRC(); + if (src == 0) { + throw new GLException("Source OpenGL context has not been created"); + } + if (dst == 0) { + throw new GLException("Destination OpenGL context has not been created"); + } + if (!WGL.wglCopyContext(src, dst, mask)) { + throw new GLException("wglCopyContext failed"); + } + } + protected void resetGLFunctionAvailability() { super.resetGLFunctionAvailability(); if (DEBUG) { diff --git a/src/classes/com/sun/opengl/impl/x11/X11GLContext.java b/src/classes/com/sun/opengl/impl/x11/X11GLContext.java index 0ed5eaebb..17b2cca40 100644 --- a/src/classes/com/sun/opengl/impl/x11/X11GLContext.java +++ b/src/classes/com/sun/opengl/impl/x11/X11GLContext.java @@ -193,6 +193,27 @@ public abstract class X11GLContext extends GLContextImpl { return (context != 0); } + public void copy(GLContext source, int mask) throws GLException { + long dst = getContext(); + long src = ((X11GLContext) source).getContext(); + if (src == 0) { + throw new GLException("Source OpenGL context has not been created"); + } + if (dst == 0) { + throw new GLException("Destination OpenGL context has not been created"); + } + if (mostRecentDisplay == 0) { + throw new GLException("Connection to X display not yet set up"); + } + lockToolkit(); + try { + GLX.glXCopyContext(mostRecentDisplay, src, dst, mask); + // Should check for X errors and raise GLException + } finally { + unlockToolkit(); + } + } + protected void resetGLFunctionAvailability() { super.resetGLFunctionAvailability(); if (DEBUG) { diff --git a/src/classes/javax/media/opengl/GLContext.java b/src/classes/javax/media/opengl/GLContext.java index b6bc7c66d..a70e131c8 100644 --- a/src/classes/javax/media/opengl/GLContext.java +++ b/src/classes/javax/media/opengl/GLContext.java @@ -112,6 +112,36 @@ public abstract class GLContext { public abstract void release() throws GLException; /** + * Copies selected groups of OpenGL state variables from the + * supplied source context into this one. The <code>mask</code> + * parameter indicates which groups of state variables are to be + * copied. <code>mask</code> contains the bitwise OR of the same + * symbolic names that are passed to the GL command {@link + * GL#glPushAttrib glPushAttrib}. The single symbolic constant + * {@link GL#GL_ALL_ATTRIB_BITS GL_ALL_ATTRIB_BITS} can be used to + * copy the maximum possible portion of rendering state. <P> + * + * Not all values for GL state can be copied. For example, pixel + * pack and unpack state, render mode state, and select and feedback + * state are not copied. The state that can be copied is exactly the + * state that is manipulated by the GL command {@link + * GL#glPushAttrib glPushAttrib}. <P> + * + * On most platforms, this context may not be current to any thread, + * including the calling thread, when this method is called. Some + * platforms have additional requirements such as whether this + * context or the source context must occasionally be made current + * in order for the results of the copy to be seen; these + * requirements are beyond the scope of this specification. + * + * @param source the source OpenGL context from which to copy state + * @param mask a mask of symbolic names indicating which groups of state to copy + + * @throws GLException if an OpenGL-related error occurred + */ + public abstract void copy(GLContext source, int mask) throws GLException; + + /** * Returns the context which is current on the current thread. If no * context is current, returns null. * diff --git a/src/native/jogl/MacOSXWindowSystemInterface.m b/src/native/jogl/MacOSXWindowSystemInterface.m index e7250b420..9fbc4c006 100644 --- a/src/native/jogl/MacOSXWindowSystemInterface.m +++ b/src/native/jogl/MacOSXWindowSystemInterface.m @@ -567,6 +567,12 @@ void updateContext(void* context) { [pool release]; } +void copyContext(void* destContext, void* srcContext, int mask) { + NSOpenGLContext *src = (NSOpenGLContext*) srcContext; + NSOpenGLContext *dst = (NSOpenGLContext*) destContext; + [dst copyAttributesFromContext: src withMask: mask]; +} + void* updateContextRegister(void* context, void* view) { NSOpenGLContext *nsContext = (NSOpenGLContext*)context; NSView *nsView = (NSView*)view; |