diff options
author | Sven Gothel <[email protected]> | 2012-10-28 22:56:21 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-10-28 22:56:21 +0100 |
commit | 9b6448b1d54716fd455c0cad0c6133c0edeb3bb8 (patch) | |
tree | bd163d415d35f865e7f717dabe334a195caf067f /src/jogl/classes/jogamp | |
parent | 17d47c83bb976b6185b1562a2c332ecfef258c48 (diff) |
GLRendererQuirks: Add RequiresBoundVAO (w/ impl.), GLSLBuggyDiscard (todo) ; GLContextImpl: Bind default VAO if having quirk RequiresBoundVAO.
OSX w/ OpenGL >= 3 core context implementation requires a bound VAO for vertex attribute operations,
i.e. VertexAttributePointer(..). This has been experienced on OSX 10.7.5, OpenGL 3.2 core w/ Nvidia GPU
and in several forum posts. Such 'behavior' violates the GL 3.2 core specification,
which does not state this requirement, hence it is a bug. (Please correct me if I am wrong!)
GLContextImpl works around this quirk, by generating a default VAO and binds it at 1st makeCurrent (@creation)
and deletes it at destroy. This is minimal invasive since no action is required for subsequent makeCurrent or release.
We assume if a user uses and binds a VAO herself, she will mind this quirk.
Note: We could enhance this workaround by quering for a currently bound VAO at makeCurrent() and bind our default if none.
However, we refrain from this operation to minimize the workaround and complexity.
Diffstat (limited to 'src/jogl/classes/jogamp')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLContextImpl.java | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index d2e0bb407..48184119b 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -98,7 +98,8 @@ public abstract class GLContextImpl extends GLContext { private final GLStateTracker glStateTracker = new GLStateTracker(); private GLDebugMessageHandler glDebugHandler = null; private final int[] boundFBOTarget = new int[] { 0, 0 }; // { draw, read } - + private int defaultVAO = 0; + protected GLDrawableImpl drawable; protected GLDrawableImpl drawableRead; @@ -347,6 +348,12 @@ public abstract class GLContextImpl extends GLContext { } catch (Throwable t) { drawableContextRealizedException = t; } + if(0 != defaultVAO) { + int[] tmp = new int[] { defaultVAO }; + gl.getGL2GL3().glBindVertexArray(0); + gl.getGL2GL3().glDeleteVertexArrays(1, tmp, 0); + defaultVAO = 0; + } glDebugHandler.enable(false); if(lock.getHoldCount() > 1) { // pending release() after makeCurrent() @@ -563,6 +570,13 @@ public abstract class GLContextImpl extends GLContext { final boolean created; try { created = createImpl(shareWith); // may throws exception if fails! + if( created && glRendererQuirks.exist(GLRendererQuirks.RequiresBoundVAO) ) { + // Workaround: Create a default VAO to be used per default on makeCurrent + final int[] tmp = new int[1]; + gl.getGL2GL3().glGenVertexArrays(1, tmp, 0); + defaultVAO = tmp[0]; + gl.getGL2GL3().glBindVertexArray(defaultVAO); + } } finally { if (null != shareWith) { shareWith.getDrawableImpl().unlockSurface(); @@ -1292,11 +1306,18 @@ public abstract class GLContextImpl extends GLContext { // OS related quirks if( Platform.getOSType() == Platform.OSType.MACOS ) { - final int quirk = GLRendererQuirks.NoOffscreenBitmap; + final int quirk1 = GLRendererQuirks.NoOffscreenBitmap; if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()); + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk1)+": cause: OS "+Platform.getOSType()); + } + quirks[i++] = quirk1; + if( 3 <= ctxMajorVersion ) { + final int quirk2 = GLRendererQuirks.RequiresBoundVAO; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk2)+": cause: OS "+Platform.getOSType()); + } + quirks[i++] = quirk2; } - quirks[i++] = quirk; } else if( Platform.getOSType() == Platform.OSType.WINDOWS ) { final int quirk = GLRendererQuirks.NoDoubleBufferedBitmap; if(DEBUG) { |