ID3DXSprite scaling and rotation

Started by
9 comments, last by red_sodium 20 years, 1 month ago
Can ''ID3DXSprite''s be rotated or scaled, or should I use a textured quad and do it manually?
"Learn as though you would never be able to master it,
hold it as though you would be in fear of losing it" - Confucius
Advertisement
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.
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]
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
Stay Casual,KenDrunken Hyena
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.
"Learn as though you would never be able to master it,
hold it as though you would be in fear of losing it" - Confucius
Oh yeah, I forgot to ask, does ID3DXSprite support alpha blending as well as a colour key?
"Learn as though you would never be able to master it,
hold it as though you would be in fear of losing it" - Confucius
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
pass D3DXSPRITE_ALPHABLEND to the ID3DXSprite::Begin method
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.
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).
"Learn as though you would never be able to master it,
hold it as though you would be in fear of losing it" - Confucius

This topic is closed to new replies.

Advertisement