Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm making a 2D game with OpenGL. In order to avoid changing the state machine and binding at runtime, I want to make consolidate my textures into bigger textures,

for example, taking 4 128x128 textures and making 1 big 512x512. I could then just render part of the texture rather than binding a new one.

Is this a good idea? Could my newly created texture get lost, or are there major faults in doing this?

Thanks

share|improve this question
    
it really depends on the case you are using, for example to create a tilemap, it's much more efficient to use single texture from begining. or character animations are usually stored as spreadsheet. –  Ali.S Jun 11 '11 at 4:32
3  
Did you identify this as a major performance problem in your project? If not, then this falls into the category premature optimizations and that in fact is a major fault. –  Maik Semder Jun 11 '11 at 9:06

1 Answer 1

Yes, in general, to it being a good idea. OpenGL generally has transparent loss mechanisms, that is, if a texture is lost, you won't notice it.

The idea of making multiple textures into one large texture has been explored. This is called "Texture Atlasing". There are faults with it if you try to make an atlas that is greater than the maximum texture size of the graphics card (which on modern cards is quite large, 8Kx8K or so).

There are pathological cases where texture atlasing will not improve performance, but with discrete graphics cards offering >> 512MB of video memory on low end cards, I don't think you'll run into any of these type problems. I wouldn't concern yourself too much with performance optimizations if you are developing for the desktop systems until it is clear that they are needed -- and what an epic title it must be then! ;)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.