aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/macosx
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-10-13 13:02:32 +0200
committerSven Gothel <[email protected]>2011-10-13 13:02:32 +0200
commit5d33b0a3ef993ff2d257c90abc3d84bc93269cd0 (patch)
treeb6a0a984ce20f8f57a37932476cde851ab31d72e /src/jogl/classes/jogamp/opengl/macosx
parenta8c14db739c8d7765d1a204f73b5708faac07fdd (diff)
MacOSX: Fix shared ctx release [onMainThread]; Make GLContextShareSet lifecycle deterministic; Remove warnings
Fix shared ctx release [onMainThread] - Releasing the shared contexts caused a freeze of about 10s from one of the shared release operations. [NSOpenGLContext release] - Thorough triage concluded the workaround to release the shared ctx on the main thread. - Using enhanced GLContextShareSet, see below Make GLContextShareSet lifecycle deterministic - Programmatically control the lifecycle of tracked shared ctx allows us using 'hard' references. - Features queries for isShared() and ofc unregister a share set if all are destroyed. Remove warnings - MacOSXWindowSystemInterface.m used 'long', where 'GLint' was requested.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/macosx')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java22
3 files changed, 25 insertions, 19 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 6d6b79b42..b35e38d02 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -42,9 +42,11 @@ package jogamp.opengl.macosx.cgl;
import java.nio.*;
import java.util.*;
+
import javax.media.opengl.*;
import javax.media.nativewindow.*;
import jogamp.opengl.*;
+
import com.jogamp.gluegen.runtime.ProcAddressTable;
import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
@@ -204,14 +206,15 @@ public abstract class MacOSXCGLContext extends GLContextImpl
throw new GLException("Unable to delete OpenGL Context (CGL)");
}
if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL Context (CGL) " + contextHandle);
+ System.err.println("!!! Destroyed OpenGL Context (CGL) " + toHexString(contextHandle));
}
} else {
- if (!CGL.deleteContext(contextHandle)) {
- throw new GLException("Unable to delete OpenGL Context (NS)");
+ final boolean isSharedContext = GLContextShareSet.isShared(this);
+ if (!CGL.deleteContext(contextHandle, isSharedContext)) {
+ throw new GLException("Unable to delete OpenGL Context (NS) "+toHexString(contextHandle)+", isShared "+isSharedContext);
}
if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL Context (NS) " + contextHandle);
+ System.err.println("!!! Destroyed OpenGL Context (NS.s0) " + toHexString(contextHandle)+", isShared "+isSharedContext);
}
}
}
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
index 393bd398b..b387c28c8 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
@@ -39,8 +39,8 @@
package jogamp.opengl.macosx.cgl;
-
-import javax.media.opengl.*;
+import javax.media.opengl.GLContext;
+import javax.media.opengl.GLException;
public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
@@ -82,7 +82,10 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
@Override
protected boolean createImpl() {
boolean res = create(false, false);
- if(res && isNSContext) {
+ if(!isNSContext) {
+ throw new InternalError("XXX0");
+ }
+ if(res) {
if(0 != updateHandle) {
throw new InternalError("XXX1");
}
@@ -100,7 +103,7 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
CGL.updateContextUnregister(updateHandle);
updateHandle = 0;
}
- super.destroyImpl();
+ super.destroyImpl();
}
@Override
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
index 75b54504a..efc70e3dd 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -117,12 +117,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
}
protected void destroyImpl() throws GLException {
- if (!impl.destroy(contextHandle)) {
- throw new GLException("Unable to delete OpenGL context");
- }
- if (DEBUG) {
- System.err.println("!!! Destroyed OpenGL context " + contextHandle);
- }
+ impl.destroy(contextHandle);
}
protected void setSwapIntervalImpl(int interval) {
@@ -212,7 +207,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
interface Impl {
public boolean isNSContext();
public long create();
- public boolean destroy(long ctx);
+ public void destroy(long ctx);
public boolean makeCurrent(long ctx);
public boolean release(long ctx);
public void setSwapInterval(long ctx, int interval);
@@ -237,8 +232,8 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
return contextHandle;
}
- public boolean destroy(long ctx) {
- return CGL.deleteContext(ctx);
+ public void destroy(long ctx) {
+ MacOSXPbufferCGLContext.super.destroyImpl();
}
public boolean makeCurrent(long ctx) {
@@ -344,8 +339,13 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
return ctx.get(0);
}
- public boolean destroy(long ctx) {
- return (CGL.CGLDestroyContext(ctx) == CGL.kCGLNoError);
+ public void destroy(long ctx) {
+ if (CGL.CGLDestroyContext(ctx) != CGL.kCGLNoError) {
+ throw new GLException("Unable to delete OpenGL context (cgl)");
+ }
+ if (DEBUG) {
+ System.err.println("!!! Destroyed OpenGL context (cgl)" + contextHandle);
+ }
}
public boolean makeCurrent(long ctx) {