IDXGISwapChain Interface
Represents a swap chain, which is a collection of surfaces that are presented to the user.
Interface Comments
This interface is used to manage the presentation of rendered images to the screen. It allows you to control how rendered frames are displayed, including the ability to present frames, retrieve back buffer surfaces, and manage the swap chain's properties.
Methods
GetBuffer
HRESULT GetBuffer(
UINT Buffer,
REFIID riid,
_COM_Outptr_ void **ppSurface
);
Retrieves a back buffer surface.
Parameters
Buffer
[in] - The zero-based index of the back buffer surface to retrieve.riid
[in] - The globally unique identifier (GUID) for the interface of the back buffer surface.ppSurface
[out] - A pointer to the back buffer surface.
Returns:
S_OK
if the method succeeds.DXGI_ERROR_NOT_CURRENTLY_AVAILABLE
if the back buffer is not currently available.DXGI_ERROR_DEVICE_REMOVED
if the graphics adapter has been removed.- Other error codes.
Remarks:
Use this method to retrieve a back buffer surface from the swap chain. This surface can then be used to render frames.
Present
HRESULT Present(
UINT SyncInterval,
UINT Flags
);
Presents the contents of the next buffer in the sequence of back buffers to the user.
Parameters
SyncInterval
[in] - The number of refresh intervals to wait before presenting the next frame. 0 means present as fast as possible. 1 means present on the next vertical sync.Flags
[in] - Options for presenting the frame.
Returns:
S_OK
if the method succeeds.DXGI_ERROR_DEVICE_REMOVED
if the graphics adapter has been removed.DXGI_ERROR_DEVICE_HUNG
if the device has been lost.DXGI_ERROR_INVALID_CALL
if the method call is invalid.
Remarks:
This is the primary method for displaying rendered frames to the user. Proper use of
SyncInterval
and Flags
is crucial for controlling frame rate and presentation behavior.
ResizeBuffers
HRESULT ResizeBuffers(
UINT BufferCount,
UINT Width,
UINT Height,
DXGI_FORMAT NewFormat,
UINT SwapChainFlags
);
Resizes the back buffers of the swap chain.
Parameters
BufferCount
[in] - The number of buffers in the swap chain.Width
[in] - The width of the buffers.Height
[in] - The height of the buffers.NewFormat
[in] - The new format of the back buffers.SwapChainFlags
[in] - Swap chain flags.
Returns:
S_OK
if the method succeeds.DXGI_ERROR_DEVICE_REMOVED
if the graphics adapter has been removed.DXGI_ERROR_INVALID_CALL
if the method call is invalid.
Remarks:
Call this method when the application needs to change the resolution or format of the swap chain. The existing surfaces are released and new ones are created.
GetDesc
HRESULT GetDesc(
DXGI_SWAP_CHAIN_DESC *pDesc
);
Retrieves a description of the swap chain.
Parameters
pDesc
[out] - A pointer to aDXGI_SWAP_CHAIN_DESC
structure that receives a description of the swap chain.
Returns:
S_OK
if the method succeeds.DXGI_ERROR_DEVICE_REMOVED
if the graphics adapter has been removed.
Remarks:
This method is useful for querying the current state and properties of the swap chain.