有两个OpenGL文档页面,它们对glDrawElements函数的“index”参数有略微不同的描述。在www.opengl.org/sdk/docs/man4/上,它说:
indices
Specifies a pointer to the location where the indices are stored.
在www.khronos.org/opengles/sdk/docs/man3上,它说:
indices
Specifies a byte offset (cast to a pointer type) into the buffer bound
to GL_ELEMENT_ARRAY_BUFFER to start reading indices from. If no buffer
is bound, specifies a pointer to the location where the indices are stored.
顺便说一下,我在使用OpenGL 4+的Windows系统。
所以我把索引数组复制到了我创建的元素缓冲对象中,我需要提供的indices指针参数是第一个索引的字节偏移量吗?那么如果我要从索引3开始绘制,这个参数会是2 * sizeof(GLuint),转换为指针吗?
我实际上费了一番力气来创建EBO,但看起来好像说如果没有绑定EBO,指针就直接指向索引所在的位置,而不是EBO。我对吗?这是否意味着它将指向系统RAM中的数组?(编辑:我刚才意识到这是不合理的,如果指针在0x00000008处,它不能去到系统内存中的那个地址)。如果是这样,它是否会每次复制索引数组到显卡上才能使用?谢谢。