First, if you are displaying a single simple rotating cube with 6 textures and it's slow, maybe the problem is elsewhere. Of course, this depends on what phone you're using, but event on my G1, I can run this kind of rendering without problems. So maybe you should try to profile your code.
Anyway, to answer your question. A texture atlas is something like this :http://www.larabie.net/ogre/CombinedTextures.jpg
Basically it's a big texture that contains 4 (or whatever number you like) other textures. So you reduce the number of textures you have. Now, if you want to render a quad with the grass texture, the 4 vertices would have the following texture coordinates :
- Code: Select all
top-left : (0,1)
top-right: (0.5, 1);
bottom-right: (0.5, 0.5);
bottom-left: (0, 0.5);
So you're taking only a quarter of the actual texture, the quarter that correspond to the grass.
Ok, so that's the idea. Unfortunately, I don't have code to do that, but a search for "texture atlas opengl" on Google should make you happy.
You might want to look at this thread
which has some code.
Also, [url=http://developer.apple.com/library/ios/#samplecode/GLTextureAtlas/Listings/ReadMe_txt.html#//apple_ref/doc/uid/DTS40009014-ReadMe_txt-DontLinkElementID_11]here[/url] is an example for the iPhone (the ideas are the same).