I have called glVertexAttribPointer
without binding GL_ARRAY_BUFFER
first:
If pointer is not NULL, a non-zero named buffer object must be bound to the GL_ARRAY_BUFFER target (see glBindBuffer), otherwise an error is generated.
I had trouble finding this bug because the error is GL_NO_ERROR
after calling glVertexAttribPointer
, but glGet(GL_ARRAY_BUFFER_BINDING)
yields 0, so shouldn't this raise this error?
GL_INVALID_OPERATION is generated if zero is bound to the GL_ARRAY_BUFFER buffer object binding point and the pointer argument is not NULL.
This failure to yield an error happens when pointer
is non-null.
Is this a bug in my OpenGL driver? Or am I looking for the error in the wrong way?
If you don't use a Vertex Buffer Object, then you've to use a compatibility profile context. See OpenGL Context.
When you use glVertexAttribPointer
then a named buffer object has to be bound to the ARRAY_BUFFER
target and the last parameter is treated as a byte offset into this buffer.
In Legacy OpenGL (compatibility context) there is the option to bind a zero named buffer (0). Then the last parameter is a pointer to the buffer data.
But if you use a core profile context, then a named buffer object has to be bound in any case.
In the OpenGL 4.6 API Compatibility Profile Specification is specified that
An INVALID_OPERATION error is generated if a non-zero vertex array object is bound, no buffer is bound to ARRAY_BUFFER, and pointer is not NULL.
This means more or less, if you use a Vertex Array Object than you've to use Vertex Buffer Object, too. It is not allowed to bind a VAO, bind no VBO and to set a pointer.