aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2005-12-05 22:36:25 +0000
committerKenneth Russel <[email protected]>2005-12-05 22:36:25 +0000
commit6d8ae643c68b1b3f9cca3ec56485cd85f010a5b3 (patch)
tree1ed68c8cb4fa1a5e53fda2f75428efc98b423964 /src/classes/com/sun/opengl
parent7bc47042a9203aa18a71b92ef8ef90af19518d51 (diff)
Added MacOSXExternalGLContext support as suggested by Billy Biggs
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@481 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl')
-rw-r--r--src/classes/com/sun/opengl/impl/macosx/MacOSXExternalGLContext.java96
-rw-r--r--src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java3
-rw-r--r--src/classes/com/sun/opengl/impl/macosx/MacOSXOnscreenGLContext.java4
3 files changed, 101 insertions, 2 deletions
diff --git a/src/classes/com/sun/opengl/impl/macosx/MacOSXExternalGLContext.java b/src/classes/com/sun/opengl/impl/macosx/MacOSXExternalGLContext.java
new file mode 100644
index 000000000..7a0b53a98
--- /dev/null
+++ b/src/classes/com/sun/opengl/impl/macosx/MacOSXExternalGLContext.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.impl.macosx;
+
+import javax.media.opengl.*;
+import com.sun.opengl.impl.*;
+
+public class MacOSXExternalGLContext extends MacOSXGLContext {
+ private boolean firstMakeCurrent = true;
+ private boolean created = true;
+
+ public MacOSXExternalGLContext() {
+ super(null, null);
+
+ // FIXME: we don't have a "current context" primitive implemented
+ // yet on OS X. In the current implementation this would need to
+ // return an NSOpenGLContext*, but "external" toolkits are not
+ // guaranteed to be using the Cocoa OpenGL API. Additionally, if
+ // we switched this implementation to use the low-level CGL APIs,
+ // we would lose the ability to share textures and display lists
+ // between contexts since you need an NSOpenGLContext, not a
+ // CGLContextObj, in order to share textures and display lists
+ // between two NSOpenGLContexts.
+ //
+ // The ramifications here are that it is not currently possible to
+ // share textures and display lists between an OpenGL context
+ // created by JOGL and one created by a third-party library on OS
+ // X.
+
+ // context = CGL.CGLGetCurrentContext();
+
+ GLContextShareSet.contextCreated(this);
+ resetGLFunctionAvailability();
+ }
+
+ protected boolean create() {
+ return true;
+ }
+
+ protected int makeCurrentImpl() throws GLException {
+ if (firstMakeCurrent) {
+ firstMakeCurrent = false;
+ return CONTEXT_CURRENT_NEW;
+ }
+ return CONTEXT_CURRENT;
+ }
+
+ protected void releaseImpl() throws GLException {
+ }
+
+ protected void destroyImpl() throws GLException {
+ created = false;
+ GLContextShareSet.contextDestroyed(this);
+ }
+
+ public boolean isCreated() {
+ return created;
+ }
+}
diff --git a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java
index 8aed41876..b05886e15 100644
--- a/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java
+++ b/src/classes/com/sun/opengl/impl/macosx/MacOSXGLDrawableFactory.java
@@ -106,8 +106,7 @@ public class MacOSXGLDrawableFactory extends GLDrawableFactoryImpl {
}
public GLContext createExternalGLContext() {
- // FIXME
- throw new GLException("Not yet implemented");
+ return new MacOSXExternalGLContext();
}
public boolean canCreateExternalGLDrawable() {
diff --git a/src/classes/com/sun/opengl/impl/macosx/MacOSXOnscreenGLContext.java b/src/classes/com/sun/opengl/impl/macosx/MacOSXOnscreenGLContext.java
index 9e20dd6dd..3023ca708 100644
--- a/src/classes/com/sun/opengl/impl/macosx/MacOSXOnscreenGLContext.java
+++ b/src/classes/com/sun/opengl/impl/macosx/MacOSXOnscreenGLContext.java
@@ -53,6 +53,10 @@ public class MacOSXOnscreenGLContext extends MacOSXGLContext {
this.drawable = drawable;
}
+ protected boolean create() {
+ return create(true, false);
+ }
+
protected int makeCurrentImpl() throws GLException {
try {
int lockRes = drawable.lockSurface();