GraphicsDevice.Present Method (Nullable<Rectangle>, Nullable<Rectangle>, IntPtr)

Specifies the window target for a presentation and presents the display with the contents of the next buffer in the sequence of back buffers owned by the GraphicsDevice.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public void Present (
         Nullable<Rectangle> sourceRectangle,
         Nullable<Rectangle> destinationRectangle,
         IntPtr overrideWindowHandle


The source rectangle. If null, the entire source surface is presented. If the rectangle exceeds the source surface, the rectangle is clipped to the source surface. This parameter must be null unless the swap chain was created with SwapEffect.Copy.
The destination rectangle, in window client coordinates. If null, the entire client area is filled. If the rectangle exceeds the destination client area, the rectangle is clipped to the destination client area. This parameter must be null unless the swap chain was created with SwapEffect.Copy.
Destination window containing the client area that is the target for this presentation. If not specified, this is DeviceWindowHandle.

Exception typeCondition
ObjectDisposedException Present was called after the GraphicsDevice was disposed.
DriverInternalErrorExceptionInternal driver error. Applications should generally shut down when receiving this error.
DeviceLostException The GraphicsDevice is lost but cannot be reset at this time. Therefore, rendering is not possible.

// Create a new render target to receive the drawn data.
renderTarget = new RenderTarget2D(
    // In this case, we are creating
    // a render target to match half of a split screen:
    // Number of levels in the render target:
    // Use the same surface format as the back buffer.

// 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.

// Set the device render target back to the back buffer.
graphics.GraphicsDevice.SetRenderTarget(0, null);

// Call GetTexture to retrieve the render target data and save it to a texture.
capturedTexture = renderTarget.GetTexture();

Xbox 360, Windows XP SP2, Windows Vista, Zune

Community Additions