SwapChain.SwapChain Constructor |
Language: |
Creates a new instance of the SwapChain class.
Visual Basic Public Sub New( _
ByVal device As Device, _
ByVal presentationParameters As PresentParameters _
)C# public SwapChain(
Device device,
PresentParameters presentationParameters
);C++ public:
SwapChain(
Device^ device,
PresentParameters^ presentationParameters
);JScript public function SwapChain(
device : Device,
presentationParameters : PresentParameters
);
device Microsoft.DirectX.Direct3D.Device
The Device object that represents the device to associate with the swap chain.presentationParameters Microsoft.DirectX.Direct3D.PresentParameters
A PresentParameters object that contains the presentation parameters for the new swap chain. See 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
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