element vertex_buffer_object must be enabled to call this method

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

element vertex_buffer_object must be enabled to call this method

pedro
This post was updated on .
Hello all,
I'm using the build jogl-2.0-pre-20100611-windows-i586 and I'm experiancing an unexpected exception when trying to use Vertex Array Object.

Here is the exception
javax.media.opengl.GLException: element vertex_buffer_object must be enabled to call this method
        at com.jogamp.opengl.impl.gl4.GL4bcImpl.checkBufferObject(GL4bcImpl.java:24265)
        at com.jogamp.opengl.impl.gl4.GL4bcImpl.checkElementVBOEnabled(GL4bcImpl.java:24312)
        at com.jogamp.opengl.impl.gl4.GL4bcImpl.glDrawElements(GL4bcImpl.java:3501)

Here is a minimal code to reproduce :

        GL3bc gl = drawable.getGL().getGL3bc();
        gl = new DebugGL3bc(gl);


        /**
         * Create Buffer Object Data Store for Vertex Coordiantes
         */
        // 1- Create data
        final ByteBuffer vertexCoord = ByteBuffer.allocateDirect(9 * Float.SIZE / 8);
        vertexCoord.order(ByteOrder.nativeOrder());
        final FloatBuffer fbuffer = vertexCoord.asFloatBuffer();
        fbuffer.put(new float[]{1.f, 0.f, 0.f});
        fbuffer.put(new float[]{0.f, 1.f, 0.f});
        fbuffer.put(new float[]{0.f, 0.f, 1.f});
        // 2- Bind Buffer
        int vbuffers[] = new int[1];
        gl.glGenBuffers(vbuffers.length, vbuffers, 0);
        gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbuffers[0]);
        gl.glBufferData(GL3.GL_ARRAY_BUFFER, vertexCoord.capacity(), vertexCoord, GL3.GL_STATIC_DRAW);
        // 3- Cleanup current state
        gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);
        /**
         * Create Buffer Object Data Store for Trinagle Indices
         */
        // 1- Create data
        final ByteBuffer indices = ByteBuffer.allocateDirect(3 * Integer.SIZE / 8);
        indices.order(ByteOrder.nativeOrder());
        final IntBuffer ibuffer = indices.asIntBuffer();
        ibuffer.put(0);
        ibuffer.put(1);
        ibuffer.put(2);
        // 2- Bind Buffer
        int ibuffers[] = new int[1];
        gl.glGenBuffers(vbuffers.length, ibuffers, 0);
        gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, ibuffers[0]);
        gl.glBufferData(GL3.GL_ELEMENT_ARRAY_BUFFER, indices.capacity(),
                indices, GL3.GL_STATIC_DRAW);
        // 3- Cleanup current state
        gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, 0);
        /**
         * Create Vertex Array Object
         */
        final int tVertexArray[] = new int[1];
        gl.glGenVertexArrays(tVertexArray.length, tVertexArray, 0);

        gl.glBindVertexArray(tVertexArray[0]);
        gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbuffers[0]);
        gl.glVertexPointer(3, GL3.GL_FLOAT, 0, 0);
        gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
        gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, ibuffers[0]);
        // Cleanup current state
        gl.glBindVertexArray(0);
        gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0);
        gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, 0); // Everything works when removed ... ?

        /**
         * Use Vertex Array Object
         */
        gl.glBindVertexArray(tVertexArray[0]);
        gl.glDrawElements(GL3bc.GL_TRIANGLES, ibuffer.capacity() * 8 / Integer.SIZE,
                GL3bc.GL_UNSIGNED_INT, 0); //<<< KO KO KO KO KO
        gl.glBindVertexArray(0);


Note that removing the call to "gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, 0);" makes it work without trouble
It is really unexpected, because I would have expected gl.glBindVertexArray(tVertexArray[0]); to set the openGlState.

Any idea ?
In addition I didn't found the code in checkElementVBOEnabled. Does someone know where is it ?

Thanks for your help.