glDrawElements and texturing

First of all, don’t hit me if this is in the wrong topic, but i figured it’s a clueless newbie error i’m having :stuck_out_tongue:

Anyway, I’m not very experienced in writing opengl. So the question is how would i go about applying a texture to a Wavefront .obj format model. The rendering part works (reimplemented the code from demo sources).
And yes, I know that ObjReader class doesn’t use the “vt” part of the fileformat, but since i need to render only cubes and such for now, i think i’d be able to use the same 8 textcoords every time, right?
So, here’s my problem: how do i apply the textures?
I mean if i render an object like this (pseudo code):


gl.glBindTexture(gl.GL_TEXTURE_2D, somekindofatextureID);
loop_through_all_triangles {
	gl.glBegin(GL.GL_TRIANGLES);
		gl.glNormal3f( 0.0f, 0.0f, 1.0f);
		render first vertex;
		render second vertex;
		render third vertex;
	gl.glEnd();
}

then everything works and the textures are in place.
How would i achieve the same when using glDrawElements to render the whole array of vertices at once?

Thanks :slight_smile:

lammas,

You specify the texture co-ordinates in an array (as well as the vertices, normals etc), using

gl.glTexCoordPointer