array vertex_buffer_object must be disabled to call this method

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

array vertex_buffer_object must be disabled to call this method

gmseed
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.html

If 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
        }
    }
Reply | Threaded
Open this post in threaded view
|

Re: array vertex_buffer_object must be disabled to call this method

Sven Gothel
Administrator
On Thursday, December 01, 2011 12:36:25 PM gmseed [via jogamp] wrote:

>
> 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.html
>
> If 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.

It simply says that you are using the non VBO variant of glVertexPointer,
but you have enabled VBO. Hence even though mUseVBO is false, you are enabling VBO
(bind/enable [VBO] buffer).

~Sven
Reply | Threaded
Open this post in threaded view
|

Re: array vertex_buffer_object must be disabled to call this method

gmseed
This post was updated on .
Hi

Thanks for your reply.

You say "but you have enabled VBO".

What enables VBO in the non-VBO block:


            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

I don't get it?

If I replace the above 4 lines with the following using, say, glInterleavedArrays() I still get the same exception thrown:

            gl2.glInterleavedArrays(GL2.GL_C3F_V3F, 0, mVertices);
            gl2.glDrawArrays(GL.GL_TRIANGLES, 0, mVertexCount);     // draw arrays

Does JOGL assume that if a Buffer object is passed to functions such as glVertexPointer() and glInterleavedArrays() then VBOs are being used? If so, then how can we implement a non-VBO method using VAs because I only see Buffer arg versions?

Graham
Reply | Threaded
Open this post in threaded view
|

Re: array vertex_buffer_object must be disabled to call this method

gmseed
Hi

Now I get it!!

The code logic was:


mIsVBOSupported = GLUtilities.isVBOSupported(gl);
if (mIsVBOSupported)
{
            // Generate And Bind The Vertex Buffer
            GL2 gl2 = gl.getGL2();
            gl2.glGenBuffers(1, mVBOVertices, 0);  // Get A Valid Name
            gl2.glBindBuffer(GL2.GL_ARRAY_BUFFER, mVBOVertices[0]);  // Bind The Buffer
            // Load The Data - "Static" means the data in VBO will not be changed (specified once and used many times)
            gl2.glBufferData(GL.GL_ARRAY_BUFFER, mVertexCount * 3 * Buffers.SIZEOF_FLOAT, mVertices, GL2.GL_STATIC_DRAW);
   
            int[] bufferSizeArray = new int[1];
            gl2.glGetBufferParameteriv(GL2.GL_ARRAY_BUFFER, GL2.GL_BUFFER_SIZE,bufferSizeArray,0);
            int actualBufferSize = bufferSizeArray[0];
               
            // Our Copy Of The Data Is No Longer Necessary, It Is Safe In The Graphics Card
            mVertices = null;
}
else
{
//...
}

Thus, is VBOs are supported but NOT used and VAs are used instead then the VBO binding had already taken place. Thus, the logic has to be replaced with:

if (mIsVBOSupported && mUseVBOs)
{
}

Graham