This code
//Init
gl.glBindBuffer (GL.GL_ARRAY_BUFFER , vbo);
gl.glBufferData (GL.GL_ARRAY_BUFFER ,vertexBuffer.capacity()*BufferUtil.SIZEOF_FLOAT, vertexBuffer,GL.GL_STATIC_DRAW );
gl.glBindBuffer (GL.GL_ARRAY_BUFFER , 0);
gl.glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , vboe);
gl.glBufferData (GL.GL_ELEMENT_ARRAY_BUFFER , indexBuffer.capacity()*BufferUtil.SIZEOF_INT,indexBuffer,GL.GL_STATIC_DRAW );
gl.glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , 0);
gl.glBindVertexArray(vao);
gl.glBindBuffer (GL.GL_ARRAY_BUFFER , vbo);
gl.glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , vboe);
gl.glEnableVertexAttribArray(0);
gl.glVertexAttribPointer(0, 3, GL.GL_FLOAT, false, 0, 0);
gl.glBindVertexArray(0);
gl.glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , 0);
gl.glBindBuffer (GL.GL_ARRAY_BUFFER , 0);
//Draw
gl.glBindVertexArray(vao);
gl.glDrawElements (GL.GL_TRIANGLES, 6, GL2.GL_UNSIGNED_INT, 0);
gl.glBindVertexArray(0);
Generate exception
javax.media.opengl.GLException: element vertex_buffer_object must be enabled to call this method
This is wrong!
vertex array object stores GL_ELEMENT_ARRAY_BUFFER_BINDING
and I do not have it each time set
this code works but it is not correct!!!
gl.glBindBuffer (GL.GL_ELEMENT_ARRAY_BUFFER , vboe);
gl.glBindVertexArray(vao);
gl.glDrawElements (GL.GL_TRIANGLES, 6, GL2.GL_UNSIGNED_INT, 0);
gl.glBindVertexArray(0);
vboe can point to any, even non-existent buffer and the code will work but it is not correct!!!