Archived

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

red_sodium

ID3DXSprite scaling and rotation

Recommended Posts

yeah dont use any of the ID3DX classes, they are way too slow, and you dont learn anything when you just use their classes.
so yeah write your own, then you will have complete control over them.

Share this post


Link to post
Share on other sites
you can scale rotate and translate ID3DXSprite using the SetTransform method (that takes a transformation matrix) before calling draw.

I've found the D3DXSprite class in the summer update of DirectX 9 to be more than adequate for the windowing toolkit I'm making, plus it's been very easy to use. Just make sure you put all your draw commands within a call to begin and end.

If you're planning on mixing text and sprites you can actually use the D3DXFont class with D3DXSprite which uses all the batching that comes with D3DXSprite. Just watch out for the transform matrix as it took me ages to work out why all of my text was being translated to the wrong position.



Mrs Kensington http://www.mikeditum.co.uk

[edited by - mrs kensington on March 29, 2004 11:55:41 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by hlivingstone
yeah dont use any of the ID3DX classes, they are way too slow, and you dont learn anything when you just use their classes.
so yeah write your own, then you will have complete control over them.


Too slow for what? Have you actually used them?

Why use DirectX? You won''t learn anything if you use an API. So if you want to write a game you''re really better off writing your own operating system and graphics API, then you have complete control. Well, almost. I guess you''d have to design your own hardware too.

Alternately, if you just want to write a game, you can use the quality tools that are available (like D3DX) and get it done reasonably quickly.

Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
Hey, you''re that guy with all the tutorials...

Actually, I''ve noticed that kind of sarcasm surfaces fairly regularly If I can scale and rotate my sprite, then ID3DXSprite should be adequate. I''ll probably work more on vertices, textures, etc, when I move on to 3D.

Thanks for your input, everyone.

Share this post


Link to post
Share on other sites
quote:
Original post by red_sodium
Oh yeah, I forgot to ask, does ID3DXSprite support alpha blending as well as a colour key?


Yep it does! just pass D3DXSPRITE_ALPHABLEND in your begin call... as in like this...


sprite->Begin(D3DXSPRITE_ALPHABLEND);


The MSDN page for ID3DXSprite is here and is very useful.



Mrs Kensington http://www.mikeditum.co.uk

Share this post


Link to post
Share on other sites
quote:
Original post by red_sodium
Oh yeah, I forgot to ask, does ID3DXSprite support alpha blending as well as a colour key?


As others have said, use the alphablending flag.
DirectX 8 and 9 don''t do color keying, when you load a texture with D3DXCreateTextureFromFileEx you can specify a color key, it then creates an alpha channel in your texture. After that it uses alpha blending/testing, not the color key itself.

Share this post


Link to post
Share on other sites
Wow, that''s great. The reason I avoided D3DXSprite for so long was because I was under the impression, nay illusion, that it did not support any "3D" features (scaling, rotation, alphablending).

Share this post


Link to post
Share on other sites
quote:

Too slow for what? Have you actually used them?

Why use DirectX? You won''t learn anything if you use an API. So if you want to write a game you''re really better off writing your own operating system and graphics API, then you have complete control. Well, almost. I guess you''d have to design your own hardware too.

Alternately, if you just want to write a game, you can use the quality tools that are available (like D3DX) and get it done reasonably quickly.

Stay Casual,




You got that right. The summer update is quite fast. In fact, I wrote a tile demo using Blitz Basic (2d, directdraw, VERY FAST) and wrote the exact same thing using my "3D for 2D" engine (which uses ID3DXSprite) and it is actually FASTER. Not by much, like maybe 40 - 100 FPS faster but I couldn''t believe it.

cb

~ c o l ec o ~



Rock the cradle of love!
You stupid WANKER!
S i g n a l D E V .com
Metroid Classic

Share this post


Link to post
Share on other sites