The 4th argument in glDrawElements is WHAT?

c++, opengl

Solution

If you use direct drawing, then

indices​ defines the offset into the index buffer object (bound to GL_ELEMENT_ARRAY_BUFFER​, stored in the VAO) to begin reading data.

That means, you need to create VAO, bind to it, and then use `glDrawElements()` for rendering

Problem

I am confused about `glDrawElements()` . I was following a tutorial which said that the 4th argument of the `glDrawElements()` is "Offset within the `GL_ELEMENT_ARRAY_BUFFER`". But I was having an error "Access voilation: Trying to read 0x0000", if I passed 0 as offset. So I dig further into the problem and found that OpenGL Documentation provides two different definitions of the 4th argument: First: indices: Specifies a byte offset (cast to a pointer type) into the buffer bound to GL_ELEMENT_ARRAY_BUFFER​ to start reading indices from. (Found Here: https://www.opengl.org/wiki/GLAPI/glDrawElements) Second: indices: Specifies a pointer to the location where the indices are stored. (Found Here: https://www.opengl.org/sdk/docs/man4/index.php and Here: http://www.khronos.org/opengles/sdk/docs/man/xhtml/glDrawElements.xml) Which one is true and How to use it correctly? EDIT: Here is my code: http://pastebin.com/fdxTMjnC

Original source

Related problems