Advertisement

2D images in textures

Started by September 09, 2002 07:28 AM
4 comments, last by c4ctusal 22 years, 5 months ago
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 ?
C4ctusAlWhat about some trouble ?
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.
Advertisement
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).
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.
You should never let your fears become the boundaries of your dreams.
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.
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 ?
C4ctusAlWhat about some trouble ?

This topic is closed to new replies.

Advertisement