From 808c8da0729b845d010d3f5e0babf1fc6129c3e9 Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
Date: Sun, 4 Nov 2012 06:42:43 +0100
Subject: MacOSXCGLContext[NSOpenGLLayer/NSView]: Propagate drawable change

Propagate drawable change to MacOSXCGLContext where either context/NSView or context/NSOpenGLLayer
association needs to get updated.

Fixes drawable/context switch.
---
 .../native/macosx/MacOSXWindowSystemInterface-calayer.m     |  1 +
 src/jogl/native/macosx/MacOSXWindowSystemInterface.m        | 13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

(limited to 'src/jogl/native')

diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
index 6ebf400e2..b37930587 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
@@ -448,6 +448,7 @@ static const GLfloat gl_verts[] = {
     [self disableAnimation];
     [self deallocPBuffer];
     [[self openGLContext] release];
+    [parentPixelFmt release];
     [self release];
     DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p (refcnt %d)\n", self, (int)[self retainCount]);
     pthread_mutex_unlock(&renderLock);
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
index 48807ee29..e8925f8e8 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
@@ -551,8 +551,7 @@ NSOpenGLContext* createContext(NSOpenGLContext* share,
     
     NSOpenGLContext* ctx = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:share];
         
-    if (ctx != nil) {
-      if (view != nil) {
+    if ( nil != ctx && nil != view ) {
         if(!opaque) {
             GLint zeroOpacity = 0;
             [ctx setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity];
@@ -563,7 +562,6 @@ NSOpenGLContext* createContext(NSOpenGLContext* share,
             DBG_PRINT("createContext.3.X: setView\n");
             [view unlockFocus];        
         }
-      }
     }
 
     DBG_PRINT("createContext.X: ctx: %p\n", ctx);
@@ -571,6 +569,15 @@ NSOpenGLContext* createContext(NSOpenGLContext* share,
     return ctx;
 }
 
+void setContextView(NSOpenGLContext* ctx, NSView* view) {
+    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+    if ( nil != ctx && nil != view ) {
+        [ctx setView:view];
+    }
+    [pool release];
+    return ctx;
+}
+
 Bool makeCurrentContext(NSOpenGLContext* ctx) {
 #if 0
   // we issue the CGL Lock from Java upfront!
-- 
cgit v1.2.3