views:

32

answers:

1

I don't see a RenderState as a member in the GraphicsDevice class, which is where the functions for disabling the depth buffer used to be. Anyone know how this is done with this new 4.0 API?

It would be great if I could somehow access a full RenderState-like class somewhere.. GraphicsDevice seems to have gotten some of it, but not nearly all!

Thanks!

A: 

Ah.. I would be setting GraphicsDevice.DepthStencilState to an instance of DepthStencilState with any number of properties set. Seems like the RenderState was broken into a bunch of other states. I was looking for in the individual properties inside of GraphicsDevice before, but they seem to be better organized now for easier state management.

depthState = new DepthStencilState();
depthState.DepthBufferEnable = true; /* Enable the depth buffer */
depthState.DepthBufferWriteEnable = true; /* When drawing to the screen, write to the depth buffer */

GraphicsDevice.DepthStencilState = depthState;
Kyle
Yes. But make sure you create state objects once (not in your draw method). Read Shawn for details http://blogs.msdn.com/b/shawnhar/archive/2010/04/02/state-objects-in-xna-game-studio-4-0.aspx.
Empyrean