Jump to content
  • Advertisement
Sign in to follow this  
strattonbrazil

Restoring state after an XNA call

This topic is 2461 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!