docs: update RHI API docs
This commit is contained in:
@@ -2,22 +2,67 @@
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**描述**: OpenGL 顶点数组对象 (VAO) 封装。
|
||||
**描述**: OpenGL 顶点数组对象 (VAO) 封装。管理顶点属性配置和索引缓冲绑定。
|
||||
|
||||
## 概述
|
||||
|
||||
`OpenGLVertexArray` 封装了 OpenGL 顶点数组对象 (Vertex Array Object, VAO),用于:
|
||||
- 存储顶点属性配置
|
||||
- 绑定顶点缓冲区和索引缓冲区
|
||||
- 提供便捷的绑定/解绑接口
|
||||
|
||||
## 类型
|
||||
|
||||
| 类型 | 描述 |
|
||||
|------|------|
|
||||
| [`VertexAttribute`](vertex-attribute.md) | 顶点属性描述结构体 |
|
||||
|
||||
## 构造函数/析构函数
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [`OpenGLVertexArray()`](constructor.md) | 默认构造函数 |
|
||||
| [`~OpenGLVertexArray()`](destructor.md) | 析构函数,调用 `Shutdown()` 释放资源 |
|
||||
|
||||
## 公共方法
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [`Initialize`](../../../threading/task-system/initialize.md) | 初始化顶点数组 |
|
||||
| [`AddVertexBuffer`](add-vertex-buffer.md) | 添加顶点缓冲 |
|
||||
| [`Initialize`](initialize.md) | 初始化顶点数组,生成 VAO |
|
||||
| [`AddVertexBuffer`](add-vertex-buffer.md) | 添加顶点缓冲并配置属性 |
|
||||
| [`SetIndexBuffer`](set-index-buffer.md) | 设置索引缓冲 |
|
||||
| [`Shutdown`](../../../threading/task-system/shutdown.md) | 关闭顶点数组 |
|
||||
| [`Bind`](../../shader/bind.md) | 绑定顶点数组 |
|
||||
| [`Unbind`](../../shader/unbind.md) | 解绑顶点数组 |
|
||||
| [`Shutdown`](shutdown.md) | 关闭顶点数组,释放 VAO 资源 |
|
||||
| [`Bind`](bind.md) | 绑定顶点数组到当前 OpenGL 上下文 |
|
||||
| [`Unbind`](unbind.md) | 解绑顶点数组 |
|
||||
| [`GetID`](get-id.md) | 获取 OpenGL VAO ID |
|
||||
| [`GetIndexBuffer`](get-index-buffer.md) | 获取索引缓冲 |
|
||||
| [`GetIndexCount`](get-index-count.md) | 获取索引数量 |
|
||||
| [`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();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGL 后端总览](../overview.md)
|
||||
- [VertexAttribute 结构体](vertex-attribute.md)
|
||||
|
||||
Reference in New Issue
Block a user