SwapChain.SwapChain Constructor ()

How Do I...?

  • Create an Additional Swap Chain

Creates a new instance of the SwapChain class.

Overload List

public SwapChain(Device, PresentParameters);
public SwapChain(IDirect3DSwapChain9);
public SwapChain(IDirect3DSwapChain9, Device);
public SwapChain(IntPtr);


Calling this method changes the value of members of the PresentParameters object in the following ways.

  • If BackBufferCount == 0, calling SwapChain increases it to 1.
  • If the application is in windowed mode and if either the BackBufferWidth or BackBufferHeight == 0, they are set to the width and height of the client area window.

Each device always has at least one swap chain (the implicit swap chain), because Microsoft Direct3D sets a swap chain as a device property.

Note that any given device can support only one full-screen swap chain.

It is permissible to specify Format.Unknown for the windowed-mode back buffer format when calling the Device and SwapChain constructors and Device.Reset. If this is done, the application need not query the current desktop format before it calls the Device constructor for windowed mode. For full-screen mode, the back buffer format must be specified.



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


This device does not support the queried multisample type.


The device has been lost but cannot be reset at this time. Therefore, rendering is not possible.


Direct3D does not have enough display memory to perform the operation.

OutOfMemoryExceptionLeave Site

Direct3D could not allocate sufficient memory to complete the call.

How Do I...?

Create an Additional Swap Chain

This example demonstrates how to create an additional swap chain using the SwapChain class. Additional swap chains are useful for supporting multiple viewports; for example, a single window partitioned into four sub-windows, each with different views of the same scene.

In Microsoft DirectX 9.0 for Managed Code, each Device is created with a default swap chain known as the implicit swap chain. Using the SwapChain class allows creation of additional swap chains for rendering operations.

To create a new swap chain:

  1. Create an instance of the PresentParameters class, or use an existing instance and set the presentation properties to the values you need for the swap chain.
  2. Then create a swap chain object using the SwapChain class constructor.

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


    // Create a swap chain using an existing instance of PresentParameters.
    SwapChain sc = new SwapChain(device, presentParams);