Texture atlas for objects with shared vertexes.

Basically I need to optimise my code allot. I’m trying to use a single super texture with all my textures in it and just one draw call. For simplicity the problem comes down to this. I have 3 squares squares in a row that are connected. There are 8 vertexes, 4 of which are shared, triangle_strip seems the best method to draw them but I could just use triangles. The super texture is just a square split into 4 squares. I want to assign the squares a texture at random.

From what I’ve read gltexcoordpointer assigns the tex coords to the vertex points, so it’s not possible do what I want due to the shared vertexes? This seems wrong since I see people talking about using texture atlases everywhere.

I guess my question is equivalent to how to draw a cube with a different texture on each side using a single texture file. (the choice of the texture on each side is chosen at runtime).

Hi;

I need to do that exactly…to implement a atlas routine for better performance. But How I do that ?

If you have discontinuities in your texture coordinates, you need to duplicate vertices. In other words, you need 12 unshared vertices.

Like Xmas said, you need to duplicate vertexes. Your vertex array has a 1-1 map to the coord array. So You will need to have the same point in the array multiple times. This means you can’t use triangle_strip, you need to use triangles to draw as well.