I'm making a program that given an obj file, it renders the model. For now it works without texture mapping, but i want to implement this capability, reading the material library file.
But i see that the number of vertices can be different from the number of texture coordinates. Look this example:
# Blender v2.58 (sub 0) OBJ File: ''
# www.blender.org
mtllib /home/frenk/Documenti/Progetti/dado.mtl
o Cube
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vt 0.593772 0.740196
vt 0.593666 0.869263
vt 0.394866 0.869219
vt 0.394973 0.740152
vt 0.792572 0.740240
vt 0.993810 0.740284
vt 0.993703 0.869351
vt 0.792466 0.869307
vt 0.792360 0.995233
vt 0.593560 0.995189
vt 0.593984 0.482061
vt 0.792784 0.482105
vt 0.792678 0.611172
vt 0.593878 0.611129
usemtl dado_verde_dado.tga
s off
f 1/1 2/2 3/3 4/4
f 5/5 8/6 7/7 6/8
f 1/1 5/5 6/8 2/2
f 2/2 6/8 7/9 3/10
f 3/11 7/12 8/13 4/14
f 5/5 1/1 4/14 8/13
So i can't use the function drawElements(), because indices doesn't match. Have i do to map vertices coordinates to texture coordinates, one to one?
//example
glBegin( GLTriangles );
gltexcoord2f(...); glvertex3f(...);
...
blaBlaBla(...);
...
glEnd();
I think that an efficient API must exist for doing what i want.