GraphicsDevice.ResolveBackBuffer Method (Texture2D)
Copies the current back buffer contents to a texture.
Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)
Syntax
public void ResolveBackBuffer (
Texture2D resolveTarget
)
Parameters
- resolveTarget
Texture to update with the resolved back buffer. This texture must be created with a usage type of ResourceUsage.ResolveTarget.
Exceptions
Exception type | Condition |
---|---|
InvalidOperationException | ResolveBackBuffer may not be called when the current render target is null. Use ResolveBackBuffer instead. |
Remarks
On Xbox 360, the back buffer is cleared when ResolveBackBuffer is called.
Warning
On Xbox 360, all render targets (including the back buffer) share the same memory. Because of this, the previous content of any render target is lost when the render target is changed with SetRenderTarget or when Present is called, which has the same effect as swapping the render target.
To preserve the data in a render target, it is necessary to resolve it, either with ResolveRenderTarget or ResolveBackBuffer. Just remember to resolve the render target before switching the render target to avoid losing data that you want to preserve.
Example
In this example, a new Texture2D is created for use as a render target, the data is initialized with a call to ResolveBackBuffer, and the generation of mipmaps for the resolved render target is requested.
Texture2D renderTargetTexture;
renderTargetTexture = new Texture2D(
graphics.GraphicsDevice,
graphics.GraphicsDevice.PresentationParameters.BackBufferWidth,
graphics.GraphicsDevice.PresentationParameters.BackBufferHeight,
0,
ResourceUsage.ResolveTarget | ResourceUsage.AutoGenerateMipMap,
graphics.GraphicsDevice.PresentationParameters.BackBufferFormat,
ResourceManagementMode.Manual
);
graphics.GraphicsDevice.ResolveBackBuffer( renderTargetTexture );
renderTargetTexture.GenerateMipMaps( TextureFilter.Linear );
See Also
Reference
GraphicsDevice Class
GraphicsDevice Members
Microsoft.Xna.Framework.Graphics Namespace
Platforms
Xbox 360, Windows XP SP2, Windows Vista