   How to texture an object
  Hi!I have managed load an OBJ file and draw the object on the screen.My next problem is to make the texture stick to the object.Looking at the OBJ file you have as an examplev 0.004520 0.000000 -0.363459... etcvt 0.000000 1.000000... etcvn 0.000000 -1.000000 0.000000... etcf 1/1/1 2/1/1 3/1/1... etcI have placed all vertices in one array. Lets say " vertices[]"All textures in "textures[]", all normals in "normals[]" and all the faces(indices) in "indices[]". What ends up in indices[] are all the firstnumbers in every section. In the above example it would be; 1,2,3.The middle one is for textures and the last one for normals. How do I add them and use them to draw with glDrawElements ???when I want to draw the object I use.glVertexPointer(3, GL_FLOAT, 0, vertices);glTexCoordPointer(2,GL_FLOAT,0,textures);glNormalPointer(GL_FLOAT,0,pMesh->m_aNormalArray);glDrawElements(GL_TRIANGLES,numberVertices,GL_UNSIGNED_SHORT,indices);I have enabled to use the arrays with glEnableClientState.My question here is how to I tell OpenGL to draw the texture with the faces position from the OBJ file??Thanks   
  I am a bit confused - are you trying to choose which texture image is used for which vertex?  THis is not possible in OGL b/c the normals and uv coords correspond directly to vertices.The way the fixed function pipeline works is that a given triangle (formed by three vertices) is rasterized using the currently bound texture.  You can't use two different textures on the same triangle without writing your own shader to combine them.   ;  The index array doesn't know or care about texture coordinates or normal vectors or vertex positions.  All it cares about is vertex indexes, ie the integer number that uniquely identifies a vertex.  I'm fairly confident that OpenGL indexes can only index vertices as a whole.  You can't index positions and textures and normals individually.As such, you'll probably be best off duplicating the data, for example create a Vertex struct with position, normal and texture components and when you load the OBJ file, fill out the Vertex structure appropriately.  The index array will then have to index elements of the Vertex array, which should contain texture and normal elements.Here is a pretty good summary of what you should be doing.;  SAMITH: That was exactly my question. So I have to duplicate som values so every vertex has a normal and a texture value.I guess that I have to look at the face values from the OBJ file to know which texture values correspond to what vertex ??Maybe there is a way of calculating this ?;  Yes you'd have to look at the face values.I assume OBJ indices are one-based so f 1/1/1 2/1/1 3/1/1 would translate to vertex 1: pos[0]/tex[0]/norm[0], vertex 2: pos[1]/tex[0]/norm[0], vertex 3: pos[2]/tex[0]/norm[0].So basically you'd just create a new vertex structure, look up the corresponding position, texture coordinates and normal and fill them into the vertex.   