Archived

This topic is now archived and is closed to further replies.

LordKaT

Texture dimensions?

Recommended Posts

Hey all, is it possible to get the dimensions of a texture (256x256, etc . . .) from the LPDIRECT3DTEXTURE8? --LordKaT

Share this post


Link to post
Share on other sites
Assuming a valid pointer to IDirect3DTexture9* called ptexture, you can use this:
D3DSURFACE_DESC desc;
pTexture->GetLevelDesc(0, &desc);

desc.Width, desc.Height, etc.

Share this post


Link to post
Share on other sites
Hmm, one addendum...

Be careful: There are times when you won''t be able to load a texture outright. Best example is that some cards can''t handle texture sizes above 256x256 pixels. Or those that can''t handle non-power-of-two sized textures...

You shouldn''t happen on this problem on a well-planned-for game, but if you''re making an utility for random ''textures'', well you might want to load the file in memory and get the texture size from there, BEFORE actually building the texture.

Or if you''d rather, load the file in a surface (not a texture) located in system memory (not on the video card) then you know that the hardware won''t limit your BMP sizes, I use this technique for full-screen images. (Creating several small textures from that memory surface, hehehe)

=^.^= Leaders and teachers should remember: It is best to offer others what they Need, not what they Want.

Share this post


Link to post
Share on other sites