I’m currently working on a game and am having problems working out how to texture a triangle strip.
I have a cube created using a VBO and triangle strips. I was wondering how I would go about texturing this. Would you create a new buffer object, create an array/vector of texture points (which are loaded into the buffer) and then somehow apply those points to the texture to the cube?
I think you gonna need to create an array of texture coords (one for each vertex). But I can’t figure out a way to automate this for any geometry you wanna texture. If the cube was the only object I have, I’ll consider the use of a cube map.
I’ve created an array of texture coords but I can’t work out how to apply this and texture. The texture I’m loading is a .tga file and I think its loaded file as my load file routine doesn’t come up with any errors.
Then in my render class I try rendering the texture:
glVertexPointer(3, GL_FLOAT, 0, 0);
//Draw the triangles, we pass in the number of indices, the data type of the index array
// (GL_UNSIGNED_INT) and then the pointer to the start of the array
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 24);
//Finally disable the vertex array
The cube renders fine as a 3D cube in red. Just the texture isn’t applied.