What does a step in OpenGL mean | ES

I signed the method glVertexPointer, which

void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)

Can someone help me figure out what the third argument is doing stride.

I got this definition for strideafter he entered it.

Amount of bytes from the beginning of one element to the beginning of the following element. If you pass a zero as stride, it means they are tightly packed. If you have an array of floats, which contains vertices like this, x1,y1,z1,x2,y2,z2... and so on, you can set stride to either zero (as tightly packed), or 12 (3 floats*4 bytes each from the beginning of vertex one to the beginning of vertex two).

I can’t understand what it means? it would be very helpful if someone would explain this with an example.

thank.

+4
source share
1 answer

A simple case when your array contains only vertex coordinate data. Say we only have two coordinates, so there are 6 floats:

{x1,y1,z1, x2,y2,y2}

(4- ) (.. , x1). 12, , , OpenGL 12 ( 4 ). , 12 , , x2 - .

, - , OpenGL , . - :

{x1,y1,z1,nx1,ny1,nz1,r1,g1,b1,a1, x2,y2,z2,nx2,ny2,nz2,r2,g2,b2,a2}

- ( ). 40. , OpenGL 40 : (3 + 3 + 4 ) x 4 .

+7

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


All Articles