Textured Quads vs. Sprites?

Started by
11 comments, last by GrasshopperDotNet 16 years, 6 months ago
is there a reason to use sprites considering a textured quad can seemingly do the same things?
--------------------------------------Not All Martyrs See Divinity, But At Least You Tried
Advertisement
Simplified syntax, encapsulation and reusability are just a few. You're strongly advised against reinventing the wheel. 'Textured quads' have their place in the world, but if a Sprite object is called for, use it.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Well you'd have to ask yourself what exactly you'd like to do with your textured quads, and then ask whether these things have already been done for your in the D3DX sprite interface. Perhaps you'd like to place them in screen coordinates, allow for alpha-blending, allow rotation and scaling, allow for portions of the texture to be drawn, and use some sort of batching mechanism for performance. Of course, these are all things ID3DXSprite does quite well and that you wouldn't have to waste time implementing yourself.
My understanding is the main difference of textured quads versus id3dxsprites is the fact that you can use lighting and shaders with the quads but not the sprite interface... right?
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
I used D3DX sprite in the past and it was extremely slow and limited. I don't recommend it at all, only for prototyping maybe.
I disagree about the speed of D3DX sprites, but only up to a point.

I did some extensive testing on quads verses sprite rendering speeds a while back. Quads out performed D3DX sprites when rendering low numbers of spites. On my machine (3.0 GHz Pentium 4, 1 Gig RAM, 6600GT GeForce NVid) that threshold was about 150 sprites.

However, D3DX sprites won hands down when 100's and 1000's of quads were rendered.

So if you only have to render a handful of quads (which is usually the case in say a GUI) then use quads. Your code will be more complex of course, and you'll lose out on the ease of use of sprites. But if speed is a must and you only have to render a handful of quads, then its best you did it yourself.

D3DX sprites performs a lot of setup behind the scenes (like saving and setting device states and batching geometric information) which is great for rendering huge amounts of data, but not so great for small amounts.
Quote:Original post by Terefere
I used D3DX sprite in the past and it was extremely slow and limited. I don't recommend it at all, only for prototyping maybe.

The D3DXSprite interface was overhauled back in '04, since then it's had extremely good performance. It performs automatic batching, too, so it has potential to be faster than a simple custom implementation.
NextWar: The Quest for Earth available now for Windows Phone 7.
I did a bit of tinkering around a while ago, trying to find out what ID3DXSprite does internally (When I was writing my own sprite manager). Here's my results
ID3DXSprite gives you pretty good performance, but it's quite easy to out perform it, particularly if you're doing specialised things. ID3DXSprite is just there to make life easy, it's not designed for extreme performance (Although it is fast enough to be useful).
Quote:Original post by freeworld
My understanding is the main difference of textured quads versus id3dxsprites is the fact that you can use lighting and shaders with the quads but not the sprite interface... right?


What about freeworld's point, is there a way to use shaders with ID3DXSprites?

Yes. Everything you can do with textured quads you can do with sprites. D3DXSprite is just an interface that uses the core Direct3D interfaces. There's nothing stopping you from modifying render states or applying shaders whilst using D3DXSprite.
NextWar: The Quest for Earth available now for Windows Phone 7.

This topic is closed to new replies.

Advertisement