Jump to content
  • Advertisement
Sign in to follow this  
Mike Bossy

Power of 2, but square as well?

This topic is 4339 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

Quick question with probably a quick answer: Q: Graphics cards like textures to be a size that is a power of 2 (ie. 256, 512, etc.). But does that mean it needs to be a square texture or can I have a rectangular texture where both X and Y are a power of 2 (ie. 512x256, 1024x512, etc.)? A: ??

Share this post


Link to post
Share on other sites
Advertisement
Dimensions must be a power of two (well, not on modern cards, but its a good idea to stick with that), but the width does not have to equal the height.

Share this post


Link to post
Share on other sites
Don't know about what Direct3D says, but would be surprised if it's anything different than OpenGL. OpenGL though is perfectly fine with non-square textures.

Share this post


Link to post
Share on other sites
OpenGL is ok with non-square textures. first of all i must say i don't use or support Direct3D but most of the time i saw non power of 2 textures used in Direct3D. like 640 * 480 textures. I don't know how do they use them. Maybe there's a sprite class that can mess with directly blitting of the sprites. so that non power of textures can work fast. so i'm just asking is it possible to use non-power-of 2 textures with Direct3D?

Share this post


Link to post
Share on other sites
Quote:

like 640 * 480 textures. I don't know how do they use them. Maybe there's a sprite class that can mess with directly blitting of the sprites. so that non power of textures can work fast. so i'm just asking is it possible to use non-power-of 2 textures with Direct3D?


yes it is possible but the texture is converted to a larger texture with pow2 dimension. So it's rather pointless to use non pow2 texures.

Share this post


Link to post
Share on other sites
There is a caps bit (D3DPTEXTURECAPS_SQUAREONLY) in D3D to check if you require square textures. Unles you are aiming at old cards for casual games, you can get away with ignoring the check and using non square textures.

D3D has two varieties of usage of non pow2 textures.

Most cards (even old DX7 and maybe earlier) support non-pow2-conditional (D3DPTEXTURECAPS_NONPOW2CONDITIONAL). That means you can use a 640x480 texture if you use clamp, don't set D3DRS_WRAPn, don't mip map (use MAGFILTER only), and avoid DXT1-5, cannot be used as a texture fetched by texbem, texm3x3, etc.

The second type, is full support of non pow2 textures. Few cards support this.

NonPow2Conditional is great for title screens. There may be performance costs with using nonpow2 textures, so they aren't recommended for other items drawn 1:1, such as 2D sprites, tiles, fonts, etc.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!