[quote=“Ecumene,post:4,topic:53109”]
you mean, tex-coords like x and xy and xyz and probably xyzw ?
[quote=“Ecumene,post:4,topic:53109”]
i mean, when you setup a array-buffer (vertices) you can just copy all unique vertices as provided by the .obj file. thats pretty good. then when you continue with the element-array-buffer (indices) and again you can just reuse all the face definitions (f v//…) as they come in, but everything else (normals, tex-coords) are unique by the format but there is no way to pass a end element-array-buffer (afaik) which points into a array-buffer of normals.
so by copy i mean… for each attribute (normals, tex-coords) you need to create a array-buffer, same size as the vertex-buffer (regardless of how many unique-attribute-values you have) and copy the attribute-values into the same position (not byte-position but array-index) as the face-vertex. even if you have a flat square made of lots of vertices/faces, you only have one normal - which needs to be copied into the normal-buffer for every freaking vertex. which is a waste of memory. sorry, i’m not too good with teaching ;).
you need to gather all values first, pack them nicely into “face” objects, get organised, and then build a couple VBOs which work with the draw-method of your choice. a 1 to 1 translation from .obj (probably any format) to opengl is not really possible.
–
i found this a while ago : https://github.com/g-truc/ogl-samples/blob/master/tests/gl-430-draw-without-vertex-attrib.cpp
it’s a very interesting approach. they do not use any attributes at all, just toss the whole mesh, all unique vertices, normals, coords, whatnots (faces, edges) into a huge SSBO. using a custom geometry shader to access the SSBO and pass out attributs to the vertex shader on the fly. no VBO used at all.
pretty much an extension to drawElements by adding more element-arrays. i dont think drawing that way is faster but for sure it’s one of the most memory-saving ways. still gotta try it out tho’ 