From 4f936be964c9e8613a5e43e1d88490ff7f550ec9 Mon Sep 17 00:00:00 2001
From: Kenneth Russel <kbrussel@alum.mit.edu>
Date: Tue, 8 Jul 2003 09:20:04 +0000
Subject: Added sharing of display lists and textures among OpenGL contexts
 through new methods in GLDrawableFactory; GLContext has not been exposed in
 the public API. Tested with new simple TestContextSharing demonstration on
 Windows, Linux and Mac OS X.

git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@18 232f8b59-042b-4e1e-8c03-345bb8c30851
---
 .../jogl/impl/macosx/MacOSXOnscreenGLContext.java    | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

(limited to 'src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java')

diff --git a/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java b/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java
index 5b0df9052..8f75fd561 100644
--- a/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java
+++ b/src/net/java/games/jogl/impl/macosx/MacOSXOnscreenGLContext.java
@@ -53,8 +53,11 @@ public class MacOSXOnscreenGLContext extends MacOSXGLContext {
   private long nsView; // NSView
   private Runnable myDeferredReshapeAction;
     
-  public MacOSXOnscreenGLContext(Component component, GLCapabilities capabilities, GLCapabilitiesChooser chooser) {
-    super(component, capabilities, chooser);
+  public MacOSXOnscreenGLContext(Component component,
+                                 GLCapabilities capabilities,
+                                 GLCapabilitiesChooser chooser,
+                                 GLContext shareWith) {
+    super(component, capabilities, chooser, shareWith);
   }
     
   public synchronized void invokeGL(final Runnable runnable, boolean isReshape, Runnable initAction) throws GLException {
@@ -121,12 +124,19 @@ public class MacOSXOnscreenGLContext extends MacOSXGLContext {
   }
 
   protected void create() {
-    nsContext = CGL.createContext(nsView);
+    MacOSXGLContext other = (MacOSXGLContext) GLContextShareSet.getShareContext(this);
+    long share = 0;
+    if (other != null) {
+      share = other.getNSContext();
+      if (share == 0) {
+        throw new GLException("GLContextShareSet returned an invalid OpenGL context");
+      }
+    }
+    nsContext = CGL.createContext(nsView, share);
     if (nsContext == 0) {
       throw new GLException("Error creating nsContext");
     }
-    // FIXME
-    //choosePixelFormatAndCreateContext(true);
+    GLContextShareSet.contextCreated(this);
   }    
     
   protected synchronized boolean makeCurrent(Runnable initAction) throws GLException {
-- 
cgit v1.2.3