XNA SpriteBatch causing problems with BasicEffect -
i'm using xna visualize data, , i'm trying use billboards data, , spritebatch hud text drawing.
for billboards, i'm using following example, works great: http://create.msdn.com/en-us/education/catalog/sample/3d_audio
in example, there cat , dog sprite, cat passes in front of or behind dog, depending on positions , camera position you'd expect. doesn't matter order cat.draw , dog.draw called in. these guys drawn basiceffect.
however if add class inherits drawablegamecomponent , uses spritebatch, basiceffect in other components loses it's depth sorting , quads drawn in order called. note component added game class via this.components.add(...).
is there incompatibility between basiceffect , spritebatch? problem occurs whenever spritebatch.begin()/end() called. if don't call cat/dog render fine.
any ideas?
you need reset renderstates spritebatch changes.
try setting these before basiceffect calls:
graphicsdevice.blendstate = blendstate.opaque; graphicsdevice.depthstencilstate = depthstencilstate.default;
more information render states spritebatch alters: http://blogs.msdn.com/b/shawnhar/archive/2010/06/18/spritebatch-and-renderstates-in-xna-game-studio-4-0.aspx
Comments
Post a Comment