Sign in to follow this  
chadsxe

So if D3DXCreateTextureFromFile loads images in by 2^x power, how the heck do you....

Recommended Posts

So if D3DXCreateTextureFromFile loads images in by 2^x power, how the heck do you load an image that is the full size of the current window (i.e. resolution). I am working with a resolution that is 800 x 600 and I wnat to load a .png that is that size. Obviously though it is getting stretch to the next power of 2. Any suggestions? Regards Chad EDIT: I don't mean FULLSCREEN [Edited by - chadsxe on May 9, 2007 9:18:29 AM]

Share this post


Link to post
Share on other sites
Use the Ex version of the function, and pass "D3DX_DEFAULT_NONPOW2" as the width and height. Some cards that you're not likely to run into will still require pow2 sizes.

Check the docs for D3DCAPS9 for "D3DPTEXTURECAPS_NONPOW2CONDITIONAL", as these restrictions apply to most cards.

Share this post


Link to post
Share on other sites
Another way is to just modify the source texture. Change your .png so that it has a bunch of "padding" on the right and bottom to make it a POT texture. Then in your program just treat it as an 800x600 texture and ignore the padding. It wastes memory, but ensures compatibility.

Share this post


Link to post
Share on other sites
Or just split the image into multiple 256x256 textures, and display them. That'll give you the best result IMO.

Share this post


Link to post
Share on other sites
Might as well go for the complete set of options. :)

You can also load with default width/height but filter set to D3DX_FILER_NONE. This will make a 1024x1024 texture, but only use the topleft 800x600 portion of it. You'll have a pow2 texture which contains your image, unstretched. The info structure you pass to the load call will contain the original size, while GetLevelDesc will return you the size created (pow2, maybe square, depending on hardware limits)

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