Posted by
gmseed on
Dec 01, 2011; 11:36am
URL: https://forum.jogamp.org/array-vertex-buffer-object-must-be-disabled-to-call-this-method-tp3551291.html
Hi
I implemented the Java port of Vertex Buffers at Java-Tips::
http://www.java-tips.org/other-api-tips/jogl/vertex-buffer-objects-nehe-tutorial-jogl-port-2.htmlIf the flag mUseVBO is true and VBOs are used it works fine.
However, if I set to mUseVBO to false then it defaults to using vertex arrays. In this case I get the following exception thrown:
Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: array vertex_buffer_object must be disabled to call this method
at jogamp.opengl.gl4.GL4bcImpl.checkBufferObject(GL4bcImpl.java:32027)
at jogamp.opengl.gl4.GL4bcImpl.checkArrayVBODisabled(GL4bcImpl.java:32037)
at jogamp.opengl.gl4.GL4bcImpl.glVertexPointer(GL4bcImpl.java:30986)
at com.itp.geo.threed.jogl.VertexBufferObjectRenderer.render_fill(VertexBufferObjectRenderer.java:134)
and originates at the call:
gl2.glVertexPointer(3, GL.GL_FLOAT, 0, mVertices);
Presumably the example at Java-Tips fails and I don't understand what the exception is saying as the backup vertex arrays is not binding the vertex buffer.
Has anyone else resolved this issue?
Thanks
Graham
====
public void render_fill(GL gl)
{
GL2 gl2 = gl.getGL2();
gl2.glPolygonMode(GL2.GL_FRONT_AND_BACK,GL2.GL_FILL);
if (mUseVBO) // VBO supported
{
gl2.glBindBuffer(GL2.GL_ARRAY_BUFFER, mVBOVertices[0]); // bind
gl2.glEnableClientState(GL2.GL_VERTEX_ARRAY); // enable vertex arrays
gl2.glVertexPointer(3, GL.GL_FLOAT, 0, 0); // Set The Vertex Pointer To The Vertex Buffer
gl2.glDrawArrays(GL.GL_TRIANGLES, 0, mVertexCount); // Draw All Of The Triangles At Once
gl2.glDisableClientState(GL2.GL_VERTEX_ARRAY); // Disable Vertex Arrays
gl2.glBindBuffer(GL2.GL_ARRAY_BUFFER,0); // release VBOs with id 0 after use
}
else // VBO not supported
{
gl2.glEnableClientState(GL2.GL_VERTEX_ARRAY); // enable vertex arrays
gl2.glVertexPointer(3, GL.GL_FLOAT, 0, mVertices); // Set The Vertex Pointer To Our Vertex Data
gl2.glDrawArrays(GL.GL_TRIANGLES, 0, mVertexCount); // draw arrays
gl2.glDisableClientState(GL2.GL_VERTEX_ARRAY); // disable vertex arrays
}
}