GlVertexAttribPointer, interleaved items and usability / cache

So, in the process of writing a model loader for the 3D scene I'm working on, I decided to collect the vertex, texture and normal data as follows:

VVVVTTTNNN

for each vertex, where V = the coordinate of the vertex, T = UV coordinate, and N = normal coordinate. When I pass this data to the vertex shader for my scene, I make three calls to glVertexAttribPointer, for example:

glVertexAttribPointer(ATTRIB_VERTEX, 4, GL_FLOAT, 0, 10, group->vertices.data);
glEnableVertexAttribArray(ATTRIB_VERTEX);

glVertexAttribPointer(ATTRIB_NORMAL, 3, GL_FLOAT, 0, 10, group->normals.data);
glEnableVertexAttribArray(ATTRIB_NORMAL);

glVertexAttribPointer(ATTRIB_UV_COORDINATES, 3, GL_FLOAT, 0, 10, group->uvcoordinates.data);
glEnableVertexAttribArray(ATTRIB_UV_COORDINATES);

Each transmitted group pointer refers to an initial position in the general block of vertex data where this type of vertex begins:

group->vertices.data == data
group->uvcoordinates.data == &data[4]
group->normals.data == &data[7]

, , - . (: . , .) , GL , 3 , , . , ( , ), , GL. ? , GPU/ ?

+3
1

OpenGL - API, . : , glDrawArrays glDrawElements - . .

, . .

Vertex , OpenGL, .

+3

All Articles