我在没有绑定(bind)GL_ARRAY_BUFFER
的情况下调用了glVertexAttribPointer
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.
我很难找到这个错误,因为调用 glVertexAttribPointer
后错误为 GL_NO_ERROR
,但 glGet(GL_ARRAY_BUFFER_BINDING)
产生 0,所以应该'这会引发此错误吗?
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.
当指针
非空时,会发生这种无法产生错误的情况。
这是我的 OpenGL 驱动程序中的错误吗?或者我是否以错误的方式寻找错误?
最佳答案
如果您不使用Vertex Buffer Object ,那么您必须使用兼容性配置文件上下文。 请参阅OpenGL Context .
当您使用glVertexAttribPointer
时那么命名缓冲区对象必须绑定(bind)到 ARRAY_BUFFER 目标,并且最后一个参数被视为此缓冲区的字节偏移量。
在 Legacy OpenGL (兼容性上下文)可以选择绑定(bind)零命名缓冲区 (0)。最后一个参数是指向缓冲区数据的指针。
但是,如果您使用核心配置文件上下文,则无论如何都必须绑定(bind)命名缓冲区对象。
在 OpenGL 4.6 API Compatibility Profile Specification指定为
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.
如果您使用Vertex Array Object,这意味着或多或少。比你必须使用 Vertex Buffer Object , 也。不允许绑定(bind)VAO,不允许绑定(bind)VBO,也不允许设置指针。
关于opengl - 当 glVertexAttribPointer 没有绑定缓冲区时,GL_NO_ERROR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57722994/