I'm currently working on a 2D-game that mainly uses D3DX sprites to render bitmaps on teh screen. Unfortunately, a special feature requires the use of textured primitives (TriangleList).
When i now render this TriangleList, it's hidden behind any sprite on the screen.

Is there an easy way to assign some kind of priority to the primitives / vertices, so that it is possible to draw them in front of certain sprites, but behind others
If not, what else am I supposed to do

I'd appreciate your help!


Re: Game Technologies: Graphics Easy way to render primitives in front of D3DX Sprites?

Jack Hoxley

Use of the depth-buffer is what you want. I'd imagine that, by default, ID3DXSprite renders to Z=0 which is closest to the camera. If you transform the vertices (ID3DXSprite::SetTransform()) so that they render at Z=1 then other geometry will be able to render in front of them.

Another possibility is to disable Z-writing whilst drawing your sprites and then re-enable it when you draw your real 3D geometry. In a similar way, you could just clear the depth buffer once you've drawn all your sprites so that you start fresh...