Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Basically i am trying to render a model yet it seems to draw polygons that should be behind something, in front of it. So i end up seeing some faces that should be behind something, totally covering it. Bah, i suck at explaining so here's the pic:

My Problem

See the Railing? It should be at the front, but it's covered by the top of the platform. Also, on the side, the shadowed area should be practically hidden from that front wall... Other bits are around the place too if you just look at it... :(

I tried the 3 different cull modes, none of them fixed it, so i don't think its the culling (in fact Clockwise made it worse... :P). Thanks for any help.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

It looks like your depth buffer is not working. You should try something like:

device.RenderState.DepthBufferEnable = true;

I cant now test it, so this is just what I have googled. If it doesnt help, you can also try:

device.RenderState.DepthBufferFunction = CompareFunction.LessEqual;
device.RenderState.DepthBufferWriteEnable = true;
share|improve this answer
Ahhh thankyou, the first solution was correct, however your code is shown in 3.1, i was using 4.0 :P So yes, the code i used was: DepthStencilState depthStencilState; depthStencilState = new DepthStencilState(); depthStencilState.DepthBufferEnable = true; device.DepthStencilState = depthBufferState; –  Randomman159 Oct 12 '11 at 5:46
oh wow... that didn't come out in neat lines... :P hehe –  Randomman159 Oct 12 '11 at 5:46

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.