Bug-Report: glVertexAttrib and lwjgl-debug bug

Started by zaippa, April 09, 2010, 15:25:12

Previous topic - Next topic

zaippa

Hi. First post here! :)

I think i've found a bug in the LWJGL debug-jar. (v2.2.1)

As you guys know, it is illegal to call glGetError() within a glBegin/glEnd pair.
(will result in invalid operation)

Also: In order to set vertex-attributes per-vertex (and without using VBOs), glVertexAttrib*f() must be called within a glBegin()/glEnd() pair.

Lwjgl-debug.jar is very nice to use while developing, because it calls glGetError() after almost all OpenGL function-calls.
BUT of course it shouldn't do that for functions intended to be used between glBegin/glEnd.

After many hours of debugging, it seems that lwjgl-debug.jar actually does call glGetError() after glVertexAttrib*f()!
Since glVertexAttrib*f() is intended to be used within glBegin/glEnd, this will result in "invalid operation" whenever glVertexAttrib*f() is used.



Is there any workaround? Or a fix?

(i am using LWJGL v2.2.1, since it's still possible to use non-native buffers, which can wrap and get java-arrays, and i still
find the buffer thing a bit confusing. But is it fixed in the new version?)


Thanx for da ruling LWJGL!
/Bjarke N. Laustsen

-------------------------------------

The code to reproduce is something like this:

   <...bind shader...>
   
   glBegin(GL_POINTS);
   glColor3f(1,0,1);
   glVertexAttrib4f(attribID, s1, s2, s3, s4);
   glVertex2f(0,0);
   glEnd();   
   
   <...unbind shader...>

Screen shot from glslDevil is attached, which shows that glGetError() is actually called by glVertexAttrib4f().
(This does of course not happen in the non-debug build)

The exception i got (which is thrown when glEnd() is executed):

org.lwjgl.opengl.OpenGLException: Invalid operation (1282)
        at org.lwjgl.opengl.Util.checkGLError(Util.java:54)
        at org.lwjgl.opengl.GL11.glEnd(GL11.java:702)
        at engine.resources.ShaderTest.bindAttributeTestCommonCode(ShaderTest.java:135)
        at engine.resources.ShaderTest.bindAttribute1(ShaderTest.java:644)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
        at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
        at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
        at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
        at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
        at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
        at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
        at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
        at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
        at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
        at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
        at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
        at org.junit.internal.runners.CompositeRunner.runChildren(CompositeRunner.java:33)
        at org.junit.internal.runners.CompositeRunner.run(CompositeRunner.java:28)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:130)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:109)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:100)
        at org.junit.runner.JUnitCore.runMain(JUnitCore.java:81)
        at org.junit.runner.JUnitCore.main(JUnitCore.java:44)
       

Matzon

wonder if it would be best to disable glGetError between begin/end - or just use @NoErrorCheck? - spasi?

spasi

I was working on it, but something came up, gonna commit tomorrow.

spasi

Committed now. I added several @NoErrorCheck on vertex data methods and also added Begin/End pair tracking for the debug build, it will never call glGetError between them.

Thanks for the report zaippa! :)

zaippa


Matzon

Quote from: spasi on April 10, 2010, 00:00:14
Committed now. I added several @NoErrorCheck on vertex data methods and also added Begin/End pair tracking for the debug build, it will never call glGetError between them.

Thanks for the report zaippa! :)

very nice job!
I'll check with kappa related to a flashing window bug thingy - but then I think we're more than set for 2.4!