Texture Mapping Triangle Strip VBO?

Hi everyone,

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.

I create the buffer:

//Texture Setup
	glBindTexture(GL_TEXTURE_2D, texID);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture.getWidth(), texture.getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, texture.getImageData());

Then in my render class I try rendering the texture:

	glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
	glVertexPointer(3, GL_FLOAT, 0, 0);
	glBindBuffer(GL_TEXTURE_2D, texID);
	//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.

Textures are bound with glBindTexture, not glBindBuffer :).

Guess ShaderRookie found the problem. =)

Yeh thanks guys that and a few other things I’d done wrong!