there arent any
the “key word” is “indexed drawing” / “indexed rendering”
there is no magic, consider the info you give GL:
glDrawElements(mode, count, type, indices);
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glDrawElements.xhtml
– mode: like in “usual” rendering, tells GL how to assemble vertices to primitives
– cout: like in “usual” rendering, tells GL how many vertices to process
– type: unlike in “usual” rendering, tells GL the data type of the indices in the element buffer
(either GL_UNSIGNED_BYTE (1Byte), GL_UNSIGNED_SHORT (2Bytes) or GL_UNSIGNED_INT (4Bytes))
– indices: unlike in “usual” rendering, tells GL the offset in the element buffer in bytes, divide that number by the size of 1 element index (either 1, 2 or 4) and you’ll get the offset in vertices
instead of giving GL a range of vertices to process, you giv GL an element buffer and arange in that buffer, GL then draws indices from it, looks up the vertex data at this array index and processes that vertex
downside: ? maybe the use of an additional buffer you have to manage
upside: a (small ?) performance boost, maybe (a little ?) less memory
https://www.khronos.org/opengl/wiki/Post_Transform_Cache
the post-transform cache stores processed vertices, and will prevent processing 2 same vertices twice, to identify processed vertices it only compares gl_VertexID and gl_InstanceID, if these match, it’ll skip that vertex and look up the result in the cache
regarding .obj file format:
you’ll get different indices for position / texcoord / normal, but GL allows only to use 1 element buffer, not 3, so you have to rebuild that obj vertex array anyway
you have:
vec3 obj_positions[MAX1];
vec2 obj_texcoords[MAX2];
vec3 obj_normals[MAX3];
you goal is to have 2 arrays, 1 of type “Vertex” and anothe of type unsigned int (faces)
struct Vertex {
vec3 Position;
vec2 TexCoord;
vec3 Normal;
};
you have to make use of <map>s to re-sort the vertex data efficiently