Login  Register

glVertexAttribPointer causes GL_INVALID_OPERATION

Posted by Hotzenplotz on Nov 18, 2011; 1:13pm
URL: https://forum.jogamp.org/glVertexAttribPointer-causes-GL-INVALID-OPERATION-tp3518547.html

Hi,

i cant figure out what i am doing wrong. When i call glVertexAttribPointer i get an GL_INVALID_OPERATION:

display method (scala code):
val gl = glautodrawable.getGL.getGL3
gl.glClear( GL.GL_COLOR_BUFFER_BIT );
gl.glClearColor(0,0.5f,1,0)

gl.glUseProgram(_prog.id)
				
//println(gl.getInt(GL2.GL_MAX_VERTEX_ATTRIBS_ARB)) // => 29
//println(gl.getInt(GL2GL3.GL_MAJOR_VERSION)) // => 3

val attrIdx = 0

gl.glBindAttribLocation(_prog.id,attrIdx,"position")
gl.throwWhenError
gl.glBindBuffer(GL.GL_ARRAY_BUFFER,vboId)
gl.throwWhenError
gl.glEnableVertexAttribArray(attrIdx)
gl.throwWhenError // <-- #throws NO error#

gl.glVertexAttribPointer(attrIdx,3,GL.GL_FLOAT,false,0,0)
gl.throwWhenError // <-- #throws the error#

gl.setProgramUniform(_prog.id,'modelview_matrix,_camera.modelViewMatrix)
gl.setProgramUniform(_prog.id,'projection_matrix,_camera.projectionMatrix)

gl.drawPrimitives(Primitives.Triangles,6)

gl.glDisableVertexAttribArray(attrIdx)

The vbo is set up like this:
val plane = Geometry.groundPlaneAttributes // just an array of 6*3 floats

vboId = gl.generateBuffer
gl.glBindBuffer(GL.GL_ARRAY_BUFFER,vboId)
				gl.loadBufferData(GL.GL_ARRAY_BUFFER,6*3*4,FloatBuffer.wrap(plane),GL.GL_STATIC_DRAW)

This returns true:
gl.isExtensionAvailable("GL_ARB_vertex_buffer_object")

What am i doing wrong? Or how could i find out whats wrong? I have this error with jogl-2.0-b544/gluegen-2.0-b437 and jogl-2.0-b23/gluegen-2.0-b23.

EDIT:
Im using:
val glprofile = GLProfile.get(GLProfile.GL3)
val glcapabilities = new GLCapabilities(glprofile)
val glcanvas = new GLCanvas(glcapabilities)