Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Finding the Width of a DirectX 9 Texture

Posted on 2004-04-05
4
Medium Priority
?
1,100 Views
Last Modified: 2013-12-08
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...)
0
Comment
Question by:TimNyborg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Croow
ID: 10767309

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
0
 

Author Comment

by:TimNyborg
ID: 10770109
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
0
 

Author Comment

by:TimNyborg
ID: 10770145
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
0
 
LVL 1

Accepted Solution

by:
Croow earned 500 total points
ID: 10770451
Well then give this a try ...


      if(SUCCEEDED(D3DXCreateTextureFromFile(pDevice,pSrcFile,&pTexture)))
            bTexLoaded = true;

       D3DXIMAGE_INFO info;
       hr = D3DXGetImageInfoFromFile(pSrcFile,&info);

       int width = info.Width;
       int height = info.Height;
0

Featured Post

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question