aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2007-01-07 18:15:52 +0000
committerKenneth Russel <[email protected]>2007-01-07 18:15:52 +0000
commitb7244795d44ab06ea32d68136cdb1408804514cc (patch)
tree69aec31745365cb17d5eaf07e79bf45ed5f5b147 /src
parenta38af8cf1605adaf23ab43fb93feaf7d8bbce98e (diff)
Fixed Issue 259: need a copy context
Added and specified GLContext.copy() and supplied implementations on Windows, X11 and Mac OS X platforms. New code is untested at this time. May need to make subsequent changes on X11 and Mac platforms where new code has not been compiled yet. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1075 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rw-r--r--src/classes/com/sun/opengl/impl/macosx/MacOSXGLContext.java12
-rw-r--r--src/classes/com/sun/opengl/impl/windows/WindowsGLContext.java14
-rw-r--r--src/classes/com/sun/opengl/impl/x11/X11GLContext.java21
-rw-r--r--src/classes/javax/media/opengl/GLContext.java30
-rw-r--r--src/native/jogl/MacOSXWindowSystemInterface.m6
5 files changed, 83 insertions, 0 deletions
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;