docs: update RHI API docs

This commit is contained in:
2026-03-20 02:35:45 +08:00
parent ea756c0177
commit 070b444f8f
501 changed files with 13493 additions and 2022 deletions

View File

@@ -0,0 +1,61 @@
# OpenGLDevice::CreateSwapChain
```cpp
RHISwapChain* CreateSwapChain(const SwapChainDesc& desc) override
```
创建 OpenGL 交换链对象。
## 详细描述
创建与设备窗口关联的交换链,用于管理前后缓冲区的交换。
### 交换链行为
- 使用窗口的当前尺寸初始化交换链
- 通过 `SwapBuffers()` 执行缓冲区交换
- 交换链与 GLFW 窗口 (`m_window`) 关联
## 参数
- `desc` - 交换链描述符
### SwapChainDesc 字段
| 字段 | 描述 |
|------|------|
| `width` | 缓冲区宽度 |
| `height` | 缓冲区高度 |
## 返回值
`RHISwapChain*` - 创建的交换链指针
## 注意事项
- 如果 `m_window``nullptr`,交换链创建失败
- 返回的交换链对象归调用者所有,需自行管理生命周期
- 交换链尺寸应与窗口尺寸匹配
## 示例
```cpp
SwapChainDesc swapDesc;
swapDesc.width = 1280;
swapDesc.height = 720;
RHISwapChain* swapChain = device.CreateSwapChain(swapDesc);
// 在渲染循环中使用
while (!device.ShouldClose()) {
device.PollEvents();
renderScene();
device.SwapBuffers();
}
```
## 相关文档
- [OpenGLDevice](device.md) - 类总览
- [OpenGLSwapChain](../opengl-swap-chain.md) - OpenGL 交换链实现
- [SwapBuffers](swap-buffers.md) - 交换缓冲区