views:

1263

answers:

2

Multiple places reccomend using a texture atlas for performance. Apple suggest the function gltexcoordpointer. In my example I have a row of squares each one is given a random texure. I put all the random textures into the super-texture. Now the problem is I can't seem to create a texcoordarray. I can't find any information on how gltexcoordpointer assings the selected sub-texture to the vertext coords. The vertexes would idealy be drawn using triangle_strip, but triangles will work as well.

A: 

gltexcoorpointer assigns a the texture coordinate on a 1-1 basis. So I had to draw as triangles and have many vertexes repeated. The reason I couldn't share a vertex is because the shared vertex have the same texture coord.

A: 

You have to use the glTexCoordPointer if you want to render textures at all, compressed or otherwise, I think. But if you want to shift around your texture within its UV coordinate system, you are perfectly free to manipulate the individual entries in the texture coordinate array at any time. I use functions like these:

- (void) shiftTextureUVY:(float)shift {

  textureVertices[1] += shift;
  textureVertices[3] += shift;
  textureVertices[5] += shift;
  textureVertices[7] += shift;

}
- (void) shiftTextureUVX:(float)shift {

  textureVertices[0] += shift;
  textureVertices[2] += shift;
  textureVertices[4] += shift;
  textureVertices[6] += shift;

}

to make a basic TextureAtlas class, using GL_TRIANGLE_STRIP. You could get really funky with this and do reflections and distortions with similar methods, I suppose.

Alex Lowe