Recently, I also came across this; I don't think this is a problem with flipping buffers. This should be the same in 3.1 and 4.0. I looked at GraphicsDevice using ILSpy and found out about this:
What has changed is that in 4.0, the current render target is first cleared in GraphicsDevice.Present () if a private flag is set. By default, this flag will be set initially (target rendering is clear). Drawing to the render target clears this flag (now the render target is dirty). After executing this function, GraphicsDevice.Present () sets the flag again (the rendering object has been "reset" to your window and is now considered clean again).
To get the results from GraphicsDevice.Present (), you will need to call Draw () and EndDraw () in strict order.
If you call EndDraw () without first calling Draw (), you will not get the contents of the rendering target (which is cleared), instead there will only be a purple screen.
Unfortunately, the flag is closed and there is no clean way to get to it. You can use reflection to clear a flag like this, making the render object dirty without drawing anything in it:
graphicsDevice.GetType (). GetField ("lazyClearFlags", BindingFlags.NonPublic | BindingFlags.Instance) .SetValue (graphicsDevice, 0);
(graphicsDevice is your current instance of GraphicsDevice)
Put the above line before calling EndDraw (), and the behavior will revert to what it was in 3.1
Pentti haka
source share