1

Closed

Disable enable z buffer using commonstate

description

is this is the correct way to disable and enable the z buffer before rendering the skydome?
m_Graphics.getContext()->OMSetDepthStencilState(states.DepthNone(), 0);
    m_shape->Draw(sphereWorld,m_Camera.ViewMatrix(), m_Camera.ProjectionMatrix(), Colors::White, m_texture.Get());
    m_Graphics.getContext()->OMSetDepthStencilState(states.DepthDefault(),0);
Closed Sep 15, 2016 at 6:59 AM by walbourn

comments

ShawnHargreaves wrote May 16, 2016 at 3:49 PM

That won't work, because GeometricPrimitive::Draw overrides all previous device context state (see https://github.com/Microsoft/DirectXTK/blob/master/Src/GeometricPrimitive.cpp#L225)

Instead you should call OMSetDepthStencilState from inside the setCustomState callback, which is passed to the Draw method. See the Advanced drawing section of https://github.com/Microsoft/DirectXTK/wiki/GeometricPrimitive for an example of how to use that.