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?


1 Answer 1


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

GraphicsDevice.DepthStencilState = DepthStencilState.Default;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .