Timeline for MonoGame SetRenderTarget is wiping the backbuffer
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 1, 2015 at 7:01 | comment | added | James Carlyle-Clarke |
Thanks Andrew, that solved it. To clarify, I put graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(SetToPreserve); in my game creation function MyGame(), and then added the function void SetToPreserve(object sender, PreparingDeviceSettingsEventArgs eventargs) { eventargs.GraphicsDeviceInformation.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents; } - that did exactly what I was after. You are the man, many thanks.
|
|
Jan 1, 2015 at 7:01 | vote | accept | James Carlyle-Clarke | ||
Jan 1, 2015 at 2:31 | comment | added | Andrew Russell |
@James No worries. Regarding your second comment there: You have to set PreserveContents on the backbuffer to avoid the clear of the backbuffer during SetRenderTarget(null) . The code you have there only avoids the clear of the render target when you call SetRenderTarget(renderTarget) .
|
|
Dec 31, 2014 at 7:03 | comment | added | James Carlyle-Clarke | Oh, and thanks for clearing up that this is the expected behaviour - it was driving me crazy thinking I was missing something in all of this! | |
Dec 31, 2014 at 5:24 | comment | added | James Carlyle-Clarke |
I tried modifying my RenderTarget creation to renderTarget = new RenderTarget2D(graphicsDevice, 200, 200, false, graphicsDevice.PresentationParameters.BackBufferFormat, graphicsDevice.PresentationParameters.DepthStencilFormat, graphics.PresentationParameters.MultiSampleCount, RenderTargetUsage.PreserveContents); and I still get the backbuffer wiped. Any thoughts?
|
|
Dec 31, 2014 at 5:22 | comment | added | James Carlyle-Clarke | Hi Andrew, thanks for the reply. I can quite see that ideally it's best to just shuffle the order of drawing to avoid this, and I will - but I would like to have the option to do it later in case I have the need in this or future projects (I'm making a personal library and this could come up again). | |
Dec 29, 2014 at 6:29 | history | answered | Andrew Russell | CC BY-SA 3.0 |