diff options
Diffstat (limited to 'src/jogl')
16 files changed, 359 insertions, 153 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index 9c9129ae6..4a720a4f9 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -27,7 +27,9 @@ */ package com.jogamp.opengl; -import java.util.List; +import java.util.IdentityHashMap; + +import javax.media.nativewindow.AbstractGraphicsDevice; /** * GLRendererQuirks contains information of known bugs of various GL renderer. @@ -189,17 +191,80 @@ public class GLRendererQuirks { */ public static final int GLSLNonCompliant = 12; + /** + * GL4 context needs to be requested via GL3 + * <ul> + * <li>OSX >= 10.9.0 - kCGLOGLPVersion_GL4_Core may not produce hw-accel context. Bug 867 @ https://jogamp.org/bugzilla/.</li> + * </ul> + */ + public static final int GL4NeedsGL3Request = 13; + /** Number of quirks known. */ - public static final int COUNT = 13; + public static final int COUNT = 14; private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard", "GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display", "NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext", - "NoFullFBOSupport", "GLSLNonCompliant" + "NoFullFBOSupport", "GLSLNonCompliant", "GL4NeedsGL3Request" }; - private final int _bitmask; + private static final IdentityHashMap<String, GLRendererQuirks> stickyDeviceQuirks = new IdentityHashMap<String, GLRendererQuirks>(); + + /** + * Retrieval of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}. + * <p> + * Not thread safe. + * </p> + */ + public static GLRendererQuirks getStickyDeviceQuirks(AbstractGraphicsDevice device) { + final String key = device.getUniqueID(); + final GLRendererQuirks has = stickyDeviceQuirks.get(key); + final GLRendererQuirks res; + if( null == has ) { + res = new GLRendererQuirks(); + stickyDeviceQuirks.put(key, res); + } else { + res = has; + } + return res; + } + + /** + * {@link #addQuirks(int[], int, int) Adding given quirks} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}. + * <p> + * Not thread safe. + * </p> + */ + public static void addStickyDeviceQuirks(AbstractGraphicsDevice device, int[] quirks, int offset, int len) throws IllegalArgumentException { + final GLRendererQuirks sq = getStickyDeviceQuirks(device); + sq.addQuirks(quirks, offset, len); + } + /** + * {@link #exist(int) Query} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}. + * <p> + * Not thread safe. However, use after changing the sticky quirks is safe. + * </p> + */ + public static boolean existStickyDeviceQuirk(AbstractGraphicsDevice device, int quirk) { + return getStickyDeviceQuirks(device).exist(quirk); + } + /** + * {@link #addQuirks(GLRendererQuirks) Pushing} the sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks} + * to the given {@link GLRendererQuirks destination}. + * <p> + * Not thread safe. However, use after changing the sticky quirks is safe. + * </p> + */ + public static void pushStickyDeviceQuirks(AbstractGraphicsDevice device, GLRendererQuirks dest) { + dest.addQuirks(getStickyDeviceQuirks(device)); + } + + private int _bitmask; + + public GLRendererQuirks() { + _bitmask = 0; + } /** * @param quirks an array of valid quirks @@ -208,6 +273,17 @@ public class GLRendererQuirks { * @throws IllegalArgumentException if one of the quirks is out of range */ public GLRendererQuirks(int[] quirks, int offset, int len) throws IllegalArgumentException { + this(); + addQuirks(quirks, offset, len); + } + + /** + * @param quirks an array of valid quirks to be added + * @param offset offset in quirks array to start reading + * @param len number of quirks to read from offset within quirks array + * @throws IllegalArgumentException if one of the quirks is out of range + */ + public final void addQuirks(int[] quirks, int offset, int len) throws IllegalArgumentException { int bitmask = 0; if( !( 0 <= offset + len && offset + len < quirks.length ) ) { throw new IllegalArgumentException("offset and len out of bounds: offset "+offset+", len "+len+", array-len "+quirks.length); @@ -217,21 +293,14 @@ public class GLRendererQuirks { validateQuirk(quirk); bitmask |= 1 << quirk; } - _bitmask = bitmask; + _bitmask |= bitmask; } /** - * @param quirks a list of valid quirks - * @throws IllegalArgumentException if one of the quirks is out of range + * @param quirks valid GLRendererQuirks to be added */ - public GLRendererQuirks(List<Integer> quirks) throws IllegalArgumentException { - int bitmask = 0; - for(int i=0; i<quirks.size(); i++) { - final int quirk = quirks.get(i); - validateQuirk(quirk); - bitmask |= 1 << quirk; - } - _bitmask = bitmask; + public final void addQuirks(GLRendererQuirks quirks) { + _bitmask |= quirks._bitmask; } /** diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java index 1f715c21a..40f0d180f 100644 --- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java +++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java @@ -115,7 +115,7 @@ public class JoglVersion extends JogampVersion { if(null == device) { device = GLProfile.getDefaultDevice(); } - sb.append("Default Profiles on device ").append(device).append(Platform.getNewline()); + sb.append("GLProfiles on device ").append(device).append(Platform.getNewline()); if(null!=device) { GLProfile.glAvailabilityToString(device, sb, "\t", 1); } else { diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 9f2e96781..55050f25c 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -149,11 +149,11 @@ public abstract class GLContext { // Cached keys, bits [0..15] // - /** Context option bits, full bit mask covering bits [0..15], i.e. <code>0x0000FFFF</code>, {@value}. */ + /** Context option bits, full bit mask covering 16 bits [0..15], i.e. <code>0x0000FFFF</code>, {@value}. */ protected static final int CTX_IMPL_FULL_MASK = 0x0000FFFF; - /** Context option bits, cached bit mask covering 9 bits [0..8], i.e. <code>0x000001FF</code>, {@value}. Leaving 7 bits for non cached options, i.e. 9:7. */ - protected static final int CTX_IMPL_CACHE_MASK = 0x000001FF; + /** Context option bits, cached bit mask covering 10 bits [0..9], i.e. <code>0x000003FF</code>, {@value}. Leaving 6 bits for non cached options, i.e. 10:6. */ + protected static final int CTX_IMPL_CACHE_MASK = 0x000003FF; /** <code>ARB_create_context</code> related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IS_ARB_CREATED = 1 << 0; @@ -171,14 +171,14 @@ public abstract class GLContext { protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 6; // - // Non cached keys, bits [9..15] + // Non cached keys, 6 bits [10..15] // /** <code>GL_ARB_ES2_compatibility</code> implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ - protected static final int CTX_IMPL_ES2_COMPAT = 1 << 9; + protected static final int CTX_IMPL_ES2_COMPAT = 1 << 10; /** <code>GL_ARB_ES3_compatibility</code> implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES3Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ - protected static final int CTX_IMPL_ES3_COMPAT = 1 << 10; + protected static final int CTX_IMPL_ES3_COMPAT = 1 << 11; /** * Context supports basic FBO, details see {@link #hasBasicFBOSupport()}. @@ -186,7 +186,7 @@ public abstract class GLContext { * @see #hasBasicFBOSupport() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) */ - protected static final int CTX_IMPL_FBO = 1 << 11; + protected static final int CTX_IMPL_FBO = 1 << 12; /** * Context supports <code>OES_single_precision</code>, fp32, fixed function point (FFP) compatibility entry points, @@ -195,7 +195,7 @@ public abstract class GLContext { * @see #hasFP32CompatAPI() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) */ - protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 12; + protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 13; private static final ThreadLocal<GLContext> currentContext = new ThreadLocal<GLContext>(); @@ -1668,7 +1668,8 @@ public abstract class GLContext { if(major >= 4) { return GLProfile.GL4; } else if(major == 3 && minor >= 1) { return GLProfile.GL3; } } else if(0 != ( CTX_PROFILE_ES & ctp )) { - if(major == 2) { return GLProfile.GLES2; } + if(major == 3) { return GLProfile.GLES3; } + else if(major == 2) { return GLProfile.GLES2; } else if(major == 1) { return GLProfile.GLES1; } } throw new GLException("Unhandled OpenGL version/profile: "+GLContext.getGLVersion(major, minor, ctp, null)); @@ -1719,15 +1720,27 @@ public abstract class GLContext { * @param device the device the profile is being requested * @param major Key Value either 1, 2, 3 or 4 * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} - * @return the highest GLProfile regarding availability, version and profile bits. + * @return the highest GLProfile for the device regarding availability, version and profile bits. */ protected static GLProfile getAvailableGLProfile(AbstractGraphicsDevice device, int reqMajor, int reqProfile) throws GLException { + final String glpName = getAvailableGLProfileName(device, reqMajor, reqProfile); + return null != glpName ? GLProfile.get(device, glpName) : null; + } + + /** + * @param device the device the profile is being requested + * @param major Key Value either 1, 2, 3 or 4 + * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} + * @return the highest GLProfile name for the device regarding availability, version and profile bits. + */ + /* package */ static String getAvailableGLProfileName(AbstractGraphicsDevice device, int reqMajor, int reqProfile) + throws GLException { int major[] = { 0 }; int minor[] = { 0 }; int ctp[] = { 0 }; if(GLContext.getAvailableGLVersion(device, reqMajor, reqProfile, major, minor, ctp)) { - return GLProfile.get(GLContext.getGLProfile(major[0], minor[0], ctp[0])); + return GLContext.getGLProfile(major[0], minor[0], ctp[0]); } return null; } @@ -1870,7 +1883,7 @@ public abstract class GLContext { needColon = appendString(sb, "ES2 compat", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp )); needColon = appendString(sb, "ES3 compat", needColon, 0 != ( CTX_IMPL_ES3_COMPAT & ctp )); needColon = appendString(sb, "FBO", needColon, 0 != ( CTX_IMPL_FBO & ctp )); - needColon = appendString(sb, "FP32 compat-api", needColon, 0 != ( CTX_IMPL_FP32_COMPAT_API & ctp )); + needColon = appendString(sb, "FP32 compat", needColon, 0 != ( CTX_IMPL_FP32_COMPAT_API & ctp )); if( 0 != ( CTX_IMPL_ACCEL_SOFT & ctp ) ) { needColon = appendString(sb, "software", needColon, true); } else { diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 35dcce0f7..c04971176 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -61,8 +61,8 @@ import javax.media.opengl.fixedfunc.GLPointerFunc; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; -import java.util.Iterator; import java.util.List; +import java.util.Map; /** * Specifies the the OpenGL profile. @@ -267,138 +267,182 @@ public class GLProfile { initSingleton(); + int allCount = 0; + int nativeCount = 0; + if(null==device) { device = defaultDevice; } final HashMap<String /*GLProfile_name*/, GLProfile> map = getProfileMap(device, false); if(useIndent) { - doIndent(sb, indent, indentCount).append("Native"); + doIndent(sb, indent, indentCount).append("Natives"); indentCount++; - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4bc").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4bc).append(indent); } else { - sb.append("Native[GL4bc "); + sb.append("Natives["+GL4bc+" "); } avail=isAvailableImpl(map, GL4bc); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_COMPAT); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4).append(indent); } else { - sb.append(", GL4 "); + sb.append(", "+GL4+" "); } avail=isAvailableImpl(map, GL4); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_CORE); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES3").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES3).append(indent); } else { - sb.append(", GLES3 "); + sb.append(", "+GLES3+" "); } avail=isAvailableImpl(map, GLES3); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_ES); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3bc").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3bc).append(indent); } else { - sb.append(", GL3bc "); + sb.append(", "+GL3bc+" "); } avail=isAvailableImpl(map, GL3bc); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_COMPAT); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3).append(indent); } else { - sb.append(", GL3 "); + sb.append(", "+GL3+" "); } avail=isAvailableImpl(map, GL3); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_CORE); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2).append(indent); } else { - sb.append(", GL2 "); + sb.append(", "+GL2+" "); } avail=isAvailableImpl(map, GL2); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_COMPAT); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES2).append(indent); } else { - sb.append(", GLES2 "); + sb.append(", "+GLES2+" "); } avail=isAvailableImpl(map, GLES2); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES1).append(indent); } else { - sb.append(", GLES1 "); + sb.append(", "+GLES1+" "); } avail=isAvailableImpl(map, GLES1); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES); } + allCount++; + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Count\t"+nativeCount+" / "+allCount); + indentCount--; + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Common"); + indentCount++; + } else { + sb.append(", count "+nativeCount+" / "+allCount+"], Common["); + } if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4ES3").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4ES3).append(indent); } else { - sb.append(", GL4ES3 "); + sb.append(", "+GL4ES3+" "); } sb.append(isAvailableImpl(map, GL4ES3)); + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2GL3).append(indent); } else { - sb.append(", GL2ES2 "); + sb.append(", "+GL2GL3+" "); + } + sb.append(isAvailableImpl(map, GL2GL3)); + allCount++; + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES2).append(indent); + } else { + sb.append(", "+GL2ES2+" "); } sb.append(isAvailableImpl(map, GL2ES2)); + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES1).append(indent); } else { - sb.append(", GL2ES1 "); + sb.append(", "+GL2ES1+" "); } sb.append(isAvailableImpl(map, GL2ES1)); + allCount++; if(useIndent) { indentCount--; - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Profiles"); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Mappings"); indentCount++; } else { - sb.append("], Profiles["); + sb.append("], Mappings["); } + int profileCount = 0; + if(null != map) { - for(Iterator<GLProfile> i=map.values().iterator(); i.hasNext(); ) { - if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount); - } - sb.append(i.next().toString()); - if(!useIndent) { - sb.append(", "); + for (Map.Entry<String,GLProfile> entry : map.entrySet()) { + if( !GL_DEFAULT.equals(entry.getKey()) ) { + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount); + } + sb.append(entry.getKey()+(useIndent?"\t":" ")+entry.getValue()); + if(!useIndent) { + sb.append(", "); + } + profileCount++; } } if(useIndent) { @@ -413,9 +457,10 @@ public class GLProfile { } } if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Count\t"+profileCount+" / "+allCount); sb.append(Platform.getNewline()); } else { - sb.append("]"); + sb.append(", count "+profileCount+" / "+allCount+"]"); } return sb; @@ -1979,21 +2024,21 @@ public class GLProfile { } } } else if(GL4bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4bcAvailable(device, isHardwareRasterizer))) { - return GL4bc; + return desktopCtxUndef ? GL4bc : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_COMPAT); } else if(GL4.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4Available(device, isHardwareRasterizer))) { - return GL4; + return desktopCtxUndef ? GL4 : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_CORE); } else if(GL3bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer))) { - return GL3bc; + return desktopCtxUndef ? GL3bc : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_COMPAT); } else if(GL3.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3Available(device, isHardwareRasterizer))) { - return GL3; + return desktopCtxUndef ? GL3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_CORE); } else if(GL2.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) { - return GL2; + return desktopCtxUndef ? GL2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_COMPAT); } else if(GLES3.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) { - return GLES3; + return esCtxUndef ? GLES3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_ES); } else if(GLES2.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) { - return GLES2; + return esCtxUndef ? GLES2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_ES); } else if(GLES1.equals(profile) && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) { - return GLES1; + return esCtxUndef ? GLES1 : GLContext.getAvailableGLProfileName(device, 1, GLContext.CTX_PROFILE_ES); } return null; } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 911a4c2be..8542a799a 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -826,8 +826,11 @@ public abstract class GLContextImpl extends GLContext { final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); final int[] reqMajorCTP = new int[] { 0, 0 }; - getRequestMajorAndCompat(glCaps.getGLProfile(), reqMajorCTP); + GLContext.getRequestMajorAndCompat(glCaps.getGLProfile(), reqMajorCTP); + if(DEBUG) { + System.err.println(getThreadName() + ": createContextARB: Requested "+GLContext.getGLVersion(reqMajorCTP[0], 0, reqMajorCTP[0], null)); + } int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; @@ -835,9 +838,12 @@ public abstract class GLContextImpl extends GLContext { if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], _major, _minor, _ctp)) { _ctp[0] |= additionalCtxCreationFlags; + if(DEBUG) { + System.err.println(getThreadName() + ": createContextARB: Mapped "+GLContext.getGLVersion(_major[0], _minor[0], _ctp[0], null)); + } _ctx = createContextARBImpl(share, direct, _ctp[0], _major[0], _minor[0]); if(0!=_ctx) { - setGLFunctionAvailability(true, _major[0], _minor[0], _ctp[0], false); + setGLFunctionAvailability(true, _major[0], _minor[0], _ctp[0], false /* strictMatch */, false /* withinGLVersionsMapping */); } } return _ctx; @@ -857,67 +863,95 @@ public abstract class GLContextImpl extends GLContext { // Even w/ PROFILE_ALIASING, try to use true core GL profiles // ensuring proper user behavior across platforms due to different feature sets! // - if(!hasGL4) { + if( Platform.OSType.MACOS == Platform.getOSType() && + Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Mavericks) >= 0 ) { + /** + * OSX 10.9 GLRendererQuirks.GL4NeedsGL3Request, quirk is added as usual @ setRendererQuirks(..) + */ + if( !hasGL4 && !hasGL3 ) { + hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 + success |= hasGL3; + if( hasGL3 ) { + final boolean isHWAccel = 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ); + if( isHWAccel && ctxVersion.getMajor() >= 4 ) { + // Gotcha: Creating a '3.2' ctx delivers a >= 4 ctx. + GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + hasGL4 = true; + if(DEBUG) { + System.err.println("Quirk Triggerd: "+GLRendererQuirks.toString(GLRendererQuirks.GL4NeedsGL3Request)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()); + } + } + resetStates(false); // clean this context states, since creation was temporary + } + } + } + if( !hasGL4 ) { hasGL4 = createContextARBMapVersionsAvailable(4, CTX_PROFILE_CORE); // GL4 success |= hasGL4; - if(hasGL4) { - // Map all lower compatible profiles: GL3 - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - if(PROFILE_ALIASING) { - hasGL3 = true; + if( hasGL4 ) { + if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ) ) { + // Map hw-accel GL4 to all lower core profiles: GL3 + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + if( PROFILE_ALIASING ) { + hasGL3 = true; + } } resetStates(false); // clean context states, since creation was temporary } } - if(!hasGL3) { + if( !hasGL3 ) { hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 success |= hasGL3; - if(hasGL3) { + if( hasGL3 ) { resetStates(false); // clean this context states, since creation was temporary } } - if(!hasGL4bc) { + if( !hasGL4bc ) { hasGL4bc = createContextARBMapVersionsAvailable(4, CTX_PROFILE_COMPAT); // GL4bc success |= hasGL4bc; - if(hasGL4bc) { - // Map all lower compatible profiles: GL3bc, GL2, GL4, GL3 - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - if(!hasGL4) { + if( hasGL4bc ) { + if( !hasGL4 ) { // last chance .. ignore hw-accel GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + hasGL4 = true; } - if(!hasGL3) { + if( !hasGL3 ) { // last chance .. ignore hw-accel GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - } - if(PROFILE_ALIASING) { - hasGL3bc = true; - hasGL2 = true; - hasGL4 = true; hasGL3 = true; } + if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ) ) { + // Map hw-accel GL4bc to all lower compatible profiles: GL3bc, GL2 + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + if(PROFILE_ALIASING) { + hasGL3bc = true; + hasGL2 = true; + } + } resetStates(false); // clean this context states, since creation was temporary } } - if(!hasGL3bc) { + if( !hasGL3bc ) { hasGL3bc = createContextARBMapVersionsAvailable(3, CTX_PROFILE_COMPAT); // GL3bc success |= hasGL3bc; - if(hasGL3bc) { - // Map all lower compatible profiles: GL2 and GL3 - GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - if(!hasGL3) { + if( hasGL3bc ) { + if(!hasGL3) { // last chance .. ignore hw-accel GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - } - if(PROFILE_ALIASING) { - hasGL2 = true; hasGL3 = true; } + if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ) ) { + // Map hw-accel GL3bc to all lower compatible profiles: GL2 + GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + if(PROFILE_ALIASING) { + hasGL2 = true; + } + } resetStates(false); // clean this context states, since creation was temporary } } - if(!hasGL2) { + if( !hasGL2 ) { hasGL2 = createContextARBMapVersionsAvailable(2, CTX_PROFILE_COMPAT); // GL2 success |= hasGL2; - if(hasGL2) { + if( hasGL2 ) { resetStates(false); // clean this context states, since creation was temporary } } @@ -1022,7 +1056,7 @@ public abstract class GLContextImpl extends GLContext { _context = createContextARBImpl(share, direct, ctxOptionFlags, major[0], minor[0]); if(0 != _context) { - if( setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true) ) { + if( setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true /* strictMatch */, true /* withinGLVersionsMapping */) ) { break; } else { destroyContextARBImpl(_context); @@ -1291,14 +1325,15 @@ public abstract class GLContextImpl extends GLContext { * * @param force force the setting, even if is already being set. * This might be useful if you change the OpenGL implementation. - * @param major OpenGL major version - * @param minor OpenGL minor version - * @param ctxProfileBits OpenGL context profile and option bits, see {@link javax.media.opengl.GLContext#CTX_OPTION_ANY} - * @param strictMatch if <code>true</code> the ctx must + * @param major OpenGL major version + * @param minor OpenGL minor version + * @param ctxProfileBits OpenGL context profile and option bits, see {@link javax.media.opengl.GLContext#CTX_OPTION_ANY} + * @param strictMatch if <code>true</code> the ctx must * <ul> * <li>be greater or equal than the requested <code>major.minor</code> version, and</li> * <li>match the ctxProfileBits</li> * </ul>, otherwise method aborts and returns <code>false</code>. + * @param withinGLVersionsMapping TODO * @return returns <code>true</code> if successful, otherwise <code>false</code>. See <code>strictMatch</code>. * If <code>false</code> is returned, no data has been cached or mapped, i.e. ProcAddressTable, Extensions, Version, etc. * @see #setContextVersion @@ -1306,7 +1341,8 @@ public abstract class GLContextImpl extends GLContext { * @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT * @see javax.media.opengl.GLContext#CTX_IMPL_ES2_COMPAT */ - protected final boolean setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits, boolean strictMatch) { + protected final boolean setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits, + boolean strictMatch, boolean withinGLVersionsMapping) { if(null!=this.gl && null!=glProcAddressTable && !force) { return true; // already done and not forced } @@ -1322,7 +1358,7 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - + final int reqMajor = major, reqMinor = minor, reqCtxProfileBits = ctxProfileBits; { final boolean initGLRendererAndGLVersionStringsOK = initGLRendererAndGLVersionStrings(); if( !initGLRendererAndGLVersionStringsOK ) { @@ -1424,7 +1460,10 @@ public abstract class GLContextImpl extends GLContext { return false; } if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Post version verification "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Post version verification req "+ + GLContext.getGLVersion(reqMajor, reqMinor, reqCtxProfileBits, null)+" -> has "+ + GLContext.getGLVersion(major, minor, ctxProfileBits, null)+ + ", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed); } if( major < 2 ) { // there is no ES2/3-compat for a profile w/ major < 2 @@ -1433,7 +1472,7 @@ public abstract class GLContextImpl extends GLContext { final VersionNumberString vendorVersion = GLVersionNumber.createVendorVersion(glVersion); - setRendererQuirks(adevice, major, minor, ctxProfileBits, vendorVersion); + setRendererQuirks(adevice, reqMajor, reqMinor, reqCtxProfileBits, major, minor, ctxProfileBits, vendorVersion, withinGLVersionsMapping); if( strictMatch && glRendererQuirks.exist(GLRendererQuirks.GLNonCompliant) ) { if(DEBUG) { @@ -1550,7 +1589,10 @@ public abstract class GLContextImpl extends GLContext { return true; } - private final void setRendererQuirks(final AbstractGraphicsDevice adevice, int major, int minor, int ctp, final VersionNumberString vendorVersion) { + private final void setRendererQuirks(final AbstractGraphicsDevice adevice, + int reqMajor, int reqMinor, int reqCTP, + int major, int minor, int ctp, final VersionNumberString vendorVersion, + boolean withinGLVersionsMapping) { int[] quirks = new int[GLRendererQuirks.COUNT + 1]; // + 1 ( NoFullFBOSupport ) int i = 0; @@ -1577,7 +1619,17 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - + if( Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Mavericks) >= 0 && 3==reqMajor && 4==major ) { + final int quirk = GLRendererQuirks.GL4NeedsGL3Request; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", req "+reqMajor+"."+reqMinor); + } + quirks[i++] = quirk; + if( withinGLVersionsMapping ) { + // Thread safe due to single threaded initialization! + GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1); + } + } if( isDriverNVIDIAGeForce ) { final VersionNumber osxVersionNVFlushClean = new VersionNumber(10,7,3); // < OSX 10.7.3 w/ NV needs glFlush if( Platform.getOSVersionNumber().compareTo(osxVersionNVFlushClean) < 0 ) { @@ -1587,8 +1639,7 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - final VersionNumber osxVersionNVGLSLGood = new VersionNumber(10,7,0); // < OSX 10.7.0 w/ NV has instable GLSL - if( Platform.getOSVersionNumber().compareTo(osxVersionNVGLSLGood) < 0 ) { + if( Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Lion) < 0 ) { // < OSX 10.7.0 w/ NV has unstable GLSL final int quirk = GLRendererQuirks.GLSLNonCompliant; if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer); @@ -1732,6 +1783,11 @@ public abstract class GLContextImpl extends GLContext { } glRendererQuirks = new GLRendererQuirks(quirks, 0, i); + GLRendererQuirks.pushStickyDeviceQuirks(adevice, glRendererQuirks); // Thread safe due to single threaded initialization! + if(DEBUG) { + System.err.println("Quirks local: "+glRendererQuirks); + System.err.println("Quirks sticky on "+adevice+": "+GLRendererQuirks.getStickyDeviceQuirks(adevice)); + } } private static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) { @@ -1785,7 +1841,7 @@ public abstract class GLContextImpl extends GLContext { if(!drawable.getChosenGLCapabilities().getHardwareAccelerated()) { isHardwareRasterizer = false; } else { - isHardwareRasterizer = ! ( glRendererLowerCase.contains("software") /* Mesa3D */ || + isHardwareRasterizer = ! ( glRendererLowerCase.contains("software") /* Mesa3D, Apple */ || glRendererLowerCase.contains("mesa x11") /* Mesa3D */ || glRendererLowerCase.contains("softpipe") /* Gallium */ || glRendererLowerCase.contains("llvmpipe") /* Gallium */ diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 3de910369..d8bb2e9eb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -222,7 +222,9 @@ public class EGLContext extends GLContextImpl { throw new GLException("Error making context " + toHexString(contextHandle) + " current: error code " + toHexString(EGL.eglGetError())); } - return setGLFunctionAvailability(true, contextVersionReq, 0, CTX_PROFILE_ES, contextVersionReq>=3); // strict match for es >= 3 + return setGLFunctionAvailability(true, contextVersionReq, 0, CTX_PROFILE_ES, + contextVersionReq>=3 /* strictMatch */, // strict match for es >= 3 + false /* withinGLVersionsMapping */); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java index 4685e8bf1..d54a80ae3 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java @@ -45,7 +45,7 @@ public class EGLExternalContext extends EGLContext { public EGLExternalContext(AbstractGraphicsScreen screen) { super(null, null); GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_ES, false); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_ES, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 31fa14fbb..54510b51a 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -416,7 +416,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(aCap.getVisualID(VIDType.NATIVE) != nativeVisualID) { if(DEBUG) { System.err.println("Remove["+i+"] (mismatch VisualID): "+aCap); } removedCaps.add(availableCaps.remove(i)); - } if( 0 == aCap.getDepthBits() && 0 < capsChosen.getDepthBits() ) { + } else if( 0 == aCap.getDepthBits() && 0 < capsChosen.getDepthBits() ) { // Hack for HiSilicon/Vivante/Immersion.16 Renderer .. if(DEBUG) { System.err.println("Remove["+i+"] (mismatch depth-bits): "+aCap); } removedCaps.add(availableCaps.remove(i)); 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: diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index d23d8a7e1..a2cf334ce 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -63,7 +63,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { setOpenGLMode(isNSContext ? GLBackendType.NSOPENGL : GLBackendType.CGL ); this.contextHandle = handle; GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java index 966a8b28a..95d7d8b82 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java @@ -64,7 +64,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { System.err.println(getThreadName() + ": Created external OpenGL context " + toHexString(ctx) + " for " + this); } GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index d936308af..82be3e2b9 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -325,7 +325,7 @@ public class WindowsWGLContext extends GLContextImpl { if ( !WGL.wglMakeCurrent(drawable.getHandle(), temp_ctx) ) { throw new GLException("Error making temp context current: 0x" + toHexString(temp_ctx) + ", werr: "+GDI.GetLastError()); } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION + setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION WGL.wglMakeCurrent(0, 0); // release temp context if( !createContextARBTried ) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index ba88ff3c4..a04d1989d 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -63,7 +63,7 @@ public class X11ExternalGLXContext extends X11GLXContext { super(drawable, null); this.contextHandle = ctx; GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 22a48e093..42bb6b964 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -320,7 +320,7 @@ public class X11GLXContext extends GLContextImpl { if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) { throw new GLException(getThreadName()+": Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION + setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION isDirect = GLX.glXIsDirect(display, contextHandle); if (DEBUG) { System.err.println(getThreadName() + ": createContextImpl: OK (old-1) share "+share+", direct "+isDirect+"/"+direct); @@ -350,7 +350,7 @@ public class X11GLXContext extends GLContextImpl { if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx) ) { throw new GLException(getThreadName()+": Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable); } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION + setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION glXMakeContextCurrent(display, 0, 0, 0); // release temp context if( !createContextARBTried ) { // is*Available calls are valid since setGLFunctionAvailability(..) was called diff --git a/src/jogl/native/macosx/MacOSXCustomCGLCode.c b/src/jogl/native/macosx/MacOSXCustomCGLCode.c index f8b7a800f..75896c3a2 100644 --- a/src/jogl/native/macosx/MacOSXCustomCGLCode.c +++ b/src/jogl/native/macosx/MacOSXCustomCGLCode.c @@ -2,7 +2,7 @@ #include <assert.h> -#include </usr/include/machine/types.h> +#include <machine/types.h> #include "macosx-window-system.h" void CGLQueryPixelFormat(CGLPixelFormatObj fmt, int* iattrs, int niattrs, int* ivalues) { |