SwapChain.SwapChain(IDirect3DSwapChain9) Constructor (Microsoft.DirectX.Direct3D)
How Do I...?
- Create an Additional Swap Chain
Creates a new instance of the SwapChain class.
Definition
Visual Basic Public Sub New( _
ByVal pUnk As IDirect3DSwapChain9 _
)C# public SwapChain(
IDirect3DSwapChain9 pUnk
);C++ public:
SwapChain(
IDirect3DSwapChain9 pUnk
);JScript public function SwapChain(
pUnk : IDirect3DSwapChain9
);
Parameters
pUnk Microsoft.DirectX.PrivateImplementationDetails.IDirect3DSwapChain9
Unmanaged Component Object Model (COM) IDirect3DSwapChain9 interface pointer.
Remarks
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.
Exceptions
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.
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:
- 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.
- 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);