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
|
|
|
# OpenGLVertexArray
|
|
|
|
|
|
|
|
|
|
**命名空间**: `XCEngine::RHI`
|
|
|
|
|
|
2026-03-20 02:35:45 +08:00
|
|
|
**描述**: OpenGL 顶点数组对象 (VAO) 封装。管理顶点属性配置和索引缓冲绑定。
|
|
|
|
|
|
|
|
|
|
## 概述
|
|
|
|
|
|
|
|
|
|
`OpenGLVertexArray` 封装了 OpenGL 顶点数组对象 (Vertex Array Object, VAO),用于:
|
|
|
|
|
- 存储顶点属性配置
|
|
|
|
|
- 绑定顶点缓冲区和索引缓冲区
|
|
|
|
|
- 提供便捷的绑定/解绑接口
|
|
|
|
|
|
|
|
|
|
## 类型
|
|
|
|
|
|
|
|
|
|
| 类型 | 描述 |
|
|
|
|
|
|------|------|
|
|
|
|
|
| [`VertexAttribute`](vertex-attribute.md) | 顶点属性描述结构体 |
|
|
|
|
|
|
|
|
|
|
## 构造函数/析构函数
|
|
|
|
|
|
|
|
|
|
| 方法 | 描述 |
|
|
|
|
|
|------|------|
|
|
|
|
|
| [`OpenGLVertexArray()`](constructor.md) | 默认构造函数 |
|
|
|
|
|
| [`~OpenGLVertexArray()`](destructor.md) | 析构函数,调用 `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-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
|
|
|
| [`Initialize`](initialize.md) | 初始化顶点数组,生成 VAO |
|
|
|
|
|
| [`AddVertexBuffer`](add-vertex-buffer.md) | 添加顶点缓冲并配置属性 |
|
2026-03-19 02:01:18 +08:00
|
|
|
| [`SetIndexBuffer`](set-index-buffer.md) | 设置索引缓冲 |
|
2026-03-20 02:35:45 +08:00
|
|
|
| [`Shutdown`](shutdown.md) | 关闭顶点数组,释放 VAO 资源 |
|
|
|
|
|
| [`Bind`](bind.md) | 绑定顶点数组到当前 OpenGL 上下文 |
|
|
|
|
|
| [`Unbind`](unbind.md) | 解绑顶点数组 |
|
2026-03-19 02:01:18 +08:00
|
|
|
| [`GetID`](get-id.md) | 获取 OpenGL VAO ID |
|
2026-03-20 02:35:45 +08:00
|
|
|
| [`GetIndexBuffer`](get-index-buffer.md) | 获取索引缓冲区 ID |
|
|
|
|
|
| [`GetIndexCount`](get-index-count.md) | 获取索引数量(需手动维护) |
|
|
|
|
|
|
|
|
|
|
## 使用示例
|
|
|
|
|
|
|
|
|
|
```cpp
|
|
|
|
|
// 创建 VAO
|
|
|
|
|
OpenGLVertexArray vao;
|
|
|
|
|
vao.Initialize();
|
|
|
|
|
|
|
|
|
|
// 添加顶点缓冲和属性
|
|
|
|
|
vao.AddVertexBuffer(vbo, positionAttr);
|
|
|
|
|
vao.AddVertexBuffer(vbo, normalAttr);
|
|
|
|
|
vao.AddVertexBuffer(vbo, texCoordAttr);
|
|
|
|
|
|
|
|
|
|
// 设置索引缓冲
|
|
|
|
|
vao.SetIndexBuffer(ibo, GL_UNSIGNED_INT);
|
|
|
|
|
|
|
|
|
|
// 绑定并绘制
|
|
|
|
|
vao.Bind();
|
|
|
|
|
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_INT, 0);
|
|
|
|
|
vao.Unbind();
|
|
|
|
|
|
|
|
|
|
// 销毁
|
|
|
|
|
vao.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
|
|
|
|
|
|
|
|
## 相关文档
|
|
|
|
|
|
|
|
|
|
- [OpenGL 后端总览](../overview.md)
|
2026-03-20 02:35:45 +08:00
|
|
|
- [VertexAttribute 结构体](vertex-attribute.md)
|