Link to home
Start Free TrialLog in
Avatar of TimNyborg
TimNyborg

asked on

Finding the Width of a DirectX 9 Texture

I've written a graphics engine for a 2d game using the DirectX 9 'Sprite' system.
I simply need to know how to find the widths of strangely dimensioned textures during runtime (eg 80x60, 400x120, etc...)
Avatar of Croow
Croow


It sounds like you can solve this with the GetLevelDesc method.

LPDIRECT3DTEXTURE9 pTexture;

      D3DSURFACE_DESC desc;
      pTexture->GetLevelDesc(0,&desc);
      int width = desc.Width;
      int height = desc.Height;


The D3DSURFACE_DESC structure has a lot of other members, but I doubt they'd be very helpful to you.

Good luck
Avatar of TimNyborg

ASKER

I've tried that method, but level 0's width and height are converted to powers of 2, equal to or greater than the original dimensions

ie 40x80 becomes 64x128
Is there
whoops

*Is there a way to keep the original size? As far as I can tell, the textures are being expanded to meet 2^n sizes, but that doesn't matter when you go to draw them as sprites, because the extra area is transparent

I just need to find the centers of the actual original image so I can place image on top
ASKER CERTIFIED SOLUTION
Avatar of Croow
Croow

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial