我试图在OpenGL中渲染一些对象,但即使我用正确的模式调用glDrawElements
,它仍然会给我一个GL_INVALID_ENUM
。这是AMD的CodeXL记录的呼叫记录,从设置到渲染:
glBindVertexArray(1)
... creating shaders/programs and getting uniform locations ...
# the vertex buffer
glGenBuffers(1, 0x008A945C)
glBindBuffer(GL_ARRAY_BUFFER, 1)
glBufferData(GL_ARRAY_BUFFER, 96, 0x008A94A0, GL_STATIC_DRAW)
# the element index buffer
glGenBuffers(1, 0x008A9460)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 2)
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 96, 0x008A9508, GL_STATIC_DRAW)
glClearColor(0.12, 0.63999999, 0.55000001, 1)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glEnableVertexAttribArray(0)
glUseProgram(1)
glUniformMatrix4fv(0, 1, FALSE, ... MVP Matrix ...)
glBindBuffer(GL_ARRAY_BUFFER, 1)
glVertexAttribPointer(0, 3, GL_FLOAT, FALSE, 0, 0x00000000)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 2)
glDrawElements(GL_QUADS, 24, GL_UNSIGNED_INT, 0x00000000) # GL_INVALID_ENUM here <----
glUseProgram(0)
glDisableVertexAttribArray(0)
wglSwapBuffers(0x09011214)
我已经尝试按glDrawElements
(使用正确的参数)交换glDrawArrays(GL_QUADS, 0, 4)
,但它仍然给我同样的错误。可能是什么导致了这个? CodeXL似乎很确定错误是在绘制调用时准确引发的,而不是之前。
答案 0 :(得分:5)
这是因为在{0}}中已弃用GL_QUADS
,请参阅glDrawArrays
的文档。
你可以: