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

Started by
3 comments, last by Namethatnobodyelsetook 16 years, 11 months ago
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]
Advertisement
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.
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.
NextWar: The Quest for Earth available now for Windows Phone 7.
Or just split the image into multiple 256x256 textures, and display them. That'll give you the best result IMO.
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)

This topic is closed to new replies.

Advertisement