Files
XCEngine/docs/api/rhi/device/create-swap-chain.md

35 lines
889 B
Markdown
Raw Normal View History

# RHIDevice::CreateSwapChain
```cpp
virtual RHISwapChain* CreateSwapChain(const SwapChainDesc& desc) = 0;
```
创建交换链,用于管理窗口渲染和帧缓冲区切换。
**参数:**
- `desc` - 交换链描述符,包含尺寸、缓冲数量、格式等
2026-03-20 02:35:45 +08:00
**返回:** 新创建的交换链指针,失败返回 `nullptr`OpenGL 后端始终返回有效对象
**复杂度:** O(1)
**示例:**
```cpp
SwapChainDesc swapChainDesc;
swapChainDesc.width = 1280;
swapChainDesc.height = 720;
swapChainDesc.bufferCount = 2;
swapChainDesc.format = (uint32_t)Format::R8G8B8A8_UNorm;
swapChainDesc.refreshRate = 60;
swapChainDesc.sampleCount = 1;
swapChainDesc.sampleQuality = 0;
RHISwapChain* swapChain = device->CreateSwapChain(swapChainDesc);
```
## 相关文档
- [RHIDevice 总览](device.md) - 返回类总览
- [RHISwapChain](../swap-chain/swap-chain.md) - 交换链类