docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
# OpenGLSwapChain
|
|
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::RHI`
|
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
**类型**: `class`
|
|
|
|
|
|
|
|
|
|
|
|
**描述**: OpenGL 交换链实现,继承自 `RHISwapChain`。基于 GLFW 窗口管理,用于 OpenGL 渲染的帧缓冲交换。
|
|
|
|
|
|
|
|
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
|
|
`OpenGLSwapChain` 是 OpenGL 后端的交换链实现,负责管理渲染目标帧缓冲的呈现。它继承自 `RHISwapChain` 抽象接口,通过 GLFW 窗口系统进行帧缓冲交换。
|
|
|
|
|
|
|
|
|
|
|
|
### 枚举类型
|
|
|
|
|
|
|
|
|
|
|
|
| 枚举 | 描述 |
|
|
|
|
|
|
|------|------|
|
|
|
|
|
|
| [`PresentMode`](present-mode.md) | 呈现模式(Immediate/VSync/Mailbox/Fifo) |
|
|
|
|
|
|
| [`SurfaceFormat`](surface-format.md) | 表面格式(RGBA8/RGBA16F/RGBA32F/BGRA8) |
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
2026-03-19 02:01:18 +08:00
|
|
|
|
## 公共方法
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
2026-03-19 02:01:18 +08:00
|
|
|
|
| 方法 | 描述 |
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|------|------|
|
2026-03-20 02:35:45 +08:00
|
|
|
|
| [`OpenGLSwapChain`](constructor.md) | 构造函数 |
|
|
|
|
|
|
| [`~OpenGLSwapChain`](destructor.md) | 析构函数 |
|
2026-03-19 02:01:18 +08:00
|
|
|
|
| [`Initialize`](initialize.md) | 初始化交换链 |
|
2026-03-20 02:35:45 +08:00
|
|
|
|
| [`Initialize(mode)`](initialize-mode.md) | 使用模式初始化 |
|
|
|
|
|
|
| [`Shutdown`](shutdown.md) | 关闭交换链 |
|
2026-03-19 02:01:18 +08:00
|
|
|
|
| [`Present`](present.md) | 呈现画面 |
|
|
|
|
|
|
| [`SwapBuffers`](swap-buffers.md) | 交换缓冲 |
|
2026-03-20 02:35:45 +08:00
|
|
|
|
| [`Resize`](resize.md) | 调整交换链大小 |
|
2026-03-19 02:01:18 +08:00
|
|
|
|
| [`SetVSync`](set-vsync.md) | 设置垂直同步 |
|
|
|
|
|
|
| [`IsVSync`](is-vsync.md) | 检查是否垂直同步 |
|
|
|
|
|
|
| [`SetFullscreen`](set-fullscreen.md) | 设置全屏模式 |
|
|
|
|
|
|
| [`IsFullscreen`](is-fullscreen.md) | 检查是否全屏 |
|
|
|
|
|
|
| [`ShouldClose`](should-close.md) | 检查是否应关闭 |
|
|
|
|
|
|
| [`SetShouldClose`](set-should-close.md) | 设置关闭标志 |
|
|
|
|
|
|
| [`PollEvents`](poll-events.md) | 处理窗口事件 |
|
2026-03-20 02:35:45 +08:00
|
|
|
|
| [`GetCurrentBackBufferIndex`](get-current-back-buffer-index.md) | 获取当前后台缓冲区索引 |
|
|
|
|
|
|
| [`GetCurrentBackBuffer`](get-current-back-buffer.md) | 获取当前后台缓冲区 |
|
|
|
|
|
|
| [`GetWidth`](get-width.md) | 获取宽度 |
|
|
|
|
|
|
| [`GetHeight`](get-height.md) | 获取高度 |
|
|
|
|
|
|
| [`GetFramebufferWidth`](get-framebuffer-width.md) | 获取帧缓冲宽度 |
|
|
|
|
|
|
| [`GetFramebufferHeight`](get-framebuffer-height.md) | 获取帧缓冲高度 |
|
|
|
|
|
|
| [`SetFramebufferSize`](set-framebuffer-size.md) | 设置帧缓冲大小 |
|
2026-03-19 02:01:18 +08:00
|
|
|
|
| [`GetWindow`](get-window.md) | 获取窗口 |
|
2026-03-20 02:35:45 +08:00
|
|
|
|
| [`GetNativeHandle`](get-native-handle.md) | 获取原生句柄 |
|
|
|
|
|
|
|
|
|
|
|
|
## 使用示例
|
|
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
|
#include <XCEngine/RHI/OpenGL/OpenGLSwapChain.h>
|
|
|
|
|
|
|
|
|
|
|
|
// 创建并初始化
|
|
|
|
|
|
XCEngine::RHI::OpenGLSwapChain swapChain;
|
|
|
|
|
|
GLFWwindow* window = /* 获取 GLFW 窗口 */;
|
|
|
|
|
|
swapChain.Initialize(window, true);
|
|
|
|
|
|
|
|
|
|
|
|
// 游戏循环
|
|
|
|
|
|
while (!swapChain.ShouldClose()) {
|
|
|
|
|
|
swapChain.PollEvents();
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染逻辑
|
|
|
|
|
|
Render();
|
|
|
|
|
|
|
|
|
|
|
|
swapChain.Present(1, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 关闭
|
|
|
|
|
|
swapChain.Shutdown();
|
|
|
|
|
|
```
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
2026-03-26 01:29:00 +08:00
|
|
|
|
- [OpenGL 后端总览](../opengl.md)
|
docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录
- 重命名 index.md 为 main.md
- 修正所有模块文档中的错误:
- math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式
- containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节
- core: 修复 types 链接错误
- debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI
- memory: 修复头文件路径, malloc vs operator new, 新增方法文档
- resources: 修复 Shader/Texture 链接错误
- threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接
- 验证: fix_links.py 确认 0 个断裂引用
2026-03-19 00:22:30 +08:00
|
|
|
|
- [RHISwapChain](../../swap-chain/swap-chain.md) - 抽象交换链接口
|