Jump to content
  • Advertisement


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


ID3DXSprite::Draw changed?

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

Okay, I wrote a 2d engine a while back on directx 8 and had everything I wanted in it. I loved all the new functionality that direct3d provided for sprites. Anyway, I put the engine away for awhile and just recently I got the urge to do something with it again. I downloaded the directx 9 sdk summer updated version and installed it. I got out my engine and compiled. Much to my surprise, 4 errors. One error for each version of my sprite draw function. I checked the sdk documents under "converting to directx 9" and found no mention about a change to the ID3DXSprite::Draw() function. I did a search for it and found out they did change it. It is now...
D3DCOLOR Color);
Instead of..
CONST D3DXVECTOR2* pRotationCenter,
FLOAT Rotation,
CONST D3DVECTOR2* pTranslation,
D3DCOLOR Color);
Now, I had no problem changing the number of parameters and converting to D3DXVECTOR3 but what I want to know is where the heck did the rotation parameter go? How am I supposed to rotate my sprites? I checked the ID3DXSprite interface and saw nothing. Am I not seeing something? I''m confused and would be glad to get this cleared up. Thanks.

Share this post

Link to post
Share on other sites
Look up ID3DXSprite::SetTransform . You have to call it before every sprite you render. Compose a matrix with translation, scaling and rotation (around Z axis).

I noticed that the "center" parameter doesn''t do anything. That is to say I passed in bogus values like -42464,767765 and it would not affect rendering. The "position" is actually the anchor you want to rotate the sprite around. It''s in negative numbers though, for example for a 64x64 sprite you would pass in (-32,-32) to rotate it around its center.

Share this post

Link to post
Share on other sites
Thank you very much foofightr.
You definately set me in the right direction. I browsed a bit more through the documentation and found a handy dandy function that pretty much does everything the old Draw function did.


I basically created two D3DXMATRIX instances, one for the current transformation state and one for the new transformation.
I called ID3DXSprite::GetTransform() and passed it the matrix instance for the current transform. Then I called D3DXMatrixTransformation2D() and passed it the new matrix transform. I simply filled it out with all the data i needed using traditional 2d vectors. Then after calling draw, I just SetTransform() the old one back allowing me to call Draw() using my other drawbitmap functions without messing with rotation. Also, I can do scaling with the same function like the old DirectX8 sprite draw() as a bonus. I believe microsoft should have really mentioned this in the changes and give a brief explanation of how to get the same functionality (ie Create matrix, then SetTransform()). Oh well, I hope this helps someone else who had the same problem.

Oh yeah, a code visual...

D3DXMATRIX rotmatrix, oldmatrix;



Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!