glDrawElements to draw a cube in PyOpenGL

走远了吗. 提交于 2019-12-02 03:10:01
gl.glDrawElements(gl.GL_TRIANGLES, len(index), gl.GL_UNSIGNED_INT, index)

The index argument has two different meanings depending on whether an ELEMENT_ARRAY_BUFFER is bound or not:

  • If no bound: Then it specifies a pointer to client memory where the indices are stored
  • If a ELEMENT_ARRAY_BUFFER is bound, then the index parameter specifies an offset into this buffer. This defines where in the buffer the indices start.

In your case, a buffer is bound, so you tell OpenGL to start somewhere in the buffer. But what you want is to start at the beginning of the buffer, thus you have to set index to 0.

gl.glDrawElements(gl.GL_TRIANGLES, len(index), gl.GL_UNSIGNED_INT, ctypes.c_void_p(0))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!