summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-01-13 00:11:56 +0100
committerSven Gothel <[email protected]>2012-01-13 00:11:56 +0100
commit835b36d626f75f9e96001a41c2a6fe9f90466ae1 (patch)
tree0dfc90f72e7c16dd67d5c9526f2cb8b501411699 /src
parent1a79d4f87d750b3146b80bd861230022e66108d6 (diff)
OSX Fixes: bug 548 (another regression: pixelfmt), ctx creation failure -> no exception,
- bug 548: Another regression: pixelfmt failed for 10.6.7 and/or software OpenGL - enforcing accelerated leads to no pixelformat, - using the NSOpenGLView defaultPixelFormat causes to SIGSEGV - ctx creation failure shall just lead to return null, no immediate exception
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java8
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java4
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java1
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java25
-rw-r--r--src/jogl/native/macosx/MacOSXWindowSystemInterface.m29
5 files changed, 36 insertions, 31 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java
index 0dd1a460e..0ba7a99cd 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);
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..e1810fd63 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);
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.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;
}