diff options
author | Sven Gothel <[email protected]> | 2013-10-24 23:48:55 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-24 23:48:55 +0200 |
commit | cbc641e89136098e0a9e79afe74b45203f828587 (patch) | |
tree | 5ed676b6f2b69e353773d60ff73499ed042adc83 /src/jogl/classes/jogamp | |
parent | 970c9823007d1618e67480440ff40e7802dbb90f (diff) |
Bug 867 - OSX: Allow core >=4 if isMavericksOrLater; Use [kCGLOGLPVersion_GL4_Core, kCGLOGLPVersion_GL3_Core] for major==4 depending on sticky GLRendererQuirks.GL4NeedsGL3Request
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 57 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java | 18 |
2 files changed, 48 insertions, 27 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 03aae3f78..037aaca08 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -98,11 +98,13 @@ public class MacOSXCGLContext extends GLContextImpl /* package */ static final boolean isTigerOrLater; /* package */ static final boolean isLionOrLater; + /* package */ static final boolean isMavericksOrLater; static { final VersionNumber osvn = Platform.getOSVersionNumber(); - isTigerOrLater = osvn.getMajor() > 10 || ( osvn.getMajor() == 10 && osvn.getMinor() >= 4 ); - isLionOrLater = osvn.getMajor() > 10 || ( osvn.getMajor() == 10 && osvn.getMinor() >= 7 ); + isTigerOrLater = osvn.compareTo(Platform.OSXVersion.Tiger) >= 0; + isLionOrLater = osvn.compareTo(Platform.OSXVersion.Lion) >= 0; + isMavericksOrLater = osvn.compareTo(Platform.OSXVersion.Mavericks) >= 0; } static boolean isGLProfileSupported(int ctp, int major, int minor) { @@ -110,30 +112,45 @@ public class MacOSXCGLContext extends GLContextImpl boolean ctCore = 0 != ( CTX_PROFILE_CORE & ctp ) ; // We exclude 3.0, since we would map it's core to GL2. Hence we force mapping 2.1 to GL2 - if(3==major && 1<=minor && minor<=2) { - // [3.1..3.2] -> GL3* + if( 3 < major || 3 == major && 1 <= minor ) { + if(ctBwdCompat || !ctCore) { + // No compatibility profile on OS X + // Only core is supported + return false; + } if(!isLionOrLater) { - // no GL3* on pre lion + // no GL Profile >= GL3 core on pre lion return false; } - if(ctBwdCompat) { - // no compatibility profile on OS X + if(3 < major && !isMavericksOrLater) { + // no GL Profile >= GL4 core on pre mavericks return false; } - return ctCore; - } else if(major<3) { + // [3.1..3.x] -> GL3 + // [4.0..4.x] -> GL4 + return true; + } else if( major < 3 ) { // < 3.0 -> GL2 return true; } return false; // 3.0 && > 3.2 } - static int GLProfile2CGLOGLProfileValue(int ctp, int major, int minor) { + static int GLProfile2CGLOGLProfileValue(AbstractGraphicsDevice device, int ctp, int major, int minor) { if(!MacOSXCGLContext.isGLProfileSupported(ctp, major, minor)) { throw new GLException("OpenGL profile not supported: "+getGLVersion(major, minor, ctp, "@GLProfile2CGLOGLProfileVersion")); } - boolean ctCore = 0 != ( CTX_PROFILE_CORE & ctp ) ; - if( major == 3 && minor >= 1 && ctCore ) { - return CGL.kCGLOGLPVersion_3_2_Core; + final boolean ctCore = 0 != ( CTX_PROFILE_CORE & ctp ) ; + + if( major == 4 && ctCore ) { + if( GLRendererQuirks.existStickyDeviceQuirk(device, GLRendererQuirks.GL4NeedsGL3Request) ) { + // Thread safe GLRendererQuirks sticky access, since we are only interested of the result _after_ GL version mapping, + // i.e. after single threaded initialization! + return CGL.kCGLOGLPVersion_GL3_Core; + } else { + return CGL.kCGLOGLPVersion_GL4_Core; + } + } else if( major == 3 && minor >= 1 && ctCore ) { + return CGL.kCGLOGLPVersion_GL3_Core; } else { return CGL.kCGLOGLPVersion_Legacy; } @@ -283,7 +300,8 @@ public class MacOSXCGLContext extends GLContextImpl MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); GLCapabilitiesImmutable capabilitiesChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); GLProfile glp = capabilitiesChosen.getGLProfile(); - if(glp.isGLES1() || glp.isGLES2() || glp.isGL4() || glp.isGL3() && !isLionOrLater) { + if( glp.isGLES1() || glp.isGLES2() || glp.isGLES3() || + ( glp.isGL3() && !isLionOrLater ) || ( glp.isGL4() && !isMavericksOrLater ) ) { throw new GLException("OpenGL profile not supported on MacOSX "+Platform.getOSVersionNumber()+": "+glp); } @@ -589,7 +607,7 @@ public class MacOSXCGLContext extends GLContextImpl } else { targetCaps = chosenCaps; } - pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(targetCaps, ctp, major, minor); + pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(config.getScreen().getDevice(), targetCaps, ctp, major, minor); } if (pixelFormat == 0) { if(DEBUG) { @@ -617,7 +635,7 @@ public class MacOSXCGLContext extends GLContextImpl screenVSyncTimeout = 1000000 / sRefreshRate; } if(DEBUG) { - System.err.println("NS create OSX>=lion "+isLionOrLater); + System.err.println("NS create OSX>=lion "+isLionOrLater+", OSX>=mavericks "+isMavericksOrLater); System.err.println("NS create incompleteView: "+incompleteView); System.err.println("NS create backingLayerHost: "+backingLayerHost); System.err.println("NS create share: "+share); @@ -1117,9 +1135,10 @@ public class MacOSXCGLContext extends GLContextImpl @Override public long create(long share, int ctp, int major, int minor) { long ctx = 0; - MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); - GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); - long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2CGLPixelFormat(chosenCaps, ctp, major, minor); + final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); + final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); + final long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2CGLPixelFormat(config.getScreen().getDevice(), + chosenCaps, ctp, major, minor); if (pixelFormat == 0) { throw new GLException("Unable to allocate pixel format with requested GLCapabilities"); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index 13e249a58..481c0b94b 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -47,7 +47,6 @@ import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; - import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.nativewindow.MutableGraphicsConfiguration; @@ -89,7 +88,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration CGL.NSOpenGLPFASampleBuffers, CGL.NSOpenGLPFASamples }); - static IntBuffer GLCapabilities2NSAttribList(IntBuffer attrToken, GLCapabilitiesImmutable caps, int ctp, int major, int minor) { + static IntBuffer GLCapabilities2NSAttribList(AbstractGraphicsDevice device, IntBuffer attrToken, GLCapabilitiesImmutable caps, int ctp, int major, int minor) { final int len = attrToken.remaining(); final int off = attrToken.position(); final IntBuffer ivalues = Buffers.newDirectIntBuffer(len); @@ -98,7 +97,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration final int attr = attrToken.get(idx+off); switch (attr) { case CGL.kCGLPFAOpenGLProfile: - ivalues.put(idx, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor)); + ivalues.put(idx, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(device, ctp, major, minor)); break; case CGL.NSOpenGLPFANoRecovery: ivalues.put(idx, caps.getHardwareAccelerated() ? 1 : 0); @@ -156,13 +155,13 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration return ivalues; } - static long GLCapabilities2NSPixelFormat(GLCapabilitiesImmutable caps, int ctp, int major, int minor) { + static long GLCapabilities2NSPixelFormat(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, int ctp, int major, int minor) { final IntBuffer attrToken = cglInternalAttributeToken.duplicate(); if ( !MacOSXCGLContext.isLionOrLater ) { // no OpenGLProfile attrToken.position(1); } - final IntBuffer ivalues = GLCapabilities2NSAttribList(attrToken, caps, ctp, major, minor); + final IntBuffer ivalues = GLCapabilities2NSAttribList(device, attrToken, caps, ctp, major, minor); return CGL.createPixelFormat(attrToken, attrToken.remaining(), ivalues); } @@ -170,13 +169,13 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration return PixelFormat2GLCapabilities(glp, pixelFormat, true); } - static long GLCapabilities2CGLPixelFormat(GLCapabilitiesImmutable caps, int ctp, int major, int minor) { + static long GLCapabilities2CGLPixelFormat(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, int ctp, int major, int minor) { // Set up pixel format attributes final IntBuffer attrs = Buffers.newDirectIntBuffer(256); int i = 0; if(MacOSXCGLContext.isLionOrLater) { attrs.put(i++, CGL.kCGLPFAOpenGLProfile); - attrs.put(i++, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor)); + attrs.put(i++, MacOSXCGLContext.GLProfile2CGLOGLProfileValue(device, ctp, major, minor)); } /** if(!caps.isOnscreen() && caps.isPBuffer()) { @@ -261,7 +260,10 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration final int ivalue = ivalues.get(i); if(CGL.kCGLPFAOpenGLProfile == attrToken.get(i+off)) { switch(ivalue) { - case CGL.kCGLOGLPVersion_3_2_Core: + case CGL.kCGLOGLPVersion_GL4_Core: + glp = GLProfile.get(GLProfile.GL4); + break; + case CGL.kCGLOGLPVersion_GL3_Core: glp = GLProfile.get(GLProfile.GL3); break; case CGL.kCGLOGLPVersion_Legacy: |