D3D Sprite class

Started by
2 comments, last by TheAdmiral 16 years, 5 months ago
Hi. Are there any advantages in using a textured quad as opposed to the sprite class in Direct3D? I've heard that there are limitations to using the sprite class.
Advertisement
I guess it all depends on what you intend to do with them.

The D3DXSprite is pretty much all you need to render "simple" quads to the screen, i.e. for your usual GUIs, widgets and fonts (which can be rendered by D3DXFont which wraps D3DXSprite).

D3DXSprite is pretty fast and efficient, as well as being simple to use. You CAN beat it if you're only rendering a small handful of quads, since D3DXSprite saves render states, batches sprites before rendering them all at once to the screen, and then restores the render state. However, for 100's, if not 1000's of sprites, D3DXSprite seems to have the edge. That's what I've found out anyway.

I have written my own sprite class which batches quads, similar to D3DXSprite. Since it doesn't do any render state changes, it's almost twice as fast as D3DXSprite when rendering small numbers of quads. However, D3DXSprite uses heavily optimised SSE code, which is probably why it's good at rendering larges numbers of quads to the screen.

Evil Steve's DruinkJournal gives a pretty good low down on what D3DXSprite does internally, and considering the huge amount of overhead D3DXSprite does behind the scenes, I'm surprised it's even efficient at all. But then it was designed by Microsoft boffins that seem to know what they're doing, for the most part anyway, but still, Evil Steve does give D3DXSprite justified criticisms and it was those criticisms that encouraged me to develop my own sprite manager.

Anyway, take a look at the following link, its pretty good.

http://www.gamedev.net/community/forums/mod/journal/journal.asp?jn=300672&reply_id=2716745

Despite having my own sprite manager though, I still find myself using D3DXSprite. It's not perfect, but it's fast and efficient enough for simple purposes. As for rendering fonts, I've stuck to my own font engine. I found D3DXFont just a tad bit too slow for my purposes.
Thank you very much, TerrorFLOP. Your reply and the link you provided were very insightful!

But still, if anybody was anything else to add, that'd be great too!
Some more discussion.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.

This topic is closed to new replies.

Advertisement