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.
views:
1263answers:
2
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
2009-11-09 04:49:30