diff options
-rwxr-xr-x | make/scripts/tests.sh | 6 | ||||
-rw-r--r-- | src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java | 18 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLContextImpl.java | 115 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java (renamed from src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java) | 16 | ||||
-rw-r--r-- | src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug658NEWT.java | 200 |
5 files changed, 310 insertions, 45 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d4ce3c3e1..9f168cbe5 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -97,6 +97,7 @@ function jrun() { #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" + #D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" @@ -279,7 +280,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLUnitsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -347,7 +349,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index 2f453a497..9a13ff904 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -37,7 +37,7 @@ package com.jogamp.opengl; */ public class GLRendererQuirks { /** - * Crashes XServer when using double buffered PBuffer with: + * Crashes XServer when using double buffered PBuffer with GL_RENDERER: * <ul> * <li>Mesa DRI Intel(R) Sandybridge Desktop</li> * <li>Mesa DRI Intel(R) Ivybridge Mobile - 3.0 Mesa 8.0.4</li> @@ -62,11 +62,23 @@ public class GLRendererQuirks { /** GLSL <code>discard</code> command leads to undefined behavior or won't get compiled if being used. Appears to happen on Nvidia Tegra2. FIXME: Constrain version. */ public static final int GLSLBuggyDiscard = 5; + /** + * Non compliant GL context, e.g. due to a buggy implementation rendering it not suitable for use. + * <p> + * Mesa >= 9.0 (?), Intel driver, OpenGL 3.1 compatibility context is not compliant: + * <pre> + * GL_RENDERER: Mesa DRI Intel(R) Sandybridge Desktop + * </pre> + * </p> + */ + public static final int GLNonCompliant = 6; + /** Number of quirks known. */ - public static final int COUNT = 6; + public static final int COUNT = 7; private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", - "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard" + "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard", + "GLNonCompliant" }; private final int _bitmask; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index f61b55497..c3c2eff4b 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -571,9 +571,10 @@ public abstract class GLContextImpl extends GLContext { final boolean created; try { created = createImpl(shareWith); // may throws exception if fails! - if( created && isGL3core() && ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=2 ) ) { - // Due to GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331) - // There is no more default VAO buffer 0 bound, hence generating and binding one + if( created && isGL3core() && ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) ) { + // Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296), + // GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331) + // there is no more default VAO buffer 0 bound, hence generating and binding one // to avoid INVALID_OPERATION at VertexAttribPointer. // More clear is GL 4.3 core spec: 10.4 (p 307). final int[] tmp = new int[1]; @@ -773,6 +774,29 @@ public abstract class GLContextImpl extends GLContext { boolean hasGL2 = false; boolean hasGL4 = false; boolean hasGL3 = false; + + // Even w/ PROFILE_ALIASING, try to use true core GL profiles + // ensuring proper user behavior across platforms due to different feature sets! + // + 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, ctxMajorVersion, ctxMinorVersion, ctxOptions); + if(PROFILE_ALIASING) { + hasGL3 = true; + } + resetStates(); // clean this context states, since creation was temporary + } + } + if(!hasGL3) { + hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 + success |= hasGL3; + if(hasGL3) { + resetStates(); // clean this context states, since creation was temporary + } + } if(!hasGL4bc) { hasGL4bc = createContextARBMapVersionsAvailable(4, CTX_PROFILE_COMPAT); // GL4bc success |= hasGL4bc; @@ -780,8 +804,12 @@ public abstract class GLContextImpl extends GLContext { // Map all lower compatible profiles: GL3bc, GL2, GL4, GL3 GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_COMPAT, ctxMajorVersion, ctxMinorVersion, ctxOptions); GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxMajorVersion, ctxMinorVersion, ctxOptions); - GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + if(!hasGL4) { + GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + } + if(!hasGL3) { + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + } if(PROFILE_ALIASING) { hasGL3bc = true; hasGL2 = true; @@ -797,7 +825,9 @@ public abstract class GLContextImpl extends GLContext { if(hasGL3bc) { // Map all lower compatible profiles: GL2 and GL3 GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxMajorVersion, ctxMinorVersion, ctxOptions); - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + if(!hasGL3) { + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + } if(PROFILE_ALIASING) { hasGL2 = true; hasGL3 = true; @@ -812,25 +842,6 @@ public abstract class GLContextImpl extends GLContext { resetStates(); // 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, ctxMajorVersion, ctxMinorVersion, ctxOptions); - if(PROFILE_ALIASING) { - hasGL3 = true; - } - resetStates(); // clean this context states, since creation was temporary - } - } - if(!hasGL3) { - hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 - success |= hasGL3; - if(hasGL3) { - resetStates(); // clean this context states, since creation was temporary - } - } if(success) { // only claim GL versions set [and hence detected] if ARB context creation was successful GLContext.setAvailableGLVersionsSet(device); @@ -883,7 +894,7 @@ public abstract class GLContextImpl extends GLContext { /* min */ majorMin, minorMin, /* res */ major, minor); - if(0==_context && CTX_PROFILE_CORE == reqProfile) { + if( 0 == _context && CTX_PROFILE_CORE == reqProfile && !PROFILE_ALIASING ) { // try w/ FORWARD instead of CORE ctp &= ~CTX_PROFILE_CORE ; ctp |= CTX_OPTION_FORWARD ; @@ -891,7 +902,7 @@ public abstract class GLContextImpl extends GLContext { /* max */ majorMax, minorMax, /* min */ majorMin, minorMin, /* res */ major, minor); - if(0==_context) { + if( 0 == _context ) { // Try a compatible one .. even though not requested .. last resort ctp &= ~CTX_PROFILE_CORE ; ctp &= ~CTX_OPTION_FORWARD ; @@ -903,7 +914,7 @@ public abstract class GLContextImpl extends GLContext { } } final boolean res; - if(0!=_context) { + if( 0 != _context ) { AbstractGraphicsDevice device = drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); // ctxMajorVersion, ctxMinorVersion, ctxOptions is being set by // createContextARBVersions(..) -> setGLFunctionAvailbility(..) -> setContextVersion(..) @@ -941,6 +952,10 @@ public abstract class GLContextImpl extends GLContext { if(0 != _context) { ok = setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true); + if(!ok) { + destroyContextARBImpl(_context); + _context = 0; + } } else { ok = false; } @@ -1157,7 +1172,7 @@ public abstract class GLContextImpl extends GLContext { * context. See {@link #isFunctionAvailable(String)} for more information on * the definition of "available". * <br> - * All ProcaddressTables are being determined, the GL version is being set + * All ProcaddressTables are being determined and cached, the GL version is being set * and the extension cache is determined as well. * * @param force force the setting, even if is already being set. @@ -1165,15 +1180,19 @@ public abstract class GLContextImpl extends GLContext { * @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 strictVersionMatch if <code>true</code> and the ctx version (by string) is lower than the given major.minor version, - * method aborts and returns <code>false</code>, otherwise <code>true</code>. - * @return returns <code>true</code> if successful, otherwise <code>false</code>. See <code>strictVersionMatch</code>. + * @param strictMatch if <code>true</code> the ctx must + * <ul> + * <li>be greater or equal than the requested <code>major.minor</code> version version, and</li> + * <li>match the ctxProfileBits</li> + * </ul>, otherwise method aborts and returns <code>false</code>. + * @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 * @see javax.media.opengl.GLContext#CTX_OPTION_ANY * @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 strictVersionMatch) { + protected final boolean setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits, boolean strictMatch) { if(null!=this.gl && null!=glProcAddressTable && !force) { return true; // already done and not forced } @@ -1208,7 +1227,7 @@ public abstract class GLContextImpl extends GLContext { final VersionNumber setGLVersionNumber = new VersionNumber(major, minor, 0); final VersionNumber strGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); if( null != strGLVersionNumber && ( strGLVersionNumber.compareTo(setGLVersionNumber) < 0 || 0 == major ) ) { - if( 0 < major && strictVersionMatch ) { + if( strictMatch && 0 < major ) { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch: "+major+"."+minor+", ctp "+toHexString(ctxProfileBits)+", "+glVersion+", "+strGLVersionNumber); } @@ -1227,6 +1246,16 @@ public abstract class GLContextImpl extends GLContext { if( 2 > major ) { // there is no ES2-compat for a profile w/ major < 2 ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT; } + + setRendererQuirks(major, minor, ctxProfileBits); + + if( strictMatch && glRendererQuirks.exist(GLRendererQuirks.GLNonCompliant) ) { + if(DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL is not compliant: "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)+", "+glRenderer); + } + return false; + } + contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 validated FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion) + ", "+glVersionNumber); @@ -1301,8 +1330,6 @@ public abstract class GLContextImpl extends GLContext { // setContextVersion(major, minor, ctxProfileBits, true); - setRendererQuirks( 0 == ( ctxProfileBits & GLContext.CTX_IMPL_ACCEL_SOFT ) ); - setDefaultSwapInterval(); if(DEBUG) { @@ -1311,10 +1338,13 @@ public abstract class GLContextImpl extends GLContext { return true; } - private final void setRendererQuirks(boolean hwAccel) { + private final void setRendererQuirks(int major, int minor, int ctp) { int[] quirks = new int[GLRendererQuirks.COUNT]; int i = 0; + final boolean hwAccel = 0 == ( ctp & GLContext.CTX_IMPL_ACCEL_SOFT ); + final boolean compatCtx = 0 != ( ctp & GLContext.CTX_PROFILE_COMPAT ); + // OS related quirks if( Platform.getOSType() == Platform.OSType.MACOS ) { final int quirk1 = GLRendererQuirks.NoOffscreenBitmap; @@ -1344,7 +1374,7 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer); } - quirks[i++] = quirk; + quirks[i++] = quirk; } if( hwAccel /* glRendererLowerCase.contains("intel(r)") || glRendererLowerCase.contains("amd") */ ) { @@ -1354,7 +1384,16 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } + if( glRendererLowerCase.contains("intel(r)") && compatCtx && ( major>3 || major==3 && minor>=1 ) ) + { + final int quirk = GLRendererQuirks.GLNonCompliant; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer); + } + quirks[i++] = quirk; + } } + glRendererQuirks = new GLRendererQuirks(quirks, 0, i); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java index c699e6304..90f0c5414 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java @@ -45,7 +45,19 @@ import org.junit.BeforeClass; import org.junit.AfterClass; import org.junit.Test; -public class TestGLUnitsNEWT extends UITestCase { +/** + * Some GL state values are broken w/ Mesa 9.0 w/ multiple different context. + * <p> + * This bug lies within Mesa3D (any renderer) and is fixed in + * commit 8dc79ae7d73cf6711c2182ff9a5d37ef6c989d23. + * </p> + * <p> + * Mesa3D Version 9.0 still exposes this bug, + * where 9.0.1 has it fixed w/ above commit. + * </p> + * <https://jogamp.org/bugzilla/show_bug.cgi?id=651> + */ +public class TestGLMesaBug651NEWT extends UITestCase { static int width, height; @BeforeClass @@ -205,6 +217,6 @@ public class TestGLUnitsNEWT extends UITestCase { } public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestGLUnitsNEWT.class.getName()); + org.junit.runner.JUnitCore.main(TestGLMesaBug651NEWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug658NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug658NEWT.java new file mode 100644 index 000000000..25b0b930c --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug658NEWT.java @@ -0,0 +1,200 @@ +package com.jogamp.opengl.test.junit.jogl.acore; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * The 3.1 compatibility context on Mesa >= 9.0 seems to be broken. + * <p> + * This bug lies within Mesa3D (any renderer) and is fixed in + * commit ??? (not yet). + * </p> + * <p> + * Mesa3D Version 9.0 still exposes this bug, + * where 9.?.? has it fixed w/ above commit. + * </p> + * <https://jogamp.org/bugzilla/show_bug.cgi?id=658> + */ +public class TestGLMesaBug658NEWT extends UITestCase { + + @Test + public void test00ShowAvailProfiles() { + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, false).toString()); + } + + @Test + public void test10GL2PolygonModeFailure() { + testGLNPolygonModeFailureImpl(GLProfile.GL2); + } + + @Test + public void test11GL3bcPolygonModeFailure() { + testGLNPolygonModeFailureImpl(GLProfile.GL3bc); + } + + @Test + public void test12GL3PolygonModeFailure() { + testGLNPolygonModeFailureImpl(GLProfile.GL3); + } + + private void testGLNPolygonModeFailureImpl(String profile) { + if(!GLProfile.isAvailable(profile)) { System.err.println(profile+" n/a"); return; } + + final GLProfile pro = GLProfile.get(profile); + final GLCapabilities caps = new GLCapabilities(pro); + final GLWindow window = GLWindow.create(caps); + + window.setSize(640, 480); + window.addGLEventListener(new GLEventListener() { + public void reshape( + final GLAutoDrawable drawable, + final int x, + final int y, + final int width, + final int height) + { + // Nothing. + } + + public void init( + final GLAutoDrawable drawable) + { + final GLContext context = drawable.getContext(); + System.err.println("CTX: "+context.getGLVersion()); + + final GL2GL3 gl = drawable.getGL().getGL2GL3(); + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); + + if( gl.isGL2() || gl.isGLES2() ) { // compatibility profile || ES2 + gl.glPolygonMode(GL.GL_FRONT, GL2GL3.GL_FILL); + } else { + gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL); + } + + final int e = gl.glGetError(); + Assert.assertTrue(e == GL.GL_NO_ERROR); // // FIXME On Mesa 9.0.1 w/ GL 3.1 -> GL.GL_INVALID_OPERATION ? + } + + public void dispose( + final GLAutoDrawable drawable) + { + // Nothing. + } + + public void display( + final GLAutoDrawable drawable) + { + // Nothing. + } + }); + + try { + window.setVisible(true); + } finally { + window.destroy(); + } + } + + @Test + public void test20GL2BindArrayAttributeFails() { + testGLNBindArrayAttributeFailsImpl(GLProfile.GL2); + } + + @Test + public void test21GL3bcBindArrayAttributeFails() { + testGLNBindArrayAttributeFailsImpl(GLProfile.GL3bc); + } + + @Test + public void test22GL3BindArrayAttributeFails() { + testGLNBindArrayAttributeFailsImpl(GLProfile.GL3); + } + + private void testGLNBindArrayAttributeFailsImpl(String profile) { + if(!GLProfile.isAvailable(profile)) { System.err.println(profile+ " n/a"); return; } + + final GLProfile pro = GLProfile.get(profile); + final GLCapabilities caps = new GLCapabilities(pro); + final GLWindow window = GLWindow.create(caps); + + window.setSize(640, 480); + window.addGLEventListener(new GLEventListener() { + public void reshape( + final GLAutoDrawable drawable, + final int x, + final int y, + final int width, + final int height) + { + // Nothing. + } + + public void init( + final GLAutoDrawable drawable) + { + final GLContext context = drawable.getContext(); + System.err.println("CTX: "+context.getGLVersion()); + + final GL2GL3 gl = drawable.getGL().getGL2GL3(); + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); + + final int[] name = new int[] { 0 }; + gl.glGenBuffers(1, name, 0); + Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR); + + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, name[0]); + Assert.assertTrue(gl.glGetError() == 0); + gl.glBufferData(GL.GL_ARRAY_BUFFER, 4 * 32, null, GL.GL_STATIC_DRAW); + Assert.assertTrue(gl.glGetError() == 0); + + Assert.assertTrue(gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER) == name[0]); + gl.glEnableVertexAttribArray(1); + Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR); + gl.glVertexAttribPointer(1, 4, GL.GL_FLOAT, false, 0, 0L); + Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR); // FIXME On Mesa 9.0.1 w/ GL 3.1 -> GL.GL_INVALID_OPERATION ? + } + + public void dispose( + final GLAutoDrawable drawable) + { + // Nothing. + } + + public void display( + final GLAutoDrawable drawable) + { + // Nothing. + } + }); + + try { + window.setVisible(true); + } finally { + window.destroy(); + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestGLMesaBug658NEWT.class.getName()); + } + +} + |