Jump to content
  • Advertisement
Sign in to follow this  
LemonLime

Obtaining the dimensions of a texture in memory...

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

Hi, I am loading a non-POW2 image onto a POW2-only GFX card using D3DXCreateTextureFromFileEx(). The funtion does not fail, but creates a POW2 texture of a size that contains the image. My problem is that I cannot get the height or width of the created texture. I have tried D3DXCheckTextureRequirements(), but it seems to return the same values that I put (not the corrected values, which it says in the help it will return). I am using the Summer 2003 update of DX9. Is there a bug in the D3DXCheckTextureRequirements() function, or am I going about this the wrong way? Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
You should be able to call the function GetLevelDesc() on the texture that is created. This will give you (among other things) the width and height of whatever surface level you specify. You'll want surface level 0 in this case.

LPDIRECT3DTEXTURE9 pTexture;
D3DSURFACE_DESC SurfaceDesc;
D3DXCreateTextureFromFileEx(..., &pTexture);
pTexture->GetLevelDesc(0, &SurfaceDesc);
std::cout << SurfaceDesc.Width << " x " << SurfaceDesc.Height << std::endl;

Share this post


Link to post
Share on other sites
Be careful with that - I've tried that method before, and gotten inaccurate results. I use a wrapper class for textures that stores their dimensions, which is in Managed DirectX a good idea anyway since it makes it easy to handle device loss (ie. if your window loses focus) without using Device.IsUsingEventHandlers=true, which causes loads of trouble.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!