Sign in to follow this  
Uphoreum

[DX] Get Texture Dimensions

Recommended Posts

I have an LPDIRECT3DTEXTURE9, and I need to grab it's dimensions. I'm looking through the public methods, but I don't see anything that looks like it will give me dimensions. I hope it's not something obvious that I missed. EDIT: It looks like I have to GetSurfaceLevel, then GetDesc on the surface from that, and then get the width and height from that. Is that the only way? It works but I have to use a lot of temporary variables.

Share this post


Link to post
Share on other sites
Quote:
Original post by Uphoreum
I'm looking through the public methods
Some are included with #define D3D_DEBUG_INFO, but don't rely on these - its an easy error to create [smile]

Quote:
Original post by Uphoreum
EDIT: It looks like I have to GetSurfaceLevel, then GetDesc on the surface from that, and then get the width and height from that. Is that the only way? It works but I have to use a lot of temporary variables.
Yup, thats pretty much it. The loading functions can return a D3DXIMAGE_INFO structure IIRC that can be a convenient way of retrieving information...

hth
Jack

Share this post


Link to post
Share on other sites
GetLevelDesc can get the description in one step, without getting the surface first, or having to release the surface afterwards.

The info returned from the loading functions describe the surface on disk, not the one in memory. If a texture is 60x100 grey scale (L8) on disk, it may be loaded as 64x128 X8R8G8B8. Depending on which information you want use the load info or the level descriptor. When loading non-pow2 textures, both come in useful. It's convenient to store both in your texture class.

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