Eric van Feggelen

Hello all,

I've been doing some standard 3d stuff with XNA, and I found an odd problem of some sort. Whenever I draw 2d sprites after my 3d rendering code, the model I am loading seems to be displayed in the wrong order. I've been using one of the spacewar ships like the documentation suggests. And I'm using the Font class (spacewar) to draw the sprites.

  1. I have removed alphablending for the sprites, no luck
  2. Changed the drawing order (before and after the 3d scene)

Still can't figure out the problem though, any of you know Thanks!



Re: XNA Framework ModelMesh / BasicEffect rendering order

Rim van Wersch

Rendering sprites also disables the depth buffer, so this might be the reason your mesh looks wrong. The easiest solution is to tell the spritebatch to preserve the render states, using the appropriate flag when calling sprite.Begin. This may not be the most efficient option, but it can save you a lot of headaches. Another option is to manually re-set the render states before you draw your 3D mesh. For more information check Shawn's blog:

http://blogs.msdn.com/shawnhar/archive/2006/11/13/spritebatch-and-renderstates.aspx






Re: XNA Framework ModelMesh / BasicEffect rendering order

Eric van Feggelen

Thanks .. this is exactly what I needed. Good find!