Jump to content
  • Advertisement
Sign in to follow this  
hanhan

Regarding id3dxsprite

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

Hi, I am not clear about ID3DXSprite. Why we need it? we can do anything without it, I think. I am not sure about the reason. Is the ID3DXSprite only used for drawing 2D image only? Is the ID3DXSprite more efficient and more easy for drawing 2D image? so we use it. How i use the ID3DXSprite to draw a line? Thanks in advance! Regards! hanhan

Share this post


Link to post
Share on other sites
Advertisement
Quote:
I am not clear about ID3DXSprite. Why we need it?

It's more efficient than rendering one quad at a time. It combines all of the geometry together into a single buffer and throws it onto the screen in chunks (I think it must at least seperate by textures).

Quote:
we can do anything without it, I think.

Yes, but to get the same performance, you would end up rewriting it.

Quote:
How i use the ID3DXSprite to draw a line?

If you absolutely must use ID3DXSprite to draw lines, you could just draw a single pixel while applying matrix transforms to the sprite interface to stretch and rotate it.

Share this post


Link to post
Share on other sites

Thanks very much!
That is to say that the ID3DXSprite is high level than the origin d3d?
It is most used in drawing 2D.
I am not sure how to use it, whould you like to give me some suggestions to learn it, such as web address.
Thanks!

Share this post


Link to post
Share on other sites
You can learn about the interface here http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/directx9_c_summer_03/directx/graphics/reference/d3dx/interfaces/id3dxsprite/_id3dxsprite.asp

And drawling line can be easily done in ID3DXLine.

Share this post


Link to post
Share on other sites
Quote:
Original post by Graham
You can learn about the interface here http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/directx9_c_summer_03/directx/graphics/reference/d3dx/interfaces/id3dxsprite/_id3dxsprite.asp

And drawling line can be easily done in ID3DXLine.


It is easy to understand ID3DXLine, it is high level than the origin d3d. we can rewrite it by ourselves.
But i am not clear about id3dxsprite?

Share this post


Link to post
Share on other sites
What is your intended goal? Do you want to use the ID3DXSprite interface or do you want to re-create your own interface that does everything that the ID3DXSprite does? I'm a bit confused with your questions. The SDK contains all of the information you should ever need once you understand the underlying concepts of D3DXSprite.

If you are just wanting to know how to use it, then there at least 914 (from Google) of those tutorials online. Google ID3DXSprite Tutorial for those.

Yes, ID3DX-Anything is "higher level". D3DX merely contains helper and wrapper classes only. It is not required to use Direct3D at all. Since it is written by Microsoft and since they control DirectX also, it is highly likely that much of D3DX functions and classes are highly optimized. Some of the optimization is free-knowledge (such as grouping quads together that use the same texture) and some is probably proprietary (such as embedding assembly to take advantage of something only Microsoft knows).

A simple example of the ID3DXSprite interface follows:


Sprite->Begin(D3DXSPRITE_SORT_TEXTURE);
Sprite->Draw(pTexture1, NULL, NULL, NULL, D3DCOLOR_ARGB(255, 255, 255, 255);
Sprite->Draw(pTexture2, NULL, NULL, D3DXVECTOR3(10,10,1), D3DCOLOR_ARGB(255, 0, 255, 0);
Sprite->Draw(pTexture1, NULL, NULL, D3DXVECTOR3(100,100,1), D3DCOLOR_ARGB(255, 0, 0, 255);
Sprite->End();




This tells the sprite to sort quads based on texture. So, two draws will be performed. Internally, the ID3DXSprite class will set the texture using the one you're familiar with (pD3DDevice->SetTexture(0, pTexture1)) and draw the first and third Draw calls above which will put the sprite at (0,0) and (100,100). Finally, the second texture pTexture2 is set. Then the second Draw call places the sprite at (10,10). Even though the End function is after the Draw calls, it is what forces the draws. The Draw calls can be seen as only buffering up the data. Sprite->Flush can be called to flush the draws into the video card before End is called if for instance you change a RenderState on your own between 2 Draw calls. That brings up a whole new subject.

See the MSDN at Microsoft MSDN.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!