c++opengltexture-atlas

How I can create a texture atlas in OpenGL with other existing textures?


I will like to generate a texture atlas from some textures that are already loaded in memory.

The textures I will like to include in the atlas are generated procedurally on runtime so I can't just create a png tilemap that already contains them.

Is this possible to do with OpenGL?


Solution

  • Create a texture big enough with glTexImage2D and use glTexSubImage2D to put the 100 tiny square textures into it. glTexSubImage2D allows the specification of the x and y offsets in the target texture and the size (width and height) of a tile.