What can cause glDrawArrays to generate a GL_INVALID_OPERATION error?

纵然是瞬间 提交于 2019-11-28 18:08:32

I figured out your problem: you are rendering to the same buffer that you're sourcing your vertex data.

glBindVertexArray(vaoPass2);

I think you meant vaoPass1

From the spec:

Buffers should not be bound or in use for both transform feedback and other purposes in the GL. Specifically, if a buffer object is simultaneously bound to a transform feedback buffer binding point and elsewhere in the GL, any writes to or reads from the buffer generate undefined values. Examples of such bindings include ReadPixels to a pixel buffer object binding point and client access to a buffer mapped with MapBuffer.

Now, you should get undefined values; I'm not sure that a GL error qualifies, but it probably should be an error.

Another (apparently undocumented) case where glDrawArrays and glDrawElements fail with GL_INVALID_OPERATION:

  • GL_INVALID_OPERATION is generated if a sampler uniform is set to an invalid texture unit identifier. (I had mistakenly performed glUniform1i(location, GL_TEXTURE0); when I meant glUniform1i(location, 0);.)

Another (undocumented) case where glDraw*() calls can fail with GL_INVALID_OPERATION:

  • GL_INVALID_OPERATION is generated if a sampler uniform is set to a texture unit bound to a texture of the incorrect type. For example, if a uniform sampler2D is set glUniform1i(location, 0);, but GL_TEXTURE0 has a GL_TEXTURE_2D_ARRAY texture bound.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!