I'm trying to implement terrain collision in XNA so I've added some dynamic text that allows me to test whether calculations are correct. Everything was rendered just fine until I called:

spriteBatch.Begin(); spriteBatch.End();

or

spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); spriteBatch.End();

With these instructions terrain glitches a little bit, when I remove these two lines from my code everything is back to normal (but it means I cannot draw HUD)

Anyone has any clue what can cause that and how should I fix it?

screens:

with sprite batch on

with sprite batch off

有帮助吗?

解决方案

it due to spritebatch change the graphicsdevice states...

before drawing the terrain you should store the right renderstates...

usually the you have to set the right RasterizerState and DepthStencilState.

Common values are RasterizarState.CullNone and DepthStencilState.Default

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top