Restoring state after an XNA call

Started by
-1 comments, last by strattonbrazil 12 years, 1 month ago
I'm new to XNA and am wondering if there is some builtin workflow for restoring the graphics stack to a given state. For example, I noticed after a sprite render to my 3D scene, the 3D portion stopped working after calling SpriteBatch.begin() and had I had to fix it by
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

Is there something like a glPushAttrib()/glPopAttrib() to wrap this instead of just knowing what states the sprite engine changes that I have to change back?

My current issue is I'm playing with render targets and after creating one, I find my 3D portion of the render seems messed up after calling SetRenderTarget().

For example, if I were to call the following two functions, from what I understand of the documentation, setting the graphics device to null should reset everything.
GraphicsDevice.SetRenderTarget(target);
GraphicsDevice.SetRenderTarget(null);

Commenting out the first line above keeps the 3D render correct, so I'm assuming some state much change on that call. Are these state changes documented somewhere by call or is there a way to save the state explicitly and restore it when finished doing some operation?

This topic is closed to new replies.

Advertisement