How to setup/calculate texturebuffer in glTexCoordPointer when importing from OBJ-file
Posted
by
JohnMurdoch
on Stack Overflow
See other posts from Stack Overflow
or by JohnMurdoch
Published on 2010-11-20T14:18:45Z
Indexed on
2011/01/13
9:53 UTC
Read the original article
Hit count: 272
Hi all,
I'm parsing an OBJ-file in Android and my goal is to render & display the object. Everything works fine except the correct texture mapping (importing the resource/image into opengl etc works fine).
I don't know how to populate the texture related data from the obj-file into an texturebuffer-object.
In the OBJ-file I've vt-lines:
vt 0.495011 0.389417
vt 0.500686 0.561346
and face-lines:
f 127/73/62 98/72/62 125/75/62
My draw-routine looks like (only relevant parts):
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY); gl.glEnableClientState(GL10.GL_NORMAL_ARRAY); gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, vertexBuffer);
gl.glNormalPointer(GL10.GL_FLOAT, 0, normalsBuffer);
gl.glTexCoordPointer(2, GL10.GL_SHORT, 0, t.getvtBuffer());
gl.glDrawElements(GL10.GL_TRIANGLES, t.getFacesCount(), GL10.GL_UNSIGNED_SHORT, t.getFaceBuffer());
Output of the counts of the OBJ-file:
Vertex-count: 1023
Vns-count: 1752
Vts-count: 524
/////////////////////////
Part 0
Material name:default
Number of faces:2037
Number of vnPointers:2037
Number of vtPointers:2037
Any advise is welcome.
© Stack Overflow or respective owner