Sign in to follow this  
Coleco

texture question

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this