OpenGLException: Cannot use Buffers when Array Buffer Object is enabled

Hi ;D

It is my first tests with VBO and, of course, it is not working.
LWJGL is complaining that I use VBO and none VBO rendering (what I do). I was thinking that it should be possible if I unbind VBO after use. Am I wrong ?

There is my rendering code with vbo :


GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
     ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB,
                                           bufferVertices);
     GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);

     if (bufferTextCoords != -1)
     {
       GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
       ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB,
                                             bufferTextCoords);
       GL11.glTexCoordPointer(2,GL11.GL_FLOAT, 0, 0);
     }

     if (bufferNormales != -1)
     {
       GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
       ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB,
                                             bufferNormales);
       GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0);
     }

     ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB,
                                             bufferNormales);
     GL11.glDrawElements(GL11.GL_TRIANGLES, nbTriangles*3, GL11.GL_INT, 0);

     if (bufferNormales != -1)
     {
       GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
     }

     if (bufferTextCoords != -1)
     {
       GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
     }

     ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB,0);
     ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB,0);
     GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);

Darmn, I just have to post my problem to find out my mistake :stuck_out_tongue:

IntBuffer are GL_UNSIGNED_INT and not GL_INT when using GL11.glDrawElements… Really confusing exception message but since there was an opengl error, VBO unbinding was not working properly.

Sorry :wink: