What's the best way to organize small textures in OpenGL—having them all in a big texture and selecting them with texture coordinates, or using individual OpenGL textures?
Until recently, I used to have all textures in a big pixmap and load that into a single texture. This worked well, but in some situations, I had bright pixels from a neighboring texture leak into the edges of a dark texture, so I decided to split the textures up and load them separately. However, since I now had to switch textures quite often, this significantly increased the frame render time.
So I have basically two options:
Go with one big texture and find a way to avoid pixel leakage.
Go with many small textures and try to avoid texture switches as much as possible (which will put some more load onto the CPU) or to speed them up significantly.
Do you have any suggestions how to achieve this?
Edit: I'm currently using the following texture parameters:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
As far as I can tell, these are already the optimal parameters for what I'm trying to do. However, if there is there anything which I can still improve, I'd be glad for a hint.