SwapChain.SwapChain Constructor |
Language: |
Creates a new instance of the SwapChain class.
Visual Basic Public Sub New( _
ByVal unmanagedObject As IntPtr _
)C# public SwapChain(
IntPtr unmanagedObject
);C++ public:
SwapChain(
IntPtr unmanagedObject
);JScript public function SwapChain(
unmanagedObject : IntPtr
);
unmanagedObject System.IntPtr
Pointer to an unmanaged Component Object Model (COM) IDirect3DSwapChain9 interface. This parameter is useful for working with unmanaged applications from managed code. Not supported.
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
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 Direct3D could not allocate sufficient memory to complete the call.
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);
Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center