Archived

This topic is now archived and is closed to further replies.

2D images in textures

This topic is 5574 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello ! As everybody told me that drawPixels is slow in most cases and I want some 2D animation in my application, I would like to know more about using a texture. The texture size must be a power 2, but most images that I want to draw aren''t sized like this. Would it be better dividing the image in multiple textures or stretching it to fit and resize it after ? Thanks for helping me. C4ctusAl What about some trouble ?

Share this post


Link to post
Share on other sites
Depends what you want to use it for, if you want pixel-accurate representation of your images then of course split it across textures, if you don''t particularly care if it is a bit fuzzy (say it''s a background to a parallax scroller), scale it.

Share this post


Link to post
Share on other sites
If you don''t have memory problems, and if you don''t need to repeat the textures, then allocate a bigger texture.
For instance, if your sprite is 10x10, you can allocate a 16x16 texture and then copy into a 10x10 square with glTexSubImage2D (available since OpenGL1.1).

Share this post


Link to post
Share on other sites
or you can copy a bunch of these sprites into one big (512x512) texture with glTexSubImage2D like vincoof said. With this you minimize both : wasted space and texture bind calls.

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites