diff options
Diffstat (limited to 'src/jogl')
10 files changed, 84 insertions, 53 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java index 8cb25174c..5172cccbd 100644 --- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java +++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java @@ -30,10 +30,10 @@ package com.jogamp.opengl; import com.jogamp.common.GlueGenVersion; import javax.media.opengl.*; + import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.JogampVersion; -import com.jogamp.nativewindow.NativeWindowVersion; import java.util.jar.Manifest; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -89,10 +89,12 @@ public class JoglVersion extends JogampVersion { sb.append(Platform.getNewline()); sb.append("GL ").append(gl); sb.append(Platform.getNewline()); - sb.append("GL_VENDOR ").append(gl.glGetString(gl.GL_VENDOR)); + sb.append("GL_VENDOR ").append(gl.glGetString(GL.GL_VENDOR)); sb.append(Platform.getNewline()); - sb.append("GL_VERSION ").append(gl.glGetString(gl.GL_VERSION)); + sb.append("GL_RENDERER ").append(gl.glGetString(GL.GL_RENDERER)); sb.append(Platform.getNewline()); + sb.append("GL_VERSION ").append(gl.glGetString(GL.GL_VERSION)); + sb.append(Platform.getNewline()); sb.append("GL_EXTENSIONS "); sb.append(Platform.getNewline()); sb.append(" ").append(ctx.getGLExtensionsString()); diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index a86a2f435..286c70e54 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -64,7 +64,7 @@ public class PMVMatrix implements GLMatrixFunc { * In most Java implementations, direct NIO buffers have no backing array * and hence the Java computation will be throttled down by direct IO get/put * operations.</p> - * <p>Depending on the application, ie. weather the Java computation or + * <p>Depending on the application, ie. whether the Java computation or * JNI invocation and hence native data transfer part is heavier, * this flag shall be set to <code>true</code> or <code>false</code></p>. */ diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 8626400f7..131f42e06 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -69,7 +69,8 @@ import jogamp.opengl.GLContextImpl; refer to a given context. */ public abstract class GLContext { public static final boolean DEBUG = Debug.debug("GLContext"); - + + public static final boolean TRACE_SWITCH; /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */ public final static boolean DEBUG_GL; /** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */ @@ -79,6 +80,7 @@ public abstract class GLContext { final AccessControlContext acl = AccessController.getContext(); DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true, acl); TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true, acl); + TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true, acl); } /** Indicates that the context was not made current during the last call to {@link #makeCurrent makeCurrent}. */ @@ -295,6 +297,9 @@ public abstract class GLContext { * new GLContext implementations; not for use by end users. */ protected static void setCurrent(GLContext cur) { + if(TRACE_SWITCH) { + System.err.println("GLContext.ContextSwitch: - setCurrent() - "+Thread.currentThread().getName()+": "+cur); + } currentContext.set(cur); } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index e87d283eb..a7710e5bc 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -67,8 +67,6 @@ import javax.media.opengl.GLPipelineFactory; import javax.media.opengl.GLProfile; public abstract class GLContextImpl extends GLContext { - public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); - /** * Context full qualified name: display_type + display_connection + major + minor + ctp. * This is the key for all cached GL ProcAddressTables, etc, to support multi display/device setups. @@ -242,18 +240,24 @@ public abstract class GLContextImpl extends GLContext { release(false); } private void release(boolean force) throws GLException { + if(TRACE_SWITCH) { + System.err.println("GLContext.ContextSwitch: - release() - "+Thread.currentThread().getName()+": force: "+force+", "+lock); + } if ( !lock.isOwner() ) { - throw new GLException("Context not current on current thread"); + throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this); } final boolean actualRelease = force || lock.getHoldCount() == 1 ; - try { + try { if( actualRelease ) { - setCurrent(null); if (contextHandle != 0) { // allow dbl-release releaseImpl(); } } } finally { + // exception prone .. + if( actualRelease ) { + setCurrent(null); + } drawable.unlockSurface(); lock.unlock(); if(TRACE_SWITCH) { @@ -276,7 +280,7 @@ public abstract class GLContextImpl extends GLContext { throw new GLException("XXX: "+lock); } if (DEBUG || TRACE_SWITCH) { - System.err.println("GLContextImpl.destroy.0: " + toHexString(contextHandle) + + System.err.println("GLContextImpl.destroy.0 - "+Thread.currentThread().getName()+": " + toHexString(contextHandle) + ", isShared "+GLContextShareSet.isShared(this)+" - "+lock); } if (contextHandle != 0) { diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 0dd1a460e..522640294 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -366,7 +366,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl destroyImpl(); ((MacOSXCGLDrawable)drawable).setOpenGLMode(mode); if (DEBUG) { - System.err.println("Switching context mode " + openGLMode + " -> " + mode); + System.err.println("MacOSXCGLContext: Switching context mode " + openGLMode + " -> " + mode); } initOpenGLImpl(mode); openGLMode = mode; @@ -414,11 +414,15 @@ public abstract class MacOSXCGLContext extends GLContextImpl final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor); if (pixelFormat == 0) { - throw new GLException("Unable to allocate pixel format with requested GLCapabilities"); + if(DEBUG) { + System.err.println("Unable to allocate pixel format with requested GLCapabilities: "+chosenCaps); + } + return 0; } config.setChosenPixelFormat(pixelFormat); if(DEBUG) { System.err.println("NS create OSX>=lion "+isLionOrLater); + System.err.println("NS create backendType: "+drawable.getOpenGLMode()); System.err.println("NS create backingLayerHost: "+backingLayerHost); System.err.println("NS create share: "+share); System.err.println("NS create chosenCaps: "+chosenCaps); @@ -532,7 +536,14 @@ public abstract class MacOSXCGLContext extends GLContextImpl } public boolean release(long ctx) { - gl.glFinish(); // w/o glFinish() OSX < 10.7 (NVidia driver) may freeze + try { + gl.glFinish(); // w/o glFinish() OSX < 10.7 (NVidia driver) may freeze + } catch (GLException gle) { + if(DEBUG) { + System.err.println("MacOSXCGLContext.NSOpenGLImpl.release: INFO: glFinish() catched exception:"); + gle.printStackTrace(); + } + } final boolean res = CGL.clearCurrentContext(ctx); final long cglCtx = CGL.getCGLContext(ctx); if(0 == cglCtx) { @@ -636,7 +647,14 @@ public abstract class MacOSXCGLContext extends GLContextImpl } public boolean release(long ctx) { - gl.glFinish(); // w/o glFinish() OSX < 10.7 (NVidia driver) may freeze + try { + gl.glFinish(); // w/o glFinish() OSX < 10.7 (NVidia driver) may freeze + } catch (GLException gle) { + if(DEBUG) { + System.err.println("MacOSXCGLContext.CGLImpl.release: INFO: glFinish() catched exception:"); + gle.printStackTrace(); + } + } int err = CGL.CGLSetCurrentContext(0); if(DEBUG && CGL.kCGLNoError != err) { System.err.println("CGL: Could not release current context: err 0x"+Integer.toHexString(err)+": "+this); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index 12d480fd1..7b5efc31a 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -106,7 +106,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { } protected long getNSViewHandle() { - return GLBackendType.NSOPENGL == openGLMode ? getHandle() : null; + return GLBackendType.NSOPENGL == openGLMode ? getHandle() : 0; } protected void registerContext(MacOSXCGLContext ctx) { @@ -151,7 +151,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { destroyImpl(); if (DEBUG) { - System.err.println("Switching context mode " + openGLMode + " -> " + mode); + System.err.println("MacOSXCGLDrawable: Switching context mode " + openGLMode + " -> " + mode); } initOpenGLImpl(mode); openGLMode = mode; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 3dd7a7f08..5c6486799 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -210,6 +210,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } final GLCapabilities caps = new GLCapabilities(glp); caps.setRedBits(5); caps.setGreenBits(5); caps.setBlueBits(5); caps.setAlphaBits(0); + caps.setDepthBits(5); caps.setDoubleBuffered(false); caps.setOnscreen(false); caps.setPBuffer(true); @@ -230,11 +231,18 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } } catch (GLException gle) { if (DEBUG) { - System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: makeCurrent failed"); + System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: makeCurrent catched exception:"); gle.printStackTrace(); } } finally { - context.destroy(); + try { + context.destroy(); + } catch (GLException gle) { + if (DEBUG) { + System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: destroy catched exception:"); + gle.printStackTrace(); + } + } } } drawable.destroy(); @@ -265,7 +273,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } } catch (GLException gle) { if(DEBUG) { - System.err.println("Catched Exception while MaxOSXCGL Shared Resource initialization"); + System.err.println("Catched Exception while MaxOSXCGL Shared Resource initialization:"); gle.printStackTrace(); } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index f552ab3dd..efab37e1b 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -78,10 +78,10 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration } static final int[] cglInternalAttributeToken = new int[] { - CGL.kCGLPFAOpenGLProfile, - CGL.kCGLPFAColorFloat, + CGL.kCGLPFAOpenGLProfile, // >= lion + CGL.NSOpenGLPFAAccelerated, // query only (prefer accelerated, but allow non accelerated), ignored for createPixelformat CGL.NSOpenGLPFANoRecovery, - CGL.NSOpenGLPFAAccelerated, + CGL.kCGLPFAColorFloat, CGL.NSOpenGLPFAPixelBuffer, CGL.NSOpenGLPFADoubleBuffer, CGL.NSOpenGLPFAStereo, @@ -109,17 +109,14 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration case CGL.kCGLPFAOpenGLProfile: ivalues[idx] = MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor); break; - case CGL.kCGLPFAColorFloat: - ivalues[idx] = caps.getPbufferFloatingPointBuffers() ? 1 : 0; - break; - case CGL.NSOpenGLPFANoRecovery: ivalues[idx] = caps.getHardwareAccelerated() ? 1 : 0; break; - case CGL.NSOpenGLPFAAccelerated: - ivalues[idx] = caps.getHardwareAccelerated() ? 1 : 0; - break; + case CGL.kCGLPFAColorFloat: + ivalues[idx] = caps.getPbufferFloatingPointBuffers() ? 1 : 0; + break; + case CGL.NSOpenGLPFAPixelBuffer: ivalues[idx] = caps.isPBuffer() ? 1 : 0; break; @@ -287,14 +284,14 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration for (int i = 0; i < len; i++) { int attr = cglInternalAttributeToken[i+off]; switch (attr) { - case CGL.kCGLPFAColorFloat: - caps.setPbufferFloatingPointBuffers(ivalues[i] != 0); - break; - case CGL.NSOpenGLPFAAccelerated: caps.setHardwareAccelerated(ivalues[i] != 0); break; + case CGL.kCGLPFAColorFloat: + caps.setPbufferFloatingPointBuffers(ivalues[i] != 0); + break; + case CGL.NSOpenGLPFAPixelBuffer: caps.setPBuffer(ivalues[i] != 0); break; diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m index fe896cc53..b713465f7 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m @@ -102,11 +102,6 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, pthread_mutex_init(&renderLock, &renderLockAttr); // recursive pthread_cond_init(&renderSignal, NULL); // no attribute - // no animations for add/remove/swap sublayers etc - [self removeAnimationForKey: kCAOnOrderIn]; - [self removeAnimationForKey: kCAOnOrderOut]; - [self removeAnimationForKey: kCATransition]; - pbuffer = p; [pbuffer retain]; @@ -161,7 +156,6 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, shallDraw = NO; CGRect lRect = [self frame]; - DBG_PRINT("MyNSOpenGLLayer::init %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, frame: %lf/%lf %lfx%lf (refcnt %d)\n", self, _ctx, _fmt, pbuffer, opaque, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m index b5979d53e..979e57aee 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m @@ -376,20 +376,20 @@ NSOpenGLPixelFormat* createPixelFormat(int* iattrs, int niattrs, int* ivalues) { // http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSOpenGLPixelFormat.html NSOpenGLPixelFormatAttribute attribs[256]; + DBG_PRINT("createPixelFormat.0: attrs %d: ", niattrs); int idx = 0; int i; for (i = 0; i < niattrs && iattrs[i]>0; i++) { int attr = iattrs[i]; + DBG_PRINT("%d: %d, ", attr, ivalues[i]); switch (attr) { - case NSOpenGLPFANoRecovery: - if (ivalues[i] != 0) { - attribs[idx++] = NSOpenGLPFANoRecovery; - } + case NSOpenGLPFAAccelerated: + // ignored - allow non accelerated profiles, or see NSOpenGLPFANoRecovery break; - case NSOpenGLPFAAccelerated: + case NSOpenGLPFANoRecovery: if (ivalues[i] != 0) { - attribs[idx++] = NSOpenGLPFAAccelerated; + attribs[idx++] = NSOpenGLPFANoRecovery; } break; @@ -445,10 +445,8 @@ NSOpenGLPixelFormat* createPixelFormat(int* iattrs, int niattrs, int* ivalues) { attribs[idx++] = 0; NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; - if (fmt == nil) { - // should we fallback to defaults or not? - fmt = [NSOpenGLView defaultPixelFormat]; - } + // if(fmt == nil) { fallback to a [NSOpenGLView defaultPixelFormat] crashed (SIGSEGV) on 10.6.7/NV } + DBG_PRINT("createPixelFormat.X: pfmt %p\n", fmt); [pool release]; return fmt; @@ -510,16 +508,19 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, Bool opaque, int* viewNotReady) { + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + getRendererInfo(); - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + DBG_PRINT("createContext.0: share %p, view %p, isBackingLayer %d, pixfmt %p, opaque %d\n", + share, view, (int)isBackingLayerView, fmt, opaque); if (view != NULL) { Bool viewReady = true; if(!isBackingLayerView) { if ([view lockFocusIfCanDraw] == NO) { - DBG_PRINT("createContext [view lockFocusIfCanDraw] failed\n"); + DBG_PRINT("createContext.1 [view lockFocusIfCanDraw] failed\n"); viewReady = false; } } @@ -529,7 +530,7 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, if(!isBackingLayerView) { [view unlockFocus]; } - DBG_PRINT("createContext view.frame size %dx%d\n", (int)frame.size.width, (int)frame.size.height); + DBG_PRINT("createContext.2 view.frame size %dx%d\n", (int)frame.size.width, (int)frame.size.height); viewReady = false; } } @@ -542,6 +543,7 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, } // the view is not ready yet + DBG_PRINT("createContext.X: view not ready yet\n"); [pool release]; return NULL; } @@ -562,6 +564,7 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, } } + DBG_PRINT("createContext.X: ctx: %p\n", ctx); [pool release]; return ctx; } |