glVertexPointer 无效操作
我在使用 OpenGL 时遇到了相当奇怪的问题。当我尝试使用没有绑定到 GL_ARRAY_BUFFER 的缓冲区的 glVertexPointer
并使用顶点数组对象(VAO)时,它会生成无效的操作错误。 glVertexPointer
的文档中没有此错误。
当我生成缓冲区并将其绑定到 GL_ARRAY_BUFFER 时,错误消失,但由于我将数据存储在 RAM 上,因此我绑定 0 并使用指向 RAM 的指针。另外,通过不绑定 VAO,我不再收到错误,但我注意到,当我不使用它时,程序中的其他内容会被损坏。
也许我错过了某个地方,设置指针,而 VAO 已绑定而缓冲区未绑定,将是无效的无效操作?理论上我可以将这些数据移至 VBO,而不必费心,但我想知道为什么会发生这种情况。
I'm having rather strange problem with OpenGL. When I try to use glVertexPointer
with no buffer bound to GL_ARRAY_BUFFER
and using Vertex Array Object(VAO), it generates invalid operation error. This error is nowhere in documentation of glVertexPointer
.
When I generate buffer and bind it to GL_ARRAY_BUFFER
, error disappears, but as I have my data stored on RAM, I bind 0 and use pointer to RAM. Also by not binding VAOs I don't get error anymore, but I've noticed that when I don't use it, my other things further in program gets corrupted.
Maybe I've missed somewhere that setting pointers, while VAO is bound and buffer is not, is going to be invalid invalid operation? Theoretically I could move those data to VBOs and don't bother, but I'd like to know why's this happening.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ARB_vertex_array_object 的扩展注册表明确指出,它们不能与客户端一起使用边数组。对于支持 VAO 的核心 OpenGL 版本来说,这应该没有什么不同,因为 VAO 是服务器状态的。因此,出现无效操作错误完全是预料之中的行为。只需将所有内容存储在 VBO 中(如果数据经常更改,则可以使用 GL_DYNAMIC_DRAW 或 GL_STREAM_DRAW 作为用法)。
The extension registry for ARB_vertex_array_object clearly states, that they cannot be used with client-side arrays. This shouldn't be different for the core OpenGL versions supporting VAOs and is due to the fact, that VAOs are server-state. So it is completely expected behaviour to get an invalid operation error. Just store everything in VBOs (maybe using
GL_DYNAMIC_DRAW
orGL_STREAM_DRAW
as usage if the data changes frequently).