Sign in to follow this  
zer0sum

How to Preserve Contents of Backbuffer when switiching RenderTarget2Ds

Recommended Posts

My problem is conceptually simple but I can't figure out how to implement the solution. I have read Hargreaves' blog on the topic.

I want to:

1. Draw some world screen to the BackBuffer
2. When start button pressed, display a menu over what's drawn on the screen.
3. I create a RenderTarget2D, set the device to the RenderTarget, and I draw the menu to the rendertarget.
4. I then Switch RenderTarget back to the device, and draw my menu.

Result:

Menu drawn perfectly, but backbuffer contents are cleared and cornflower blue.

Hargreaves says that what I have to do to PreserveContents on the backbuffer is:

Quote:
To change it for the backbuffer, use the GraphicsDeviceManager.PreparingDeviceSettings event to alter GraphicsDeviceInformation.PresentationParameters.RenderTargetUsage


So my questions is: what does that mean and how do I do it. I don't know much about event handling and I'm not sure how to set up the code to do it. Please help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this