opengl - 当 glVertexAttribPointer 没有绑​​定缓冲区时,GL_NO_ERROR

标签 opengl

我在没有绑定(bind)GL_ARRAY_BUFFER的情况下调用了glVertexAttribPointerfirst :

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/

相关文章:

opengl - 将基本 3D 模型导入 OpenGL 应用程序

c++ - Opengl VAO 被覆盖

opengl - 启用深度测试不会导致任何内容出现

c++ - glBindAttribLocation 接下来是什么?

c++ - 在 OpenGL 中绘制 N 角星 - C++

xcode - 在 Xcode 中为 Mac 开发 OpenGL。我可以强制软件渲染吗?

c++ - 如何对图像使用片段着色器

c++ - SDL和OpenGL程序编译失败

java - 纹理未正确拉伸(stretch)。为什么会这样?

c++ - 基于 Tulip 的 Qt 应用程序仅显示黑屏。我如何让它正确显示?