summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-24 23:42:01 +0200
committerSven Gothel <[email protected]>2013-10-24 23:42:01 +0200
commit38025a602750161c72a50ad7a25e97fb7a6cb6df (patch)
tree829695e234e47a8fea6d711be792072a7f48ed79 /src/jogl/classes/com/jogamp
parent3647f6ad5ee3bc490a5647aee2de8d02119dd46c (diff)
Bug 867 - OSX 10.9: Recognize OpenGL Core Profile > 3.0 - Add GLRendererQuirks: Quirk GL4NeedsGL3Request and 'sticky device quirks'
The 'sticky device quirks' are required to share quirks among devices as collected while mapping the GL versions (audit). Those are context independent and may only be detected for certain contexts. They can be pushed/added to the context's quirks, but also queried at context creation (after mapping) - before the local quirks are being created.
Diffstat (limited to 'src/jogl/classes/com/jogamp')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java99
1 files changed, 84 insertions, 15 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;
}
/**