RenderTargetCube.GetTexture Method
Gets a copy of the cube texture associated with this render target.
Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)
Syntax
public TextureCube GetTexture ()
Return Value
A copy of the cube texture associated with this render target.
Exceptions
Exception type | Condition |
---|---|
InvalidOperationException | A render target must be resolved using ResolveRenderTarget before calling GetTexture. |
Example
Before calling ResolveRenderTarget, set the render target on the device using SetRenderTarget, complete any drawing code, and then call to resolve the data from the draw call to the currently set render target.
// Create a new render target to receive the drawn data.
renderTarget = new RenderTarget2D(
graphics.GraphicsDevice,
// In this case, we are creating
// a render target to match half of a split screen:
leftViewPort.Width,
leftViewPort.Height,
// Number of levels in the render target:
1,
// Use the same surface format as the back buffer.
graphics.GraphicsDevice.PresentationParameters.BackBufferFormat );
// Set the render target on the device.
graphics.GraphicsDevice.SetRenderTarget( 0, renderTarget );
// TODO: Add your code to draw to the render target here.
// For example, this could be a call to Mesh.Draw,
// a SpriteBatch Begin-End sequence, or a call to
// DrawIndexedPrimitives, as you would have called them
// in the Draw method of your application.
// Resolve the data from the draw call to the currently set render target.
graphics.GraphicsDevice.ResolveRenderTarget( 0 );
// Call GetTexture to retrieve the render target data and save it to a texture.
capturedTexture = renderTarget.GetTexture();
// Set the device render target back to the back buffer.
graphics.GraphicsDevice.SetRenderTarget( 0, null );
See Also
Reference
RenderTargetCube Class
RenderTargetCube Members
Microsoft.Xna.Framework.Graphics Namespace
Platforms
Xbox 360, Windows XP SP2, Windows Vista