Login  Register

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

Posted by Sven Gothel on Nov 18, 2011; 1:20am
URL: https://forum.jogamp.org/Exception-array-vertex-buffer-object-must-be-enabled-to-call-this-method-tp3517264p3517604.html

On Thursday, November 17, 2011 11:36:10 PM gmseed [via jogamp] wrote:

>
> Hi
>
> I ported the Tutorial 2 FragPosition.cpp tutorial at
> http://arcsynthesis.org/gltut/ to JOGL; see code below.
>
> It works fine on my 64bit WinXP PC with an Nvidia Quadro but when I run it
> on my laptop with 64bit Win7 with an ATI Radeon I get the following
> exception trace.
>
> Does anyone know why this is happening?
>
> It appears to be failing in:
>
> Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: array
> vertex_buffer_object must be enabled to call this method
> at jogamp.opengl.gl4.GL4bcImpl.checkBufferObject(GL4bcImpl.java:32020)
> at jogamp.opengl.gl4.GL4bcImpl.checkArrayVBOEnabled(GL4bcImpl.java:32047)
> at jogamp.opengl.gl4.GL4bcImpl.glVertexAttribPointer(GL4bcImpl.java:30691)
>
> and doesn't like the call to glVertexAttribPointer().


You call the VBO version w/ offset of
  'gl.glVertexAttribPointer(0, 4, GL.GL_FLOAT,false, 0, 0);'
hence the VBO must be enabled - hence the error message.

Ofc you know this.
Maybe run your code w/ debug and trace enabled to see whether
your VBO name 'mVertexBufferObject' is properly initialized
and you do have VBO support in the 1st place.
If the VBO name is '0' and/or glGetError() returns an error,
you may not have VBO support - which is odd.

Please post the appropriate debug information
  http://forum.jogamp.org/Problem-with-GLProfile-and-jogl2-rc2-td3447491.html#a3447546

Maybe run 'TestGearsES2NEWT' w/ debug flags, it usees a similar code path w/o AWT though,
but this should not matter.

+++

Some general review remarks unrelated to the above issue:

- You derive from GLCanvas, which is not recommended nor required.

- You use the VA before proper initialization:

>         gl.glUseProgram(mTheProgram);
>
>         gl.glBindBuffer(GL2.GL_ARRAY_BUFFER,mVertexBufferObject);
>         gl.glEnableVertexAttribArray(0);
>         gl.glVertexAttribPointer(0, 4, GL.GL_FLOAT,false, 0, 0);
>         gl.glDrawArrays(GL.GL_TRIANGLES, 0, 3);
>        
>         gl.glDisableVertexAttribArray(0);
>         gl.glUseProgram(0);

Proper order is:

- in
  - setup VA data
  - enable-VA
  - use-it
  - disable-VA
- out

  // in
  gl.glUseProgram(mTheProgram);

  // sync data
  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);
  }
  vboHasChanged=false;
  dataWritten=true;

  // enable
  gl.glEnableVertexAttribArray(0);

  // use it
  gl.glDrawArrays(GL.GL_TRIANGLES, 0, 3);        

  // disable
  gl.glDisableVertexAttribArray(0);

  // out
  gl.glUseProgram(0);

You may assume vboHasChanged==true all the time, since it's a minor
opimization step used eg. in JOGL's GLSLArrayHandler::syncData().

>
> Thanks Graham