OpenGL Texture Mapping - Texture Atlas

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

OpenGL Texture Mapping - Texture Atlas

Postby Girish » Thu Oct 07, 2010 6:56 am

Dear all,

I want to do rotating cube with 6 different images, i did it using traditional method of load,bind and render. But its too slow and performance is worst. I heard from the openGL experts that it can be done using texture atlast method and uv mapping. I am a newbie to openGL programming . Can any one explain how to do this,if you can share the code related to it it would be great.

Thanks in advance for the help.

Posts: 2
Joined: Fri Oct 01, 2010 10:31 am


Re: OpenGL Texture Mapping - Texture Atlas

Postby julienr » Sat Oct 16, 2010 4:11 pm

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 :

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=]here[/url] is an example for the iPhone (the ideas are the same).
Junior Developer
Junior Developer
Posts: 19
Joined: Fri Mar 12, 2010 4:05 pm


Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests