D3DXCreateTextureFromFileEx with D3DX_DEFAULT in Width and Height cause problem...?

Started by
1 comment, last by Evil Steve 17 years, 11 months ago
I find someone say that texture created using D3DXCreateTextureFromFileEx with D3DX_DEFAULT in Width and Height field will cause problem when use the texture with ID3DXSprite, is it true? If it's true, what about D3DXCreateTextureFromFile(without "Ex")? And what about D3DXCreateVolumeTextureFromResource and D3DXCreateVolumeTextureFromResourceEx? THANKS!
Advertisement

Read the description of the function from

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/D3DXCreateTextureFromFileEx.asp

As far as I understand, using non-power-of-two texture file might cause some head ache, but nobody uses them right ?

Otherwise, textures created with this function should be as good as any other texture.

You could actually try it by yourself. if you find some problems, you can tell us about them.
The "Ex" versions of the function allow you to get a D3DXIMAGE_INFO structure back, which tells you the size of the actual source image. You can then get the surface description for the top level of the texture to tell how large D3DX created it.
Often if you try to load a non-power of 2 texture, D3DX will create a texture surface that is the next power of 2 size up, and load the image into the top left corner.
Example: If you load a 200x200 image, D3DX will probably allocate a 256x256 texture. The D3DXIMAGE_INFO will tell you that the image was 200x200, and getting the level 0 surface description will tell you the texture is 256x256. That allows you to adjust the RECT you pass to ID3DXSprite::Draw so you don't include the unused parts of your texture.

This topic is closed to new replies.

Advertisement