Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just added this:


to my app and was greatly confused by the fact that this causes pretty much everything else (all of my 3D objects, that is) to be drawn incorrectly. After the code above has executed, no Z-buffering seems to take place, but instead objects are just drawn in the exace same order as I send them to the scene - with the last object drawn being fully visible even while it is located behing other objects. It also screwes up the sampler state for my textures (which I can fix by setting a new SamplerState for the device).

What is going on and how do I fix it?

share|improve this question
up vote 4 down vote accepted

This can disable depth buffer. You should enable it again. It should be enough to set DepthStencil state to default.

GraphicsDevice.DepthStencilState = DepthStencilState.Default;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.