XNA 4.0 Change GraphicsDevice Default DepthStencilState Values

146 views Asked by At

I want to change one of the deafult values of my GraphicsDevice to that:

GraphicsDevice.DepthStencilState.DepthBufferEnable = true;

But, I only know how to change it at runtime in the Draw method by putting this code (which means changing the value every time the draw method is called!):

DepthStencilState state = new DepthStencilState();
state.DepthBufferEnable = true;
GraphicsDevice.DepthStencilState = state;

Does someone know how to change it once in an efficient way?

1

There are 1 answers

0
AudioBubble On

You can use this code anywhere the GraphicsDevice is available. I would put it in LoadContent() or Initalize().