4th argument to glDrawElements - WHAT?

I'm confused at glDrawElements(). I followed a tutorial that stated that the 4th argument glDrawElements()is "Displacement inside GL_ELEMENT_ARRAY_BUFFER." But I had the error "Access voilation: Trying to read 0x0000" if I passed 0 as an offset.

So, I went deeper into the problem and found that the OpenGL Documentation provides two different definitions of the 4th argument:

First:

index: Specifies the byte offset (conversion to a pointer type) to a buffer bound to GL_ELEMENT_ARRAY_BUFFER to start reading indexes from.

(Found here: https://www.opengl.org/wiki/GLAPI/glDrawElements )

Secondly:

index: Indicates a pointer to where indexes 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

+4
source share
4 answers

If you use a direct drawing , then

indexes determine the offset into the index buffer object (bound to GL_ELEMENT_ARRAY_BUFFER stored in the VAO) to start reading data.

This means that you need to create a VAO, bind to it, and then use it glDrawElements()for rendering

+2
source

. , GL . :

(1) VBO (Vertex Buffer Object):

. glDrawElements, GL HW.

(2) VBO:

- . " ( ) , GL_ELEMENT_ARRAY_BUFFER, ". , glBufferData, . glDrawElements, , . , , .

+6

, GL. , . , .

, ( ) . , , .

, , - glBindVertexArray. :

  • glGenVertexArrays
  • glBufferData​​li >

( . , .)

+1

opengl.org/wiki, , . , :

Specifies a byte offset (cast to a pointer type) into the buffer bound to
GL_ELEMENT_ARRAY_BUFFER​ to start reading indices from.

GLvoid *, . , , , ( !).

, , . GLEW , GetProcAddress win32 (, glDrawElements 1.1, 1.0/1.1 GetProcAddress win32).

, , , . , VAO. NVIDIA, AMD Intel. VAO.

0

Source: https://habr.com/ru/post/1526373/


All Articles