aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java15
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java19
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m65
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface.m43
4 files changed, 117 insertions, 25 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index ec29558d1..e04955d87 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
@@ -490,9 +490,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl
}
backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true);
- boolean allowIncompleteView = null != backingLayerHost;
- if( !allowIncompleteView && surface instanceof ProxySurface ) {
- allowIncompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE );
+ boolean incompleteView = null != backingLayerHost;
+ if( !incompleteView && surface instanceof ProxySurface ) {
+ incompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE );
}
long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor);
if (pixelFormat == 0) {
@@ -514,7 +514,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
screenVSyncTimeout = 1000000f / sRefreshRate;
if(DEBUG) {
System.err.println("NS create OSX>=lion "+isLionOrLater);
- System.err.println("NS create allowIncompleteView: "+allowIncompleteView);
+ System.err.println("NS create incompleteView: "+incompleteView);
System.err.println("NS create backingLayerHost: "+backingLayerHost);
System.err.println("NS create share: "+share);
System.err.println("NS create drawable type: "+drawable.getClass().getName());
@@ -546,7 +546,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
int[] viewNotReady = new int[1];
// Try to allocate a context with this
ctx = CGL.createContext(share,
- nsViewHandle, allowIncompleteView,
+ nsViewHandle, incompleteView,
pixelFormat,
chosenCaps.isBackgroundOpaque(),
viewNotReady, 0);
@@ -603,6 +603,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl
} else if( chosenCaps.isPBuffer() && CGL.isNSOpenGLPixelBuffer(drawableHandle) ) {
texID = 0;
lastPBufferHandle = drawableHandle;
+ if(0 != drawableHandle) { // complete 'validatePBufferConfig(..)' procedure
+ CGL.setContextPBuffer(ctx, drawableHandle);
+ }
} else {
throw new GLException("BackingLayerHost w/ unknown handle (!FBO, !PBuffer): "+drawable);
}
@@ -648,7 +651,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl
private final void validatePBufferConfig(long ctx) {
final GLCapabilitiesImmutable chosenCaps = drawable.getChosenGLCapabilities();
final long drawableHandle = drawable.getHandle();
- if(chosenCaps.isPBuffer() && CGL.isNSOpenGLPixelBuffer(drawableHandle) && lastPBufferHandle != drawableHandle) {
+ if( chosenCaps.isPBuffer() && lastPBufferHandle != drawableHandle && CGL.isNSOpenGLPixelBuffer(drawableHandle) ) {
// Must associate the pbuffer with our newly-created context
lastPBufferHandle = drawableHandle;
if(0 != drawableHandle) {
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
index e344fd461..447d18f68 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java
@@ -39,6 +39,8 @@
package jogamp.opengl.macosx.cgl;
+import javax.media.nativewindow.NativeSurface;
+import javax.media.nativewindow.ProxySurface;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLException;
@@ -60,7 +62,7 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
@Override
protected void drawableUpdatedNotify() throws GLException {
final int w = drawable.getWidth();
- final int h = drawable.getHeight();
+ final int h = drawable.getHeight();
final boolean updateContext = ( 0!=updateHandle && CGL.updateContextNeedsUpdate(updateHandle) ) ||
w != lastWidth || h != lastHeight;
if(updateContext) {
@@ -82,9 +84,18 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext {
if(0 != updateHandle) {
throw new InternalError("XXX1");
}
- updateHandle = CGL.updateContextRegister(contextHandle, drawable.getHandle());
- if(0 == updateHandle) {
- throw new InternalError("XXX2");
+ final boolean incompleteView;
+ final NativeSurface surface = drawable.getNativeSurface();
+ if( surface instanceof ProxySurface ) {
+ incompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE );
+ } else {
+ incompleteView = false;
+ }
+ if(!incompleteView) {
+ updateHandle = CGL.updateContextRegister(contextHandle, drawable.getHandle());
+ if(0 == updateHandle) {
+ throw new InternalError("XXX2");
+ }
}
}
return res;
diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
index 63323b76d..f3495efff 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m
@@ -25,6 +25,56 @@
//
// #define DBG_PERF 1
+/**
+ * Capture setView(NULL), which produces a 'invalid drawable' message
+ *
+ * Also track lifecycle via DBG_PRINT messages, if VERBOSE is enabled!
+ */
+@interface MyNSOpenGLContext: NSOpenGLContext
+{
+}
+- (id)initWithFormat:(NSOpenGLPixelFormat *)format shareContext:(NSOpenGLContext *)share;
+- (void)setView:(NSView *)view;
+- (void)update;
+- (void)dealloc;
+
+@end
+
+@implementation MyNSOpenGLContext
+
+- (id)initWithFormat:(NSOpenGLPixelFormat *)format shareContext:(NSOpenGLContext *)share
+{
+ DBG_PRINT("MyNSOpenGLContext.initWithFormat.0: format %p, share %p\n", format, share);
+ MyNSOpenGLContext * o = [super initWithFormat:format shareContext:share];
+ DBG_PRINT("MyNSOpenGLContext.initWithFormat.X: new %p\n", o);
+ return o;
+}
+
+- (void)setView:(NSView *)view
+{
+ DBG_PRINT("MyNSOpenGLContext.setView: this.0 %p, view %p\n", self, view);
+ if(NULL != view) {
+ [super setView:view];
+ }
+ DBG_PRINT("MyNSOpenGLContext.setView.X\n");
+}
+
+- (void)update
+{
+ DBG_PRINT("MyNSOpenGLContext.update: this.0 %p, view %p\n", self, [self view]);
+ [super update];
+ DBG_PRINT("MyNSOpenGLContext.update.X\n");
+}
+
+- (void)dealloc
+{
+ DBG_PRINT("MyNSOpenGLContext.dealloc: this.0 %p\n", self);
+ [super dealloc];
+ DBG_PRINT("MyNSOpenGLContext.dealloc.X: %p\n", self);
+}
+
+@end
+
@interface MyNSOpenGLLayer: NSOpenGLLayer
{
@private
@@ -204,6 +254,8 @@ static const GLfloat gl_verts[] = {
[self setOpaque: opaque ? YES : NO];
+#ifdef VERBOSE_ON
+ CGRect lRect = [self bounds];
if(NULL != pbuffer) {
DBG_PRINT("MyNSOpenGLLayer::init (pbuffer) %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, bounds: %lf/%lf %lfx%lf (refcnt %d)\n",
self, parentCtx, parentPixelFmt, pbuffer, opaque, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight,
@@ -213,6 +265,7 @@ static const GLfloat gl_verts[] = {
self, parentCtx, parentPixelFmt, opaque, (int)textureID, texWidth, texHeight,
lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]);
}
+#endif
return self;
}
@@ -293,9 +346,10 @@ static const GLfloat gl_verts[] = {
- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat
{
- NSOpenGLContext * nctx = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx];
- DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat: %p (refcnt %d) - pfmt %p, parent %p -> new-ctx %p\n",
- self, (int)[self retainCount], pixelFormat, parentCtx, nctx);
+ DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.0: %p (refcnt %d) - pfmt %p, parent %p\n",
+ self, (int)[self retainCount], pixelFormat, parentCtx);
+ NSOpenGLContext * nctx = [[MyNSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx];
+ DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.X: new-ctx %p\n", nctx);
return nctx;
}
@@ -324,7 +378,7 @@ static const GLfloat gl_verts[] = {
if(NULL!=context) {
[context makeCurrentContext];
- DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (with ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)texureID);
+ DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (with ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)textureID);
if( 0 != textureID ) {
glDeleteTextures(1, &textureID);
@@ -333,7 +387,7 @@ static const GLfloat gl_verts[] = {
[context clearDrawable];
} else {
- DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (w/o ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)texureID);
+ DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (w/o ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)textureID);
}
pbuffer = NULL;
[self setTextureID: 0];
@@ -346,6 +400,7 @@ static const GLfloat gl_verts[] = {
pthread_mutex_lock(&renderLock);
[self disableAnimation];
[self deallocPBuffer];
+ [[self openGLContext] 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 becd41bb2..48807ee29 100644
--- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
+++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m
@@ -446,7 +446,7 @@ NSOpenGLPixelFormat* createPixelFormat(int* iattrs, int niattrs, int* ivalues) {
NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
// if(fmt == nil) { fallback to a [NSOpenGLView defaultPixelFormat] crashed (SIGSEGV) on 10.6.7/NV }
- DBG_PRINT("createPixelFormat.X: pfmt %p\n", fmt);
+ DBG_PRINT("\ncreatePixelFormat.X: pfmt %p\n", fmt);
[pool release];
return fmt;
@@ -503,7 +503,7 @@ NSView* getNSView(NSOpenGLContext* ctx) {
NSOpenGLContext* createContext(NSOpenGLContext* share,
NSView* view,
- Bool allowIncompleteView,
+ Bool incompleteView,
NSOpenGLPixelFormat* fmt,
Bool opaque,
int* viewNotReady)
@@ -512,13 +512,13 @@ NSOpenGLContext* createContext(NSOpenGLContext* share,
getRendererInfo();
- DBG_PRINT("createContext.0: share %p, view %p, allowIncompleteView %d, pixfmt %p, opaque %d\n",
- share, view, (int)allowIncompleteView, fmt, opaque);
+ DBG_PRINT("createContext.0: share %p, view %p, incompleteView %d, pixfmt %p, opaque %d\n",
+ share, view, (int)incompleteView, fmt, opaque);
if (view != nil) {
Bool viewReady = true;
- if(!allowIncompleteView) {
+ if(!incompleteView) {
if ([view lockFocusIfCanDraw] == NO) {
DBG_PRINT("createContext.1 [view lockFocusIfCanDraw] failed\n");
viewReady = false;
@@ -527,7 +527,7 @@ NSOpenGLContext* createContext(NSOpenGLContext* share,
if(viewReady) {
NSRect frame = [view frame];
if ((frame.size.width == 0) || (frame.size.height == 0)) {
- if(!allowIncompleteView) {
+ if(!incompleteView) {
[view unlockFocus];
}
DBG_PRINT("createContext.2 view.frame size %dx%d\n", (int)frame.size.width, (int)frame.size.height);
@@ -557,8 +557,10 @@ NSOpenGLContext* createContext(NSOpenGLContext* share,
GLint zeroOpacity = 0;
[ctx setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity];
}
- [ctx setView:view];
- if(!allowIncompleteView) {
+ if(!incompleteView) {
+ DBG_PRINT("createContext.3.0: setView\n");
+ [ctx setView:view];
+ DBG_PRINT("createContext.3.X: setView\n");
[view unlockFocus];
}
}
@@ -628,7 +630,12 @@ void setContextOpacity(NSOpenGLContext* ctx, int opacity) {
void updateContext(NSOpenGLContext* ctx) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- [ctx update];
+ NSView *nsView = [ctx view];
+ if(NULL != nsView) {
+ DBG_PRINT("updateContext.0: ctx %p, ctx.view %p\n", ctx, nsView);
+ [ctx update];
+ DBG_PRINT("updateContext.X\n");
+ }
[pool release];
}
@@ -638,7 +645,10 @@ void copyContext(NSOpenGLContext* dest, NSOpenGLContext* src, int mask) {
void* updateContextRegister(NSOpenGLContext* ctx, NSView* view) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ DBG_PRINT("updateContextRegister.0: ctx %p, view %p\n", ctx, view);
ContextUpdater *contextUpdater = [[ContextUpdater alloc] initWithContext: ctx view: view];
+ DBG_PRINT("updateContextRegister.X: ctxupd %p\n", contextUpdater);
[pool release];
return contextUpdater;
}
@@ -658,47 +668,60 @@ void updateContextUnregister(void* updater) {
ContextUpdater *contextUpdater = (ContextUpdater *)updater;
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ DBG_PRINT("updateContextUnregister.0: ctxupd %p\n", contextUpdater);
[contextUpdater release];
+ DBG_PRINT("updateContextUnregister.X\n");
[pool release];
}
NSOpenGLPixelBuffer* createPBuffer(int renderTarget, int internalFormat, int width, int height) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ DBG_PRINT("createPBuffer.0: renderTarget 0x%x, ifmt 0x%x, %dx%d: \n", renderTarget, internalFormat, width, height);
NSOpenGLPixelBuffer* pBuffer = [[NSOpenGLPixelBuffer alloc]
initWithTextureTarget:renderTarget
textureInternalFormat:internalFormat
textureMaxMipMapLevel:0
pixelsWide:width
pixelsHigh:height];
+ DBG_PRINT("createPBuffer.X: res %p\n", pBuffer);
[pool release];
return pBuffer;
}
Bool destroyPBuffer(NSOpenGLPixelBuffer* pBuffer) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ DBG_PRINT("destroyPBuffer.0: pbuffer %p\n", pBuffer);
[pBuffer release];
+ DBG_PRINT("destroyPBuffer.X\n");
[pool release];
return true;
}
void setContextPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ DBG_PRINT("setContextPBuffer.0: ctx %p, pbuffer %p\n", ctx, pBuffer);
[ctx setPixelBuffer: pBuffer
cubeMapFace: 0
mipMapLevel: 0
currentVirtualScreen: [ctx currentVirtualScreen]];
+ DBG_PRINT("setContextPBuffer.X\n");
[pool release];
}
void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, GLenum colorBuffer) {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ DBG_PRINT("setContextTextureImageToPBuffer.0: ctx %p, pbuffer %p, colorBuffer 0x%x\n", ctx, pBuffer, (int)colorBuffer);
[ctx setTextureImageToPixelBuffer: pBuffer colorBuffer: colorBuffer];
+ DBG_PRINT("setContextTextureImageToPBuffer.X\n");
[pool release];
}
Bool isNSOpenGLPixelBuffer(uint64_t object) {
NSObject *nsObj = (NSObject*) (intptr_t) object;
- return [nsObj isMemberOfClass:[NSOpenGLPixelBuffer class]];
+ DBG_PRINT("isNSOpenGLPixelBuffer.0: obj %p\n", object);
+ Bool res = [nsObj isMemberOfClass:[NSOpenGLPixelBuffer class]];
+ DBG_PRINT("isNSOpenGLPixelBuffer.X: res %d\n", (int)res);
+ return res;
}
#include <mach-o/dyld.h>