# RHIDevice::CreateSwapChain ```cpp virtual RHISwapChain* CreateSwapChain(const SwapChainDesc& desc) = 0; ``` 创建交换链,用于管理窗口渲染和帧缓冲区切换。 **参数:** - `desc` - 交换链描述符,包含尺寸、缓冲数量、格式等 **返回:** 新创建的交换链指针,失败返回 `nullptr` **复杂度:** 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) - 交换链类