Login  Register

Re: Exception: array vertex_buffer_object must be enabled to call this method

Posted by gmseed on Nov 18, 2011; 8:57am
URL: https://forum.jogamp.org/Exception-array-vertex-buffer-object-must-be-enabled-to-call-this-method-tp3517264p3518122.html

Hi

Thanks for your comments.

Maybe I've missed something but I can't find a list of the appropriate debug information to post at:

http://forum.jogamp.org/Problem-with-GLProfile-and-jogl2-rc2-td3447491.html#a3447546

You say that the vertex buffer is not properly initialised. If I add the order comments to my display() we'll see that it already adheres to the order you suggest. The data initialisation is performed in init() via initializeVertexBuffer() and since no change occurs to the data then I think the display() call sequence appears fine; below with your order comments added:

    public void display(GLAutoDrawable gLDrawable)
    {
        final GL2 gl = gLDrawable.getGL().getGL2();
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);

        // in
        gl.glUseProgram(mTheProgram);
        // enable
        gl.glBindBuffer(GL2.GL_ARRAY_BUFFER,mVertexBufferObject);
        gl.glEnableVertexAttribArray(0);
        gl.glVertexAttribPointer(0, 4, GL.GL_FLOAT,false, 0, 0);
        // use
        gl.glDrawArrays(GL.GL_TRIANGLES, 0, 3);
        // disable
        gl.glDisableVertexAttribArray(0);
        // out
        gl.glUseProgram(0);
       
        gLDrawable.swapBuffers();
    }

Since I'm using Buffers.newDirectFloatBuffer() then there is no garbage collection calls between initialisation and the glDrawArrays() call. Thus, I don't fully see why the initialisation is incorrect.

Also, I don't understand your if-elseif block:

if(!dataWritten) {
    gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, mVertexBufferObject);
    gl.glBufferData(..)
  } else if(vboHasChanged) {
    gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, mVertexBufferObject);
    gl.glVertexAttribPointer(0, 4, GL.GL_FLOAT,false, 0, 0);
  }

It doesn't appear to have correct closure. If dataWritten is true then the "else if(vboHasChanged)" is not called.

I still don't understand the difference between working fine on WinXP/Nvidia and not working on Win7/ATI.

Thanks

Graham