texture question

Started by
3 comments, last by Coleco 19 years, 7 months ago
Ok, I know that 256x256 is the preferred texture size and I should use the power of "2"..blah...blah...blah...lol In the old days, when you draw sprites, it was more efficient to make sure the sprite size was in multiples of 16 (or even 8) pixels. For example, a sprite 32x32 was faster than a sprite of 34x32. Ok, here is my question. If my texture size is 256x256 and I am doing 2D drawing by grabbing sections of that texture, when I place my sprite on the screen, does the same "multiple of 16" rule still apply? For example, my texture may have a small sprite that is 20x15 pixels. Do I have to make sure there is empty space around that sprite and make sure it is 32x32? Or, as long as my texture is a power or two, can I grab sprites from anywhere on the texture and not worry about performance? Hope I am explaining this correctly. Thanks
Rock the cradle of love! You stupid WANKER!
Advertisement
If you're using OpenGL, there is an extension which relaxes the non-power of two limitation. The limitation is because of the way mipmapping occurs. Some of my non-power of 2 images show up fine anyways (if you read the man page on gluBuild2DMipMaps it says non-power of 2 images are scaled to be powers of 2 at first). I guess it just depends. If you want to be sure a non-power of 2 image works, then just use the extension. Otherwise, pad it out to a power of 2, just to be careful.
Your texture *should* be a power of two, but does not have to be. DirectX will re-size your image for you. So be careful. A 1025x1024 image will re-size to 2048x2048

If you have multiple sprites on one texture, it does not matter in the least bit what size they are. All that matters is the texture size.
Since this is the DirectX forum, I would image that's what he is using.

At any rate the PowerOf2 limitation is in hardware so regardless of API it depends on the card. If you want to run reliably on many cards without special case code, use Powers of 2.

You should be able to grab them from anywhere without worry. I've never noticed any performance hit, so if there is one it's pretty insignificant.
Stay Casual,KenDrunken Hyena
Quote:If you have multiple sprites on one texture, it does not matter in the least bit what size they are. All that matters is the texture size


Quote:You should be able to grab them from anywhere without worry. I've never noticed any performance hit, so if there is one it's pretty insignificant.


Thanks guys...that is what I was actually looking for. I know about the power of 2 of the texture size...I was just wondering about limitations of drawing a piece of the texture
Rock the cradle of love! You stupid WANKER!

This topic is closed to new replies.

Advertisement