Device.GetBackBuffer(Int32,Int32,BackBufferType) Method (Microsoft.DirectX.Direct3D)

How Do I...?

  • Save a Screenshot

Retrieves a back buffer from a device's swap chain.

Definition

Visual Basic Public Function GetBackBuffer( _
    ByVal swapChain As Integer, _
    ByVal backBuffer As Integer, _
    ByVal backBufferType As BackBufferType _
) As Surface
C# public Surface GetBackBuffer(
    int swapChain,
    int backBuffer,
    BackBufferType backBufferType
);
C++ public:
SurfaceGetBackBuffer(
    int swapChain,
    int backBuffer,
    BackBufferType backBufferType
);
JScript public function GetBackBuffer(
    swapChain : int,
    backBuffer : int,
    backBufferType : BackBufferType
) : Surface;

Parameters

swapChain System.Int32
Unsigned integer that specifies the swap chain.
backBuffer System.Int32
Index of the back buffer object to return.
backBufferType Microsoft.DirectX.Direct3D.BackBufferType
Stereo view is not supported in Microsoft DirectX 9.0, so the only valid value for this parameter is Mono.

Return Value

Microsoft.DirectX.Direct3D.Surface
A Surface that represents the returned back buffer surface.

Remarks

Back buffers are numbered from 0 to the total number of back buffers - 1. A value of 0 returns the first back buffer, not the front buffer. The front buffer is not accessible through this method.

Exceptions

InvalidCallException

The method call is invalid. For example, a method's parameter might contain an invalid value.

How Do I...?

Save a Screenshot

This example demonstrates how to save a screen shot to a file.

The back buffer is retrieved and saved as a bitmap image.

In the following C# code example, device is assumed to be the rendering Device. This code is called after rendering is complete.

              [C#]
              

using Microsoft.DirectX.Direct3D;

Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
SurfaceLoader.Save("Screenshot.bmp", ImageFileFormat.Bmp, backbuffer);
backbuffer.Dispose();