Jump to content
  • Advertisement

Archived

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

c4ctusal

2D images in textures

This topic is 5820 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
Advertisement
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
DarkWing: you''re right except for the case of mipmapping. Though, mipmapping may not happend in a 2D engine, and that would not be a problem then.

Share this post


Link to post
Share on other sites
I have read all your posts and they all make sense and I will make a mix of all of these for my functions.


C4ctusAl

What about some trouble ?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!