Microsoft DirectX 9.0 SDK Update (October 2004)

SwapChain.SwapChain Constructor

Language:

Note: This documentation is preliminary and is subject to change.
How Do I...?

Creates a new instance of the SwapChain class.

Definition

Visual Basic .NET Public Sub New( _
    ByVal lp As IDirect3DSwapChain9, _
    ByVal device As Device _
)
C# public SwapChain(
    IDirect3DSwapChain9 lp,
    Device device
);
Managed C++ public: SwapChain(
    IDirect3DSwapChain9 lp,
    Device *device
);
JScript .NET public function SwapChain(
    lp : IDirect3DSwapChain9,
    device : Device
);

Parameters

lp Microsoft.DirectX.PrivateImplementationDetails.IDirect3DSwapChain9. Unmanaged Component Object Model (COM) IDirect3DSwapChain9 interface pointer.
device Microsoft.DirectX.Direct3D.Device. The Device object that represents the device to associate with the swap chain.

Remarks

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

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.

Exceptions
InvalidCallException The method call is invalid. For example, a method's parameter might contain an invalid value.
NotAvailableException This device does not support the queried multisample type.
DeviceLostException The device has been lost but cannot be reset at this time. Therefore, rendering is not possible.
OutOfVideoMemoryException Direct3D does not have enough display memory to perform the operation.
OutOfMemoryException Leave 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.

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


© 2004 Microsoft Corporation. All rights reserved. Terms of use.

Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center