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 个断裂引用
This commit is contained in:
26
docs/api/rhi/opengl/README.md
Normal file
26
docs/api/rhi/opengl/README.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# OpenGL 后端组件
|
||||
|
||||
OpenGL 后端已创建以下组件文件夹和文档:
|
||||
|
||||
- `device/` - OpenGLDevice
|
||||
- `buffer/` - OpenGLBuffer
|
||||
- `texture/` - OpenGLTexture
|
||||
- `command-list/` - OpenGLCommandList
|
||||
- `command-queue/` - OpenGLCommandQueue
|
||||
- `swap-chain/` - OpenGLSwapChain
|
||||
- `fence/` - OpenGLFence
|
||||
- `shader/` - OpenGLShader
|
||||
- `pipeline-state/` - OpenGLPipelineState
|
||||
- `sampler/` - OpenGLSampler
|
||||
- `vertex-array/` - OpenGLVertexArray
|
||||
- `render-target-view/` - OpenGLRenderTargetView
|
||||
- `depth-stencil-view/` - OpenGLDepthStencilView
|
||||
|
||||
每个组件文件夹包含:
|
||||
- `{component}.md` - 类总览
|
||||
- `methods.md` - 方法详细文档
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGL 后端总览](overview.md)
|
||||
- [RHI 抽象层](../d3d12/overview.md)
|
||||
21
docs/api/rhi/opengl/buffer/bind-base.md
Normal file
21
docs/api/rhi/opengl/buffer/bind-base.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# OpenGLBuffer::BindBase
|
||||
|
||||
```cpp
|
||||
void BindBase(unsigned int target, unsigned int index) const
|
||||
```
|
||||
|
||||
将缓冲区绑定到固定的 binding point。
|
||||
|
||||
**参数:**
|
||||
- `target` - OpenGL target (如 GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER)
|
||||
- `index` - binding point 索引
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
buffer.BindBase(GL_UNIFORM_BUFFER, 0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLBuffer](buffer.md) - 返回类总览
|
||||
34
docs/api/rhi/opengl/buffer/buffer.md
Normal file
34
docs/api/rhi/opengl/buffer/buffer.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# OpenGLBuffer
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**描述**: OpenGL 缓冲区的实现,继承自 `RHIBuffer`。
|
||||
|
||||
## 方法列表
|
||||
|
||||
| 方法 | 文档 |
|
||||
|------|------|
|
||||
| `Initialize` | [详细文档](../../../threading/task-system/initialize.md) |
|
||||
| `InitializeVertexBuffer` | [详细文档](initialize-vertex-buffer.md) |
|
||||
| `InitializeIndexBuffer` | [详细文档](initialize-index-buffer.md) |
|
||||
| `Shutdown` | [详细文档](../../../threading/task-system/shutdown.md) |
|
||||
| `Bind` | [详细文档](../../shader/bind.md) |
|
||||
| `Unbind` | [详细文档](../../shader/unbind.md) |
|
||||
| `BindBase` | [详细文档](bind-base.md) |
|
||||
| `Map` | [详细文档](../../buffer/map.md) |
|
||||
| `Unmap` | [详细文档](../../buffer/unmap.md) |
|
||||
| `SetData` | [详细文档](../../buffer/set-data.md) |
|
||||
| `GetID` | [详细文档](get-id.md) |
|
||||
| `GetSize` | [详细文档](../../buffer/get-size.md) |
|
||||
| `GetType` | [详细文档](../../shader/get-type.md) |
|
||||
| `IsDynamic` | [详细文档](is-dynamic.md) |
|
||||
| `GetBufferType` / `SetBufferType` | [详细文档](../../buffer/get-buffer-type.md) |
|
||||
| `GetStride` / `SetStride` | [详细文档](../../buffer/get-stride.md) |
|
||||
| `GetNativeHandle` | [详细文档](../../buffer/get-native-handle.md) |
|
||||
| `GetState` / `SetState` | [详细文档](../../buffer/get-state.md) |
|
||||
| `GetName` / `SetName` | [详细文档](../../buffer/get-name.md) |
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGL 后端总览](../overview.md)
|
||||
- [RHIBuffer](../../buffer/buffer.md) - 抽象缓冲区接口
|
||||
20
docs/api/rhi/opengl/buffer/get-id.md
Normal file
20
docs/api/rhi/opengl/buffer/get-id.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLBuffer::GetID
|
||||
|
||||
```cpp
|
||||
unsigned int GetID() const
|
||||
```
|
||||
|
||||
获取 OpenGL buffer 的 GLuint ID。
|
||||
|
||||
**返回:** OpenGL buffer ID
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
unsigned int id = buffer.GetID();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, id);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLBuffer](buffer.md) - 返回类总览
|
||||
25
docs/api/rhi/opengl/buffer/initialize-index-buffer.md
Normal file
25
docs/api/rhi/opengl/buffer/initialize-index-buffer.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# OpenGLBuffer::InitializeIndexBuffer
|
||||
|
||||
```cpp
|
||||
bool InitializeIndexBuffer(const void* data, size_t size)
|
||||
```
|
||||
|
||||
初始化索引缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `data` - 索引数据指针
|
||||
- `size` - 数据大小(字节)
|
||||
|
||||
**返回:** 成功返回 true
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
uint32_t indices[] = { 0, 1, 2 };
|
||||
OpenGLBuffer buffer;
|
||||
buffer.InitializeIndexBuffer(indices, sizeof(indices));
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLBuffer](buffer.md) - 返回类总览
|
||||
25
docs/api/rhi/opengl/buffer/initialize-vertex-buffer.md
Normal file
25
docs/api/rhi/opengl/buffer/initialize-vertex-buffer.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# OpenGLBuffer::InitializeVertexBuffer
|
||||
|
||||
```cpp
|
||||
bool InitializeVertexBuffer(const void* data, size_t size)
|
||||
```
|
||||
|
||||
初始化顶点缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `data` - 顶点数据指针
|
||||
- `size` - 数据大小(字节)
|
||||
|
||||
**返回:** 成功返回 true
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
float vertices[] = { 0.0f, 0.5f, 0.0f };
|
||||
OpenGLBuffer buffer;
|
||||
buffer.InitializeVertexBuffer(vertices, sizeof(vertices));
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLBuffer](buffer.md) - 返回类总览
|
||||
24
docs/api/rhi/opengl/buffer/is-dynamic.md
Normal file
24
docs/api/rhi/opengl/buffer/is-dynamic.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# OpenGLBuffer::IsDynamic
|
||||
|
||||
```cpp
|
||||
bool IsDynamic() const
|
||||
```
|
||||
|
||||
判断缓冲区是否为动态缓冲区。
|
||||
|
||||
**返回:** 如果是动态缓冲区返回 true
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
if (buffer.IsDynamic()) {
|
||||
// 动态缓冲区可以直接 Map/Unmap
|
||||
void* data = buffer.Map();
|
||||
// ...
|
||||
buffer.Unmap();
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLBuffer](buffer.md) - 返回类总览
|
||||
23
docs/api/rhi/opengl/command-list/clear-color.md
Normal file
23
docs/api/rhi/opengl/command-list/clear-color.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# OpenGLCommandList::ClearColor
|
||||
|
||||
```cpp
|
||||
void ClearColor(float r, float g, float b, float a)
|
||||
```
|
||||
|
||||
清除颜色缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `r` - 红色分量 (0.0-1.0)
|
||||
- `g` - 绿色分量 (0.0-1.0)
|
||||
- `b` - 蓝色分量 (0.0-1.0)
|
||||
- `a` - 透明度分量 (0.0-1.0)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
22
docs/api/rhi/opengl/command-list/clear-depth-stencil.md
Normal file
22
docs/api/rhi/opengl/command-list/clear-depth-stencil.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenGLCommandList::ClearDepthStencil
|
||||
|
||||
```cpp
|
||||
void ClearDepthStencil(void* depthStencil, float depth, uint8_t stencil)
|
||||
```
|
||||
|
||||
清除深度模板目标。
|
||||
|
||||
**参数:**
|
||||
- `depthStencil` - 深度模板目标指针
|
||||
- `depth` - 深度值
|
||||
- `stencil` - 模板值
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->ClearDepthStencil(depthStencil, 1.0f, 0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
20
docs/api/rhi/opengl/command-list/clear-depth.md
Normal file
20
docs/api/rhi/opengl/command-list/clear-depth.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLCommandList::ClearDepth
|
||||
|
||||
```cpp
|
||||
void ClearDepth(float depth)
|
||||
```
|
||||
|
||||
清除深度缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `depth` - 深度值 (0.0-1.0)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->ClearDepth(1.0f);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
22
docs/api/rhi/opengl/command-list/clear-render-target.md
Normal file
22
docs/api/rhi/opengl/command-list/clear-render-target.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenGLCommandList::ClearRenderTarget
|
||||
|
||||
```cpp
|
||||
void ClearRenderTarget(void* renderTarget, const float color[4])
|
||||
```
|
||||
|
||||
清除渲染目标。
|
||||
|
||||
**参数:**
|
||||
- `renderTarget` - 渲染目标指针
|
||||
- `color` - 清除颜色 [r, g, b, a]
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
float color[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
commandList->ClearRenderTarget(renderTarget, color);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
20
docs/api/rhi/opengl/command-list/clear-stencil.md
Normal file
20
docs/api/rhi/opengl/command-list/clear-stencil.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLCommandList::ClearStencil
|
||||
|
||||
```cpp
|
||||
void ClearStencil(int stencil)
|
||||
```
|
||||
|
||||
清除模板缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `stencil` - 模板值
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->ClearStencil(0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
45
docs/api/rhi/opengl/command-list/command-list.md
Normal file
45
docs/api/rhi/opengl/command-list/command-list.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# OpenGLCommandList
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**描述**: OpenGL 命令列表实现,继承自 `RHICommandList`。
|
||||
|
||||
## 方法列表
|
||||
|
||||
| 方法 | 文档 |
|
||||
|------|------|
|
||||
| `Shutdown` | [详细文档](../../../threading/task-system/shutdown.md) |
|
||||
| `Reset` | [详细文档](../../../resources/resourcehandle/reset.md) |
|
||||
| `Close` | [详细文档](../../../core/filewriter/close.md) |
|
||||
| `Clear` | [详细文档](../../../memory/linear-allocator/clear.md) |
|
||||
| `ClearColor` | [详细文档](clear-color.md) |
|
||||
| `ClearDepth` | [详细文档](clear-depth.md) |
|
||||
| `ClearStencil` | [详细文档](clear-stencil.md) |
|
||||
| `ClearDepthStencil` | [详细文档](clear-depth-stencil.md) |
|
||||
| `SetPipelineState` | [详细文档](set-pipeline-state.md) |
|
||||
| `SetVertexBuffer` | [详细文档](set-vertex-buffer.md) |
|
||||
| `SetVertexBuffers` | [详细文档](set-vertex-buffers.md) |
|
||||
| `SetIndexBuffer` | [详细文档](set-index-buffer.md) |
|
||||
| `TransitionBarrier` | [详细文档](transition-barrier.md) |
|
||||
| `SetPrimitiveTopology` | [详细文档](set-primitive-topology.md) |
|
||||
| `SetViewport` | [详细文档](set-viewport.md) |
|
||||
| `SetViewports` | [详细文档](set-viewports.md) |
|
||||
| `SetScissorRect` | [详细文档](set-scissor-rect.md) |
|
||||
| `SetScissorRects` | [详细文档](set-scissor-rects.md) |
|
||||
| `SetRenderTargets` | [详细文档](set-render-targets.md) |
|
||||
| `SetDepthStencilState` | [详细文档](set-depth-stencil-state.md) |
|
||||
| `SetStencilRef` | [详细文档](set-stencil-ref.md) |
|
||||
| `SetBlendState` | [详细文档](set-blend-state.md) |
|
||||
| `SetBlendFactor` | [详细文档](set-blend-factor.md) |
|
||||
| `ClearRenderTarget` | [详细文档](clear-render-target.md) |
|
||||
| `ClearDepthStencil` | [详细文档](clear-depth-stencil.md) |
|
||||
| `Draw` | [详细文档](draw.md) |
|
||||
| `DrawIndexed` | [详细文档](draw-indexed.md) |
|
||||
| `Dispatch` | [详细文档](dispatch.md) |
|
||||
| `CopyResource` | [详细文档](copy-resource.md) |
|
||||
| **OpenGL 特有方法** | [详细文档](opengl-methods.md) |
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGL 后端总览](../overview.md)
|
||||
- [RHICommandList](../../command-list/command-list.md) - 抽象命令列表接口
|
||||
21
docs/api/rhi/opengl/command-list/copy-resource.md
Normal file
21
docs/api/rhi/opengl/command-list/copy-resource.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# OpenGLCommandList::CopyResource
|
||||
|
||||
```cpp
|
||||
void CopyResource(void* dst, void* src)
|
||||
```
|
||||
|
||||
复制资源。
|
||||
|
||||
**参数:**
|
||||
- `dst` - 目标资源指针
|
||||
- `src` - 源资源指针
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->CopyResource(dstTexture, srcTexture);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
22
docs/api/rhi/opengl/command-list/dispatch.md
Normal file
22
docs/api/rhi/opengl/command-list/dispatch.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenGLCommandList::Dispatch
|
||||
|
||||
```cpp
|
||||
void Dispatch(uint32_t x, uint32_t y, uint32_t z)
|
||||
```
|
||||
|
||||
分发计算着色器。
|
||||
|
||||
**参数:**
|
||||
- `x` - X 方向线程组数量
|
||||
- `y` - Y 方向线程组数量
|
||||
- `z` - Z 方向线程组数量
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->Dispatch(8, 8, 1);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
24
docs/api/rhi/opengl/command-list/draw-indexed.md
Normal file
24
docs/api/rhi/opengl/command-list/draw-indexed.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# OpenGLCommandList::DrawIndexed
|
||||
|
||||
```cpp
|
||||
void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t startIndex, int32_t baseVertex, uint32_t startInstance)
|
||||
```
|
||||
|
||||
绘制索引图元。
|
||||
|
||||
**参数:**
|
||||
- `indexCount` - 索引数量
|
||||
- `instanceCount` - 实例数量
|
||||
- `startIndex` - 起始索引
|
||||
- `baseVertex` - 基础顶点
|
||||
- `startInstance` - 起始实例
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->DrawIndexed(6, 1, 0, 0, 0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
23
docs/api/rhi/opengl/command-list/draw.md
Normal file
23
docs/api/rhi/opengl/command-list/draw.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# OpenGLCommandList::Draw
|
||||
|
||||
```cpp
|
||||
void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t startVertex, uint32_t startInstance)
|
||||
```
|
||||
|
||||
绘制非索引图元。
|
||||
|
||||
**参数:**
|
||||
- `vertexCount` - 顶点数量
|
||||
- `instanceCount` - 实例数量
|
||||
- `startVertex` - 起始顶点
|
||||
- `startInstance` - 起始实例
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->Draw(3, 1, 0, 0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
545
docs/api/rhi/opengl/command-list/opengl-methods.md
Normal file
545
docs/api/rhi/opengl/command-list/opengl-methods.md
Normal file
@@ -0,0 +1,545 @@
|
||||
# OpenGLCommandList - OpenGL 特有方法
|
||||
|
||||
以下是 `OpenGLCommandList` 中 OpenGL 特有的底层逃逸方法。这些方法不存在于 RHI 抽象接口中,用于需要直接操作 OpenGL 状态的高级场景。
|
||||
|
||||
## 顶点缓冲区(OpenGL 逃逸)
|
||||
|
||||
### SetVertexBuffer (GL uint)
|
||||
|
||||
```cpp
|
||||
void SetVertexBuffer(unsigned int buffer, size_t offset, size_t stride)
|
||||
```
|
||||
|
||||
直接使用 OpenGL buffer ID 设置顶点缓冲区。
|
||||
|
||||
### SetVertexBuffers (GL uint)
|
||||
|
||||
```cpp
|
||||
void SetVertexBuffers(unsigned int startSlot, unsigned int count, const unsigned int* buffers, const size_t* offsets, const size_t* strides)
|
||||
```
|
||||
|
||||
批量设置顶点缓冲区。
|
||||
|
||||
### SetIndexBuffer (GL uint)
|
||||
|
||||
```cpp
|
||||
void SetIndexBuffer(unsigned int buffer, unsigned int type)
|
||||
void SetIndexBuffer(unsigned int buffer, unsigned int type, size_t offset)
|
||||
```
|
||||
|
||||
直接设置索引缓冲区。
|
||||
|
||||
## 顶点数组
|
||||
|
||||
### BindVertexArray
|
||||
|
||||
```cpp
|
||||
void BindVertexArray(unsigned int vao)
|
||||
void BindVertexArray(unsigned int vao, unsigned int indexBuffer, unsigned int indexType)
|
||||
```
|
||||
|
||||
绑定 VAO,可同时设置索引缓冲区。
|
||||
|
||||
### UseShader
|
||||
|
||||
```cpp
|
||||
void UseShader(unsigned int program)
|
||||
```
|
||||
|
||||
使用 shader program。
|
||||
|
||||
## 视口与裁剪
|
||||
|
||||
### SetViewport (int)
|
||||
|
||||
```cpp
|
||||
void SetViewport(int x, int y, int width, int height)
|
||||
```
|
||||
|
||||
使用整数参数设置视口。
|
||||
|
||||
### SetViewport (float)
|
||||
|
||||
```cpp
|
||||
void SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth)
|
||||
```
|
||||
|
||||
使用浮点参数设置视口。
|
||||
|
||||
### SetViewports
|
||||
|
||||
```cpp
|
||||
void SetViewports(unsigned int count, const float* viewports)
|
||||
```
|
||||
|
||||
批量设置视口(6 个浮点值 per viewport: x, y, width, height, minDepth, maxDepth)。
|
||||
|
||||
### SetScissor
|
||||
|
||||
```cpp
|
||||
void SetScissor(int x, int y, int width, int height)
|
||||
```
|
||||
|
||||
设置裁剪矩形。
|
||||
|
||||
### SetScissorRects
|
||||
|
||||
```cpp
|
||||
void SetScissorRects(unsigned int count, const int* rects)
|
||||
```
|
||||
|
||||
批量设置裁剪矩形(4 个整数值 per rect: x, y, width, height)。
|
||||
|
||||
### EnableScissorTest
|
||||
|
||||
```cpp
|
||||
void EnableScissorTest(bool enable)
|
||||
```
|
||||
|
||||
启用/禁用裁剪测试。
|
||||
|
||||
## 深度测试
|
||||
|
||||
### EnableDepthTest
|
||||
|
||||
```cpp
|
||||
void EnableDepthTest(bool enable)
|
||||
```
|
||||
|
||||
启用/禁用深度测试。
|
||||
|
||||
### EnableDepthWrite
|
||||
|
||||
```cpp
|
||||
void EnableDepthWrite(bool enable)
|
||||
```
|
||||
|
||||
启用/禁用深度写入。
|
||||
|
||||
### SetDepthFunc
|
||||
|
||||
```cpp
|
||||
void SetDepthFunc(unsigned int func)
|
||||
```
|
||||
|
||||
设置深度比较函数(GL_NEVER, GL_LESS, GL_EQUAL, etc.)。
|
||||
|
||||
## 模板测试
|
||||
|
||||
### EnableStencilTest
|
||||
|
||||
```cpp
|
||||
void EnableStencilTest(bool enable)
|
||||
```
|
||||
|
||||
启用/禁用模板测试。
|
||||
|
||||
### SetStencilFunc
|
||||
|
||||
```cpp
|
||||
void SetStencilFunc(unsigned int func, int ref, unsigned int mask)
|
||||
```
|
||||
|
||||
设置模板测试函数。
|
||||
|
||||
### SetStencilOp
|
||||
|
||||
```cpp
|
||||
void SetStencilOp(unsigned int fail, unsigned int zfail, unsigned int zpass)
|
||||
```
|
||||
|
||||
设置模板操作。
|
||||
|
||||
## 混合
|
||||
|
||||
### EnableBlending
|
||||
|
||||
```cpp
|
||||
void EnableBlending(bool enable)
|
||||
```
|
||||
|
||||
启用/禁用混合。
|
||||
|
||||
### SetBlendFunc
|
||||
|
||||
```cpp
|
||||
void SetBlendFunc(unsigned int src, unsigned int dst)
|
||||
```
|
||||
|
||||
设置混合函数。
|
||||
|
||||
### SetBlendFuncSeparate
|
||||
|
||||
```cpp
|
||||
void SetBlendFuncSeparate(unsigned int srcRGB, unsigned int dstRGB, unsigned int srcAlpha, unsigned int dstAlpha)
|
||||
```
|
||||
|
||||
分别设置 RGB 和 Alpha 的混合函数。
|
||||
|
||||
### SetBlendEquation
|
||||
|
||||
```cpp
|
||||
void SetBlendEquation(unsigned int mode)
|
||||
```
|
||||
|
||||
设置混合方程。
|
||||
|
||||
### SetBlendColor
|
||||
|
||||
```cpp
|
||||
void SetBlendColor(float r, float g, float b, float a)
|
||||
```
|
||||
|
||||
设置混合因子颜色。
|
||||
|
||||
## 光栅化
|
||||
|
||||
### EnableCulling
|
||||
|
||||
```cpp
|
||||
void EnableCulling(bool enable)
|
||||
```
|
||||
|
||||
启用/禁用面剔除。
|
||||
|
||||
### SetCullFace
|
||||
|
||||
```cpp
|
||||
void SetCullFace(unsigned int face)
|
||||
```
|
||||
|
||||
设置剔除面(GL_FRONT, GL_BACK, GL_FRONT_AND_BACK)。
|
||||
|
||||
### SetFrontFace
|
||||
|
||||
```cpp
|
||||
void SetFrontFace(unsigned int face)
|
||||
```
|
||||
|
||||
设置正面方向(GL_CW, GL_CCW)。
|
||||
|
||||
### SetPolygonMode
|
||||
|
||||
```cpp
|
||||
void SetPolygonMode(unsigned int mode)
|
||||
```
|
||||
|
||||
设置多边形模式(GL_POINT, GL_LINE, GL_FILL)。
|
||||
|
||||
### SetPolygonOffset
|
||||
|
||||
```cpp
|
||||
void SetPolygonOffset(float factor, float units)
|
||||
```
|
||||
|
||||
设置多边形偏移。
|
||||
|
||||
### SetPrimitiveType
|
||||
|
||||
```cpp
|
||||
void SetPrimitiveType(PrimitiveType type)
|
||||
```
|
||||
|
||||
设置图元类型。
|
||||
|
||||
## 绘制(OpenGL 类型)
|
||||
|
||||
### Draw (PrimitiveType)
|
||||
|
||||
```cpp
|
||||
void Draw(PrimitiveType type, unsigned int vertexCount, unsigned int startVertex)
|
||||
```
|
||||
|
||||
绘制非索引图元。
|
||||
|
||||
### DrawInstanced
|
||||
|
||||
```cpp
|
||||
void DrawInstanced(PrimitiveType type, unsigned int vertexCount, unsigned int instanceCount, unsigned int startVertex, unsigned int startInstance)
|
||||
```
|
||||
|
||||
实例化绘制。
|
||||
|
||||
### DrawIndexed (PrimitiveType)
|
||||
|
||||
```cpp
|
||||
void DrawIndexed(PrimitiveType type, unsigned int indexCount, unsigned int startIndex, int baseVertex)
|
||||
```
|
||||
|
||||
绘制索引图元。
|
||||
|
||||
### DrawIndexedInstanced
|
||||
|
||||
```cpp
|
||||
void DrawIndexedInstanced(PrimitiveType type, unsigned int indexCount, unsigned int instanceCount, unsigned int startIndex, int baseVertex, unsigned int startInstance)
|
||||
```
|
||||
|
||||
实例化索引绘制。
|
||||
|
||||
### DrawIndirect
|
||||
|
||||
```cpp
|
||||
void DrawIndirect(PrimitiveType type, unsigned int buffer, size_t offset, unsigned int drawCount, unsigned int stride)
|
||||
```
|
||||
|
||||
间接绘制。
|
||||
|
||||
### DrawIndexedIndirect
|
||||
|
||||
```cpp
|
||||
void DrawIndexedIndirect(PrimitiveType type, unsigned int buffer, size_t offset, unsigned int drawCount, unsigned int stride)
|
||||
```
|
||||
|
||||
间接索引绘制。
|
||||
|
||||
### MultiDrawArrays
|
||||
|
||||
```cpp
|
||||
void MultiDrawArrays(PrimitiveType type, const int* first, const int* count, unsigned int drawCount)
|
||||
```
|
||||
|
||||
多重绘制。
|
||||
|
||||
### MultiDrawElements
|
||||
|
||||
```cpp
|
||||
void MultiDrawElements(PrimitiveType type, const int* count, unsigned int type_, const void* const* indices, unsigned int drawCount)
|
||||
```
|
||||
|
||||
多重索引绘制。
|
||||
|
||||
## 计算着色器
|
||||
|
||||
### DispatchIndirect
|
||||
|
||||
```cpp
|
||||
void DispatchIndirect(unsigned int buffer, size_t offset)
|
||||
```
|
||||
|
||||
间接分发计算着色器。
|
||||
|
||||
### DispatchCompute
|
||||
|
||||
```cpp
|
||||
void DispatchCompute(unsigned int x, unsigned int y, unsigned int z, unsigned int groupX, unsigned int groupY, unsigned int groupZ)
|
||||
```
|
||||
|
||||
分发计算着色器(带参数)。
|
||||
|
||||
## 内存屏障
|
||||
|
||||
### MemoryBarrier
|
||||
|
||||
```cpp
|
||||
void MemoryBarrier(unsigned int barriers)
|
||||
```
|
||||
|
||||
设置内存屏障。
|
||||
|
||||
### TextureBarrier
|
||||
|
||||
```cpp
|
||||
void TextureBarrier()
|
||||
```
|
||||
|
||||
纹理屏障。
|
||||
|
||||
## 纹理绑定
|
||||
|
||||
### BindTexture
|
||||
|
||||
```cpp
|
||||
void BindTexture(unsigned int target, unsigned int unit, unsigned int texture)
|
||||
```
|
||||
|
||||
绑定纹理到纹理单元。
|
||||
|
||||
### BindTextures
|
||||
|
||||
```cpp
|
||||
void BindTextures(unsigned int first, unsigned int count, const unsigned int* textures)
|
||||
```
|
||||
|
||||
批量绑定纹理。
|
||||
|
||||
### BindSampler
|
||||
|
||||
```cpp
|
||||
void BindSampler(unsigned int unit, unsigned int sampler)
|
||||
```
|
||||
|
||||
绑定采样器。
|
||||
|
||||
### BindSamplers
|
||||
|
||||
```cpp
|
||||
void BindSamplers(unsigned int first, unsigned int count, const unsigned int* samplers)
|
||||
```
|
||||
|
||||
批量绑定采样器。
|
||||
|
||||
### BindImageTexture
|
||||
|
||||
```cpp
|
||||
void BindImageTexture(unsigned int unit, unsigned int texture, int level, bool layered, int layer, unsigned int access, unsigned int format)
|
||||
```
|
||||
|
||||
绑定为 image texture。
|
||||
|
||||
## 缓冲区绑定
|
||||
|
||||
### BindBufferBase
|
||||
|
||||
```cpp
|
||||
void BindBufferBase(unsigned int target, unsigned int index, unsigned int buffer)
|
||||
```
|
||||
|
||||
绑定到固定 binding point。
|
||||
|
||||
### BindBufferRange
|
||||
|
||||
```cpp
|
||||
void BindBufferRange(unsigned int target, unsigned int index, unsigned int buffer, size_t offset, size_t size)
|
||||
```
|
||||
|
||||
绑定到范围 binding point。
|
||||
|
||||
## OpenGL 状态
|
||||
|
||||
### Enable / Disable
|
||||
|
||||
```cpp
|
||||
void Enable(unsigned int cap)
|
||||
void Disable(unsigned int cap)
|
||||
void Enablei(unsigned int cap, unsigned int index)
|
||||
void Disablei(unsigned int cap, unsigned int index)
|
||||
```
|
||||
|
||||
启用/禁用 GL capability。
|
||||
|
||||
## Uniform 设置
|
||||
|
||||
### SetUniform1i / SetUniform1f
|
||||
|
||||
```cpp
|
||||
void SetUniform1i(int location, int v)
|
||||
void SetUniform1f(int location, float v)
|
||||
```
|
||||
|
||||
### SetUniform2f
|
||||
|
||||
```cpp
|
||||
void SetUniform2f(int location, float x, float y)
|
||||
```
|
||||
|
||||
### SetUniform3f
|
||||
|
||||
```cpp
|
||||
void SetUniform3f(int location, float x, float y, float z)
|
||||
```
|
||||
|
||||
### SetUniform4f
|
||||
|
||||
```cpp
|
||||
void SetUniform4f(int location, float x, float y, float z, float w)
|
||||
```
|
||||
|
||||
### SetUniform1fv / SetUniform2fv / SetUniform3fv / SetUniform4fv
|
||||
|
||||
```cpp
|
||||
void SetUniform1fv(int location, int count, const float* v)
|
||||
void SetUniform2fv(int location, int count, const float* v)
|
||||
void SetUniform3fv(int location, int count, const float* v)
|
||||
void SetUniform4fv(int location, int count, const float* v)
|
||||
```
|
||||
|
||||
### SetUniformMatrix4fv
|
||||
|
||||
```cpp
|
||||
void SetUniformMatrix4fv(int location, int count, bool transpose, const float* v)
|
||||
```
|
||||
|
||||
## Shader 程序
|
||||
|
||||
### UseProgram
|
||||
|
||||
```cpp
|
||||
void UseProgram(unsigned int program)
|
||||
```
|
||||
|
||||
使用 program。
|
||||
|
||||
### BindFragDataLocation
|
||||
|
||||
```cpp
|
||||
void BindFragDataLocation(unsigned int program, unsigned int colorNumber, const char* name)
|
||||
void BindFragDataLocationIndexed(unsigned int program, unsigned int colorNumber, unsigned int index, const char* name)
|
||||
```
|
||||
|
||||
设置颜色输出绑定。
|
||||
|
||||
## 查询
|
||||
|
||||
### BeginQuery / EndQuery
|
||||
|
||||
```cpp
|
||||
void BeginQuery(unsigned int target, unsigned int id)
|
||||
void EndQuery(unsigned int target)
|
||||
```
|
||||
|
||||
开始/结束查询。
|
||||
|
||||
### GetQueryObjectiv / GetQueryObjectuiv
|
||||
|
||||
```cpp
|
||||
void GetQueryObjectiv(unsigned int id, unsigned int pname, int* params)
|
||||
void GetQueryObjectuiv(unsigned int id, unsigned int pname, unsigned int* params)
|
||||
```
|
||||
|
||||
获取查询结果。
|
||||
|
||||
## Framebuffer 操作
|
||||
|
||||
### ReadPixels
|
||||
|
||||
```cpp
|
||||
void ReadPixels(int x, int y, int width, int height, unsigned int format, unsigned int type, void* data)
|
||||
```
|
||||
|
||||
读取像素。
|
||||
|
||||
### BlitFramebuffer
|
||||
|
||||
```cpp
|
||||
void BlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, unsigned int mask, unsigned int filter)
|
||||
```
|
||||
|
||||
Blit 帧缓冲区。
|
||||
|
||||
### CopyImageSubData
|
||||
|
||||
```cpp
|
||||
void CopyImageSubData(unsigned int srcName, unsigned int srcTarget, int srcLevel, int srcX, int srcY, int srcZ, unsigned int dstName, unsigned int dstTarget, int dstLevel, int dstX, int dstY, int dstZ, int width, int height, int depth)
|
||||
```
|
||||
|
||||
复制图像子数据。
|
||||
|
||||
### InvalidateFramebuffer
|
||||
|
||||
```cpp
|
||||
void InvalidateFramebuffer(unsigned int target, unsigned int count, const unsigned int* attachments)
|
||||
void InvalidateSubFramebuffer(unsigned int target, unsigned int count, const unsigned int* attachments, int x, int y, int width, int height)
|
||||
```
|
||||
|
||||
使帧缓冲区失效。
|
||||
|
||||
## 调试
|
||||
|
||||
### PushDebugGroup / PopDebugGroup
|
||||
|
||||
```cpp
|
||||
void PushDebugGroup(unsigned int source, unsigned int id, int length, const char* message)
|
||||
void PopDebugGroup()
|
||||
```
|
||||
|
||||
推送/弹出调试组。
|
||||
21
docs/api/rhi/opengl/command-list/set-blend-factor.md
Normal file
21
docs/api/rhi/opengl/command-list/set-blend-factor.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# OpenGLCommandList::SetBlendFactor
|
||||
|
||||
```cpp
|
||||
void SetBlendFactor(const float factor[4])
|
||||
```
|
||||
|
||||
设置混合因子。
|
||||
|
||||
**参数:**
|
||||
- `factor` - 混合因子数组 [r, g, b, a]
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
float factor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
commandList->SetBlendFactor(factor);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
24
docs/api/rhi/opengl/command-list/set-blend-state.md
Normal file
24
docs/api/rhi/opengl/command-list/set-blend-state.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# OpenGLCommandList::SetBlendState
|
||||
|
||||
```cpp
|
||||
void SetBlendState(const BlendState& state)
|
||||
```
|
||||
|
||||
设置混合状态。
|
||||
|
||||
**参数:**
|
||||
- `state` - 混合状态结构
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
BlendState state;
|
||||
state.enable = true;
|
||||
state.srcBlend = BlendFunc::SrcAlpha;
|
||||
state.dstBlend = BlendFunc::InvSrcAlpha;
|
||||
commandList->SetBlendState(state);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
24
docs/api/rhi/opengl/command-list/set-depth-stencil-state.md
Normal file
24
docs/api/rhi/opengl/command-list/set-depth-stencil-state.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# OpenGLCommandList::SetDepthStencilState
|
||||
|
||||
```cpp
|
||||
void SetDepthStencilState(const DepthStencilState& state)
|
||||
```
|
||||
|
||||
设置深度模板状态。
|
||||
|
||||
**参数:**
|
||||
- `state` - 深度模板状态结构
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
DepthStencilState state;
|
||||
state.depthEnable = true;
|
||||
state.depthWriteEnable = true;
|
||||
state.depthFunc = ComparisonFunc::Less;
|
||||
commandList->SetDepthStencilState(state);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
22
docs/api/rhi/opengl/command-list/set-index-buffer.md
Normal file
22
docs/api/rhi/opengl/command-list/set-index-buffer.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenGLCommandList::SetIndexBuffer
|
||||
|
||||
```cpp
|
||||
void SetIndexBuffer(void* buffer, uint64_t offset, Format format)
|
||||
```
|
||||
|
||||
设置索引缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `buffer` - 缓冲区指针
|
||||
- `offset` - 数据偏移
|
||||
- `format` - 索引格式
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->SetIndexBuffer(indexBuffer, 0, Format::R32_UINT);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
20
docs/api/rhi/opengl/command-list/set-pipeline-state.md
Normal file
20
docs/api/rhi/opengl/command-list/set-pipeline-state.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLCommandList::SetPipelineState
|
||||
|
||||
```cpp
|
||||
void SetPipelineState(void* pipelineState)
|
||||
```
|
||||
|
||||
设置渲染管线状态。
|
||||
|
||||
**参数:**
|
||||
- `pipelineState` - 管线状态对象指针
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->SetPipelineState(pipelineState);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
20
docs/api/rhi/opengl/command-list/set-primitive-topology.md
Normal file
20
docs/api/rhi/opengl/command-list/set-primitive-topology.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLCommandList::SetPrimitiveTopology
|
||||
|
||||
```cpp
|
||||
void SetPrimitiveTopology(PrimitiveTopology topology)
|
||||
```
|
||||
|
||||
设置图元拓扑类型。
|
||||
|
||||
**参数:**
|
||||
- `topology` - 图元拓扑类型
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->SetPrimitiveTopology(PrimitiveTopology::TriangleList);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
23
docs/api/rhi/opengl/command-list/set-render-targets.md
Normal file
23
docs/api/rhi/opengl/command-list/set-render-targets.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# OpenGLCommandList::SetRenderTargets
|
||||
|
||||
```cpp
|
||||
void SetRenderTargets(uint32_t count, void** renderTargets, void* depthStencil = nullptr)
|
||||
```
|
||||
|
||||
设置渲染目标。
|
||||
|
||||
**参数:**
|
||||
- `count` - 渲染目标数量
|
||||
- `renderTargets` - 渲染目标指针数组
|
||||
- `depthStencil` - 深度模板缓冲区指针(可选)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
void* targets[1] = { colorTarget };
|
||||
commandList->SetRenderTargets(1, targets, depthStencil);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
23
docs/api/rhi/opengl/command-list/set-scissor-rect.md
Normal file
23
docs/api/rhi/opengl/command-list/set-scissor-rect.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# OpenGLCommandList::SetScissorRect
|
||||
|
||||
```cpp
|
||||
void SetScissorRect(const Rect& rect)
|
||||
```
|
||||
|
||||
设置裁剪矩形。
|
||||
|
||||
**参数:**
|
||||
- `rect` - 裁剪矩形结构
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Rect rect;
|
||||
rect.x = 0; rect.y = 0;
|
||||
rect.width = 800; rect.height = 600;
|
||||
commandList->SetScissorRect(rect);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
22
docs/api/rhi/opengl/command-list/set-scissor-rects.md
Normal file
22
docs/api/rhi/opengl/command-list/set-scissor-rects.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenGLCommandList::SetScissorRects
|
||||
|
||||
```cpp
|
||||
void SetScissorRects(uint32_t count, const Rect* rects)
|
||||
```
|
||||
|
||||
批量设置裁剪矩形。
|
||||
|
||||
**参数:**
|
||||
- `count` - 裁剪矩形数量
|
||||
- `rects` - 裁剪矩形数组指针
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Rect rects[2] = { ... };
|
||||
commandList->SetScissorRects(2, rects);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
20
docs/api/rhi/opengl/command-list/set-stencil-ref.md
Normal file
20
docs/api/rhi/opengl/command-list/set-stencil-ref.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLCommandList::SetStencilRef
|
||||
|
||||
```cpp
|
||||
void SetStencilRef(uint8_t ref)
|
||||
```
|
||||
|
||||
设置模板测试参考值。
|
||||
|
||||
**参数:**
|
||||
- `ref` - 模板参考值
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->SetStencilRef(1);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
23
docs/api/rhi/opengl/command-list/set-vertex-buffer.md
Normal file
23
docs/api/rhi/opengl/command-list/set-vertex-buffer.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# OpenGLCommandList::SetVertexBuffer
|
||||
|
||||
```cpp
|
||||
void SetVertexBuffer(uint32_t slot, void* buffer, uint64_t offset, uint32_t stride)
|
||||
```
|
||||
|
||||
设置单个顶点缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `slot` - 顶点缓冲区槽位
|
||||
- `buffer` - 缓冲区指针
|
||||
- `offset` - 数据偏移
|
||||
- `stride` - 顶点跨度
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->SetVertexBuffer(0, vertexBuffer, 0, sizeof(Vertex));
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
24
docs/api/rhi/opengl/command-list/set-vertex-buffers.md
Normal file
24
docs/api/rhi/opengl/command-list/set-vertex-buffers.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# OpenGLCommandList::SetVertexBuffers
|
||||
|
||||
```cpp
|
||||
void SetVertexBuffers(uint32_t startSlot, uint32_t count, const uint64_t* buffers, const uint64_t* offsets, const uint32_t* strides)
|
||||
```
|
||||
|
||||
批量设置顶点缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `startSlot` - 起始槽位
|
||||
- `count` - 缓冲区数量
|
||||
- `buffers` - 缓冲区指针数组
|
||||
- `offsets` - 偏移数组
|
||||
- `strides` - 跨度数组
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->SetVertexBuffers(0, 2, buffers, offsets, strides);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
24
docs/api/rhi/opengl/command-list/set-viewport.md
Normal file
24
docs/api/rhi/opengl/command-list/set-viewport.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# OpenGLCommandList::SetViewport
|
||||
|
||||
```cpp
|
||||
void SetViewport(const Viewport& viewport)
|
||||
```
|
||||
|
||||
设置视口。
|
||||
|
||||
**参数:**
|
||||
- `viewport` - 视口结构
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Viewport viewport;
|
||||
viewport.x = 0; viewport.y = 0;
|
||||
viewport.width = 800; viewport.height = 600;
|
||||
viewport.minDepth = 0.0f; viewport.maxDepth = 1.0f;
|
||||
commandList->SetViewport(viewport);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
22
docs/api/rhi/opengl/command-list/set-viewports.md
Normal file
22
docs/api/rhi/opengl/command-list/set-viewports.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenGLCommandList::SetViewports
|
||||
|
||||
```cpp
|
||||
void SetViewports(uint32_t count, const Viewport* viewports)
|
||||
```
|
||||
|
||||
批量设置视口。
|
||||
|
||||
**参数:**
|
||||
- `count` - 视口数量
|
||||
- `viewports` - 视口数组指针
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
Viewport viewports[2] = { ... };
|
||||
commandList->SetViewports(2, viewports);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
22
docs/api/rhi/opengl/command-list/transition-barrier.md
Normal file
22
docs/api/rhi/opengl/command-list/transition-barrier.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenGLCommandList::TransitionBarrier
|
||||
|
||||
```cpp
|
||||
void TransitionBarrier(void* resource, ResourceStates stateBefore, ResourceStates stateAfter)
|
||||
```
|
||||
|
||||
设置资源状态转换屏障。
|
||||
|
||||
**参数:**
|
||||
- `resource` - 资源指针
|
||||
- `stateBefore` - 转换前状态
|
||||
- `stateAfter` - 转换后状态
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandList->TransitionBarrier(texture, ResourceStates::RenderTarget, ResourceStates::Common);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandList](command-list.md) - 返回类总览
|
||||
24
docs/api/rhi/opengl/command-queue/command-queue.md
Normal file
24
docs/api/rhi/opengl/command-queue/command-queue.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# OpenGLCommandQueue
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**描述**: OpenGL 命令队列实现,继承自 `RHICommandQueue`。
|
||||
|
||||
## 方法列表
|
||||
|
||||
| 方法 | 文档 |
|
||||
|------|------|
|
||||
| `Shutdown` | [详细文档](../../../threading/task-system/shutdown.md) |
|
||||
| `ExecuteCommandLists` | [详细文档](execute-command-lists.md) |
|
||||
| `Signal` | [详细文档](signal.md) |
|
||||
| `Wait` | [详细文档](../../../threading/task-group/wait.md) |
|
||||
| `GetCompletedValue` | [详细文档](get-completed-value.md) |
|
||||
| `WaitForIdle` | [详细文档](wait-for-idle.md) |
|
||||
| `GetType` | [详细文档](../../shader/get-type.md) |
|
||||
| `GetTimestampFrequency` | [详细文档](get-timestamp-frequency.md) |
|
||||
| `GetNativeHandle` | [详细文档](../../buffer/get-native-handle.md) |
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGL 后端总览](../overview.md)
|
||||
- [RHICommandQueue](../../command-queue/command-queue.md) - 抽象命令队列接口
|
||||
22
docs/api/rhi/opengl/command-queue/execute-command-lists.md
Normal file
22
docs/api/rhi/opengl/command-queue/execute-command-lists.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenGLCommandQueue::ExecuteCommandLists
|
||||
|
||||
```cpp
|
||||
void ExecuteCommandLists(uint32_t count, void** lists)
|
||||
```
|
||||
|
||||
执行命令列表。
|
||||
|
||||
**参数:**
|
||||
- `count` - 命令列表数量
|
||||
- `lists` - 命令列表指针数组
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
void* lists[] = { commandList };
|
||||
commandQueue->ExecuteCommandLists(1, lists);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandQueue](command-queue.md) - 返回类总览
|
||||
19
docs/api/rhi/opengl/command-queue/get-completed-value.md
Normal file
19
docs/api/rhi/opengl/command-queue/get-completed-value.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLCommandQueue::GetCompletedValue
|
||||
|
||||
```cpp
|
||||
uint64_t GetCompletedValue()
|
||||
```
|
||||
|
||||
获取已完成的值。
|
||||
|
||||
**返回:** 已完成的围栏值
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
uint64_t value = commandQueue->GetCompletedValue();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandQueue](command-queue.md) - 返回类总览
|
||||
19
docs/api/rhi/opengl/command-queue/get-timestamp-frequency.md
Normal file
19
docs/api/rhi/opengl/command-queue/get-timestamp-frequency.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLCommandQueue::GetTimestampFrequency
|
||||
|
||||
```cpp
|
||||
uint64_t GetTimestampFrequency() const
|
||||
```
|
||||
|
||||
获取时间戳频率。
|
||||
|
||||
**返回:** 时间戳频率(Hz)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
uint64_t frequency = commandQueue->GetTimestampFrequency();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandQueue](command-queue.md) - 返回类总览
|
||||
21
docs/api/rhi/opengl/command-queue/signal.md
Normal file
21
docs/api/rhi/opengl/command-queue/signal.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# OpenGLCommandQueue::Signal
|
||||
|
||||
```cpp
|
||||
void Signal(RHIFence* fence, uint64_t value)
|
||||
```
|
||||
|
||||
发送信号。
|
||||
|
||||
**参数:**
|
||||
- `fence` - 围栏指针
|
||||
- `value` - 信号值
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandQueue->Signal(fence, 1);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandQueue](command-queue.md) - 返回类总览
|
||||
17
docs/api/rhi/opengl/command-queue/wait-for-idle.md
Normal file
17
docs/api/rhi/opengl/command-queue/wait-for-idle.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# OpenGLCommandQueue::WaitForIdle
|
||||
|
||||
```cpp
|
||||
void WaitForIdle()
|
||||
```
|
||||
|
||||
等待命令队列空闲。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
commandQueue->WaitForIdle();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLCommandQueue](command-queue.md) - 返回类总览
|
||||
20
docs/api/rhi/opengl/depth-stencil-view/bind-framebuffer.md
Normal file
20
docs/api/rhi/opengl/depth-stencil-view/bind-framebuffer.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLDepthStencilView::BindFramebuffer
|
||||
|
||||
```cpp
|
||||
static void BindFramebuffer(unsigned int framebuffer)
|
||||
```
|
||||
|
||||
静态方法,将指定帧缓冲区绑定为当前深度模板帧缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `framebuffer` - 帧缓冲区 ID(0 表示解除绑定)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLDepthStencilView::BindFramebuffer(dsv.GetFramebuffer());
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览
|
||||
@@ -0,0 +1,21 @@
|
||||
# OpenGLDepthStencilView::ClearDepthStencil
|
||||
|
||||
```cpp
|
||||
void ClearDepthStencil(float depth, uint8_t stencil)
|
||||
```
|
||||
|
||||
同时清除深度和模板缓冲区。
|
||||
|
||||
**参数:**
|
||||
- `depth` - 深度值(通常为 0.0 到 1.0)
|
||||
- `stencil` - 模板值(0-255)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
dsv.ClearDepthStencil(1.0f, 0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览
|
||||
20
docs/api/rhi/opengl/depth-stencil-view/clear-depth.md
Normal file
20
docs/api/rhi/opengl/depth-stencil-view/clear-depth.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLDepthStencilView::ClearDepth
|
||||
|
||||
```cpp
|
||||
void ClearDepth(float depth)
|
||||
```
|
||||
|
||||
清除深度缓冲区的深度值。
|
||||
|
||||
**参数:**
|
||||
- `depth` - 深度值(通常为 0.0 到 1.0)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
dsv.ClearDepth(1.0f);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览
|
||||
20
docs/api/rhi/opengl/depth-stencil-view/clear-stencil.md
Normal file
20
docs/api/rhi/opengl/depth-stencil-view/clear-stencil.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLDepthStencilView::ClearStencil
|
||||
|
||||
```cpp
|
||||
void ClearStencil(uint8_t stencil)
|
||||
```
|
||||
|
||||
清除模板缓冲区的模板值。
|
||||
|
||||
**参数:**
|
||||
- `stencil` - 模板值(0-255)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
dsv.ClearStencil(0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览
|
||||
28
docs/api/rhi/opengl/depth-stencil-view/depth-stencil-view.md
Normal file
28
docs/api/rhi/opengl/depth-stencil-view/depth-stencil-view.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# OpenGLDepthStencilView
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**描述**: OpenGL 深度模板视图实现。
|
||||
|
||||
## 方法列表
|
||||
|
||||
| 方法 | 文档 |
|
||||
|------|------|
|
||||
| `Initialize` | [详细文档](../../../threading/task-system/initialize.md) |
|
||||
| `InitializeCubemap` | [详细文档](initialize-cubemap.md) |
|
||||
| `Shutdown` | [详细文档](../../../threading/task-system/shutdown.md) |
|
||||
| `Bind` | [详细文档](../../shader/bind.md) |
|
||||
| `Unbind` | [详细文档](../../shader/unbind.md) |
|
||||
| `ClearDepth` | [详细文档](clear-depth.md) |
|
||||
| `ClearStencil` | [详细文档](clear-stencil.md) |
|
||||
| `ClearDepthStencil` | [详细文档](clear-depth-stencil.md) |
|
||||
| `GetFramebuffer` | [详细文档](get-framebuffer.md) |
|
||||
| `GetTexture` | [详细文档](get-texture.md) |
|
||||
| `GetMipLevel` | [详细文档](get-mip-level.md) |
|
||||
| `GetWidth` / `GetHeight` | [详细文档](../../buffer/get-size.md) |
|
||||
| `BindFramebuffer` | [详细文档](bind-framebuffer.md) |
|
||||
| `UnbindFramebuffer` | [详细文档](unbind-framebuffer.md) |
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGL 后端总览](../overview.md)
|
||||
19
docs/api/rhi/opengl/depth-stencil-view/get-framebuffer.md
Normal file
19
docs/api/rhi/opengl/depth-stencil-view/get-framebuffer.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLDepthStencilView::GetFramebuffer
|
||||
|
||||
```cpp
|
||||
unsigned int GetFramebuffer() const
|
||||
```
|
||||
|
||||
获取帧缓冲区对象 ID。
|
||||
|
||||
**返回:** `unsigned int` - 帧缓冲区 ID
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
unsigned int fbo = dsv.GetFramebuffer();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览
|
||||
19
docs/api/rhi/opengl/depth-stencil-view/get-mip-level.md
Normal file
19
docs/api/rhi/opengl/depth-stencil-view/get-mip-level.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLDepthStencilView::GetMipLevel
|
||||
|
||||
```cpp
|
||||
int GetMipLevel() const
|
||||
```
|
||||
|
||||
获取 mipmap 级别。
|
||||
|
||||
**返回:** `int` - mip 级别
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
int mipLevel = dsv.GetMipLevel();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览
|
||||
19
docs/api/rhi/opengl/depth-stencil-view/get-texture.md
Normal file
19
docs/api/rhi/opengl/depth-stencil-view/get-texture.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLDepthStencilView::GetTexture
|
||||
|
||||
```cpp
|
||||
unsigned int GetTexture() const
|
||||
```
|
||||
|
||||
获取关联的纹理对象 ID。
|
||||
|
||||
**返回:** `unsigned int` - 纹理 ID
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
unsigned int tex = dsv.GetTexture();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览
|
||||
25
docs/api/rhi/opengl/depth-stencil-view/initialize-cubemap.md
Normal file
25
docs/api/rhi/opengl/depth-stencil-view/initialize-cubemap.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# OpenGLDepthStencilView::InitializeCubemap
|
||||
|
||||
```cpp
|
||||
bool InitializeCubemap(unsigned int cubemap, int face, int mipLevel = 0)
|
||||
```
|
||||
|
||||
初始化立方体贴图的深度模板视图。
|
||||
|
||||
**参数:**
|
||||
- `cubemap` - 立方体贴图对象 ID
|
||||
- `face` - 立方体贴面索引(0-5)
|
||||
- `mipLevel` - mipmap 级别(默认为 0)
|
||||
|
||||
**返回:** `bool` - 成功返回 true,失败返回 false
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLDepthStencilView dsv;
|
||||
dsv.InitializeCubemap(cubemapTexture, 0, 0);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览
|
||||
17
docs/api/rhi/opengl/depth-stencil-view/unbind-framebuffer.md
Normal file
17
docs/api/rhi/opengl/depth-stencil-view/unbind-framebuffer.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# OpenGLDepthStencilView::UnbindFramebuffer
|
||||
|
||||
```cpp
|
||||
static void UnbindFramebuffer()
|
||||
```
|
||||
|
||||
静态方法,解除当前深度模板帧缓冲区的绑定。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLDepthStencilView::UnbindFramebuffer();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览
|
||||
28
docs/api/rhi/opengl/device/create-render-window.md
Normal file
28
docs/api/rhi/opengl/device/create-render-window.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# OpenGLDevice::CreateRenderWindow
|
||||
|
||||
```cpp
|
||||
bool CreateRenderWindow(int width, int height, const char* title, bool enableDebug = false)
|
||||
```
|
||||
|
||||
创建并初始化一个新的 GLFW 窗口,同时初始化 OpenGL 上下文。
|
||||
|
||||
**参数:**
|
||||
- `width` - 窗口宽度(像素)
|
||||
- `height` - 窗口高度(像素)
|
||||
- `title` - 窗口标题
|
||||
- `enableDebug` - 是否启用 OpenGL 调试上下文(可选,默认为 false)
|
||||
|
||||
**返回:** `bool` - 成功返回 true,失败返回 false
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLDevice device;
|
||||
if (device.CreateRenderWindow(1280, 720, "XCEngine", false)) {
|
||||
// 窗口创建成功,可以开始渲染循环
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDevice](device.md) - 返回类总览
|
||||
37
docs/api/rhi/opengl/device/device.md
Normal file
37
docs/api/rhi/opengl/device/device.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# OpenGLDevice
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**描述**: OpenGL 设备的实现,继承自 `RHIDevice`。
|
||||
|
||||
## 方法列表
|
||||
|
||||
| 方法 | 文档 |
|
||||
|------|------|
|
||||
| `Initialize` | [详细文档](../../../threading/task-system/initialize.md) |
|
||||
| `Shutdown` | [详细文档](../../../threading/task-system/shutdown.md) |
|
||||
| `CreateRenderWindow` | [详细文档](create-render-window.md) |
|
||||
| `InitializeWithExistingWindow` | [详细文档](initialize-with-existing-window.md) |
|
||||
| `GetWindow` | [详细文档](get-window.md) |
|
||||
| `SwapBuffers` | [详细文档](swap-buffers.md) |
|
||||
| `PollEvents` | [详细文档](poll-events.md) |
|
||||
| `SetShouldClose` | [详细文档](set-should-close.md) |
|
||||
| `ShouldClose` | [详细文档](should-close.md) |
|
||||
| `CreateBuffer` | [详细文档](../../device/create-buffer.md) |
|
||||
| `CreateTexture` | [详细文档](../../device/create-texture.md) |
|
||||
| `CreateSwapChain` | [详细文档](../../device/create-swap-chain.md) |
|
||||
| `CreateCommandList` | [详细文档](../../device/create-command-list.md) |
|
||||
| `CreateCommandQueue` | [详细文档](../../device/create-command-queue.md) |
|
||||
| `CompileShader` | [详细文档](../../device/compile-shader.md) |
|
||||
| `CreatePipelineState` | [详细文档](../../device/create-pipeline-state.md) |
|
||||
| `CreateFence` | [详细文档](../../device/create-fence.md) |
|
||||
| `CreateSampler` | [详细文档](../../device/create-sampler.md) |
|
||||
| `GetCapabilities` | [详细文档](../../device/get-capabilities.md) |
|
||||
| `GetDeviceInfo` | [详细文档](../../device/get-device-info.md) |
|
||||
| `GetNativeDevice` | [详细文档](../../device/get-native-device.md) |
|
||||
| `GetNativeHandle` | [详细文档](../../buffer/get-native-handle.md) |
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGL 后端总览](../overview.md)
|
||||
- [RHIDevice](../../device/device.md) - 抽象设备接口
|
||||
22
docs/api/rhi/opengl/device/get-window.md
Normal file
22
docs/api/rhi/opengl/device/get-window.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenGLDevice::GetWindow
|
||||
|
||||
```cpp
|
||||
GLFWwindow* GetWindow() const
|
||||
```
|
||||
|
||||
获取关联的 GLFW 窗口指针。
|
||||
|
||||
**返回:** `GLFWwindow*` - GLFW 窗口指针
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
GLFWwindow* window = device.GetWindow();
|
||||
if (window) {
|
||||
glfwSetWindowTitle(window, "New Title");
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDevice](device.md) - 返回类总览
|
||||
@@ -0,0 +1,26 @@
|
||||
# OpenGLDevice::InitializeWithExistingWindow
|
||||
|
||||
```cpp
|
||||
bool InitializeWithExistingWindow(GLFWwindow* window)
|
||||
```
|
||||
|
||||
使用已有的 GLFW 窗口初始化 OpenGL 设备,不会创建新窗口或管理窗口生命周期。
|
||||
|
||||
**参数:**
|
||||
- `window` - 已存在的 GLFWwindow 指针
|
||||
|
||||
**返回:** `bool` - 成功返回 true,失败返回 false
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
GLFWwindow* existingWindow = glfwCreateWindow(1280, 720, "Existing", nullptr, nullptr);
|
||||
OpenGLDevice device;
|
||||
if (device.InitializeWithExistingWindow(existingWindow)) {
|
||||
// 使用已有窗口初始化设备
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDevice](device.md) - 返回类总览
|
||||
23
docs/api/rhi/opengl/device/poll-events.md
Normal file
23
docs/api/rhi/opengl/device/poll-events.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# OpenGLDevice::PollEvents
|
||||
|
||||
```cpp
|
||||
bool PollEvents()
|
||||
```
|
||||
|
||||
处理所有挂起的 GLFW 事件(窗口事件、输入事件等)。
|
||||
|
||||
**返回:** `bool` - 如果窗口应保持打开返回 true,如果窗口应关闭返回 false
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
while (device.PollEvents()) {
|
||||
// 渲染和交换缓冲区
|
||||
renderScene();
|
||||
device.SwapBuffers();
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDevice](device.md) - 返回类总览
|
||||
20
docs/api/rhi/opengl/device/set-should-close.md
Normal file
20
docs/api/rhi/opengl/device/set-should-close.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLDevice::SetShouldClose
|
||||
|
||||
```cpp
|
||||
void SetShouldClose(bool shouldClose)
|
||||
```
|
||||
|
||||
设置窗口是否应该关闭的标志。
|
||||
|
||||
**参数:**
|
||||
- `shouldClose` - true 表示窗口应该关闭,false 表示保持打开
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
device.SetShouldClose(true); // 请求关闭窗口
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDevice](device.md) - 返回类总览
|
||||
23
docs/api/rhi/opengl/device/should-close.md
Normal file
23
docs/api/rhi/opengl/device/should-close.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# OpenGLDevice::ShouldClose
|
||||
|
||||
```cpp
|
||||
bool ShouldClose() const
|
||||
```
|
||||
|
||||
检查窗口是否应该关闭。
|
||||
|
||||
**返回:** `bool` - 如果窗口应该关闭返回 true,否则返回 false
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
while (!device.ShouldClose()) {
|
||||
device.PollEvents();
|
||||
renderScene();
|
||||
device.SwapBuffers();
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDevice](device.md) - 返回类总览
|
||||
19
docs/api/rhi/opengl/device/swap-buffers.md
Normal file
19
docs/api/rhi/opengl/device/swap-buffers.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLDevice::SwapBuffers
|
||||
|
||||
```cpp
|
||||
void SwapBuffers()
|
||||
```
|
||||
|
||||
交换前后缓冲区,将渲染内容显示到屏幕上。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
// 渲染完成后交换缓冲区
|
||||
renderScene();
|
||||
device.SwapBuffers();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLDevice](device.md) - 返回类总览
|
||||
25
docs/api/rhi/opengl/fence/fence.md
Normal file
25
docs/api/rhi/opengl/fence/fence.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# OpenGLFence
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**描述**: OpenGL 栅栏同步实现,继承自 `RHIFence`。
|
||||
|
||||
## 方法列表
|
||||
|
||||
| 方法 | 文档 |
|
||||
|------|------|
|
||||
| `Initialize` | [详细文档](../../../threading/task-system/initialize.md) |
|
||||
| `Shutdown` | [详细文档](../../../threading/task-system/shutdown.md) |
|
||||
| `Signal` | [详细文档](signal.md) |
|
||||
| `Wait` | [详细文档](../../../threading/task-group/wait.md) |
|
||||
| `Reset` | [详细文档](../../../resources/resourcehandle/reset.md) |
|
||||
| `IsSignaled` | [详细文档](is-signaled.md) |
|
||||
| `GetStatus` | [详细文档](get-status.md) |
|
||||
| `GetCompletedValue` | [详细文档](get-completed-value.md) |
|
||||
| `GetCurrentValue` | [详细文档](get-current-value.md) |
|
||||
| `GetNativeHandle` | [详细文档](../../buffer/get-native-handle.md) |
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGL 后端总览](../overview.md)
|
||||
- [RHIFence](../../fence/fence.md) - 抽象栅栏接口
|
||||
19
docs/api/rhi/opengl/fence/get-completed-value.md
Normal file
19
docs/api/rhi/opengl/fence/get-completed-value.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLFence::GetCompletedValue
|
||||
|
||||
```cpp
|
||||
uint64_t GetCompletedValue() const override
|
||||
```
|
||||
|
||||
获取已完成的最大栅栏值。
|
||||
|
||||
**返回:** `uint64_t` - 已完成的栅栏值
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
uint64_t completed = fence.GetCompletedValue();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLFence](fence.md) - 返回类总览
|
||||
19
docs/api/rhi/opengl/fence/get-current-value.md
Normal file
19
docs/api/rhi/opengl/fence/get-current-value.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLFence::GetCurrentValue
|
||||
|
||||
```cpp
|
||||
uint64_t GetCurrentValue() const
|
||||
```
|
||||
|
||||
获取栅栏的当前值。
|
||||
|
||||
**返回:** `uint64_t` - 当前栅栏值
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
uint64_t current = fence.GetCurrentValue();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLFence](fence.md) - 返回类总览
|
||||
25
docs/api/rhi/opengl/fence/get-status.md
Normal file
25
docs/api/rhi/opengl/fence/get-status.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# OpenGLFence::GetStatus
|
||||
|
||||
```cpp
|
||||
FenceStatus GetStatus() const
|
||||
```
|
||||
|
||||
获取栅栏的当前状态。
|
||||
|
||||
**返回:** `FenceStatus` - 栅栏状态,可能的值:
|
||||
- `FenceStatus::Signaled` - 栅栏已signaled
|
||||
- `FenceStatus::Unsignaled` - 栅栏未signaled
|
||||
- `FenceStatus::Error` - 发生错误
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
FenceStatus status = fence.GetStatus();
|
||||
if (status == FenceStatus::Signaled) {
|
||||
// 操作已完成
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLFence](fence.md) - 返回类总览
|
||||
21
docs/api/rhi/opengl/fence/is-signaled.md
Normal file
21
docs/api/rhi/opengl/fence/is-signaled.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# OpenGLFence::IsSignaled
|
||||
|
||||
```cpp
|
||||
bool IsSignaled() const override
|
||||
```
|
||||
|
||||
检查栅栏是否处于 signaled 状态。
|
||||
|
||||
**返回:** `bool` - 如果栅栏已signaled返回 true,否则返回 false
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
if (fence.IsSignaled()) {
|
||||
// 可以安全地继续执行
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLFence](fence.md) - 返回类总览
|
||||
20
docs/api/rhi/opengl/fence/signal.md
Normal file
20
docs/api/rhi/opengl/fence/signal.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLFence::Signal
|
||||
|
||||
```cpp
|
||||
void Signal() override
|
||||
void Signal(uint64_t value) override
|
||||
```
|
||||
|
||||
将栅栏设置为 signaled 状态,通知等待的线程操作完成。
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLFence fence;
|
||||
fence.Initialize(false);
|
||||
fence.Signal();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLFence](fence.md) - 返回类总览
|
||||
@@ -1,135 +0,0 @@
|
||||
# OpenGLBuffer
|
||||
|
||||
OpenGL 缓冲区的实现,封装 OpenGL buffer object。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLBuffer.h>
|
||||
```
|
||||
|
||||
## 继承关系
|
||||
|
||||
```
|
||||
RHIBuffer (interface)
|
||||
└── OpenGLBuffer (implementation)
|
||||
```
|
||||
|
||||
## OpenGLBufferType 枚举
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `Vertex` | 顶点缓冲区 |
|
||||
| `Index` | 索引缓冲区 |
|
||||
| `Uniform` | Uniform 缓冲区 (UBO) |
|
||||
| `CopyRead` | 复制源缓冲区 |
|
||||
| `CopyWrite` | 复制目标缓冲区 |
|
||||
| `AtomicCounter` | 原子计数器缓冲区 |
|
||||
| `DispatchIndirect` | 间接计算调用缓冲区 |
|
||||
| `DrawIndirect` | 间接绘制缓冲区 |
|
||||
| `ShaderBindingTable` | 光线追踪 Shader 绑定表 |
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
### 构造函数与析构函数
|
||||
|
||||
#### `OpenGLBuffer()`
|
||||
|
||||
#### `~OpenGLBuffer() override`
|
||||
|
||||
### 初始化
|
||||
|
||||
#### `bool Initialize(OpenGLBufferType type, size_t size, const void* data = nullptr, bool dynamic = false)`
|
||||
通用初始化。
|
||||
- `type`: 缓冲区类型
|
||||
- `size`: 大小(字节)
|
||||
- `data`: 初始数据(可选)
|
||||
- `dynamic`: 是否动态更新
|
||||
|
||||
#### `bool InitializeVertexBuffer(const void* data, size_t size)`
|
||||
初始化顶点缓冲区。
|
||||
|
||||
#### `bool InitializeIndexBuffer(const void* data, size_t size)`
|
||||
初始化索引缓冲区。
|
||||
|
||||
#### `void Shutdown() override`
|
||||
|
||||
### 绑定操作
|
||||
|
||||
#### `void Bind() const`
|
||||
绑定缓冲区到当前 target。
|
||||
|
||||
#### `void Unbind() const`
|
||||
解除绑定。
|
||||
|
||||
#### `void BindBase(unsigned int target, unsigned int index) const`
|
||||
绑定到指定的 binding point(用于 UBO、SSBO 等)。
|
||||
|
||||
### 数据操作
|
||||
|
||||
#### `void* Map() override`
|
||||
映射缓冲区到 CPU。
|
||||
|
||||
#### `void Unmap() override`
|
||||
解除映射。
|
||||
|
||||
#### `void SetData(const void* data, size_t size, size_t offset = 0) override`
|
||||
更新缓冲区数据。
|
||||
|
||||
### 属性
|
||||
|
||||
#### `unsigned int GetID() const`
|
||||
获取 OpenGL buffer ID。
|
||||
|
||||
#### `uint64_t GetSize() const override`
|
||||
获取缓冲区大小。
|
||||
|
||||
#### `OpenGLBufferType GetType() const`
|
||||
获取缓冲区类型。
|
||||
|
||||
#### `bool IsDynamic() const`
|
||||
是否动态缓冲区。
|
||||
|
||||
#### `BufferType GetBufferType() const override / void SetBufferType(BufferType type) override`
|
||||
|
||||
#### `uint32_t GetStride() const override / void SetStride(uint32_t stride) override`
|
||||
|
||||
#### `void* GetNativeHandle() override`
|
||||
返回 `reinterpret_cast<void*>(static_cast<uintptr_t>(m_buffer))`
|
||||
|
||||
#### `ResourceStates GetState() const override`
|
||||
返回 `ResourceStates::Common`(OpenGL 无显式状态)
|
||||
|
||||
#### `const std::string& GetName() const override / void SetName(...) override`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_buffer` | `unsigned int` | GL buffer ID |
|
||||
| `m_size` | `size_t` | 大小 |
|
||||
| `m_isIndexBuffer` | `bool` | 是否索引缓冲区 |
|
||||
| `m_dynamic` | `bool` | 是否动态 |
|
||||
| `m_type` | `OpenGLBufferType` | 缓冲区类型 |
|
||||
| `m_bufferType` | `BufferType` | RHI 缓冲区类型 |
|
||||
| `m_stride` | `uint32_t` | 顶点步长 |
|
||||
| `m_name` | `std::string` | 名称 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
OpenGLBuffer vb;
|
||||
float vertices[] = { ... };
|
||||
vb.InitializeVertexBuffer(vertices, sizeof(vertices));
|
||||
vb.SetBufferType(BufferType::Vertex);
|
||||
vb.SetStride(sizeof(float) * 5);
|
||||
|
||||
OpenGLBuffer ib;
|
||||
uint16_t indices[] = { 0, 1, 2, ... };
|
||||
ib.InitializeIndexBuffer(indices, sizeof(indices));
|
||||
|
||||
// Bind and draw
|
||||
vb.Bind();
|
||||
ib.Bind();
|
||||
glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, 0);
|
||||
```
|
||||
@@ -1,308 +0,0 @@
|
||||
# OpenGLCommandList
|
||||
|
||||
OpenGL 命令列表实现。OpenGL 是立即模式 API,此类提供命令录制和批量提交的能力。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLCommandList.h>
|
||||
```
|
||||
|
||||
## 继承关系
|
||||
|
||||
```
|
||||
RHICommandList (interface)
|
||||
└── OpenGLCommandList (implementation)
|
||||
```
|
||||
|
||||
## 枚举
|
||||
|
||||
### PrimitiveType
|
||||
|
||||
| 值 | OpenGL 常量 |
|
||||
|----|-------------|
|
||||
| `Points` | `GL_POINTS` |
|
||||
| `Lines` | `GL_LINES` |
|
||||
| `LineStrip` | `GL_LINE_STRIP` |
|
||||
| `Triangles` | `GL_TRIANGLES` |
|
||||
| `TriangleStrip` | `GL_TRIANGLE_STRIP` |
|
||||
| `TriangleFan` | `GL_TRIANGLE_FAN` |
|
||||
| `LineListAdj` | `GL_LINES_ADJACENCY` |
|
||||
| `TriangleListAdj` | `GL_TRIANGLES_ADJACENCY` |
|
||||
| `Patch` | `GL_PATCHES` |
|
||||
|
||||
### ClearFlag
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `Color` | 清除颜色缓冲区 |
|
||||
| `Depth` | 清除深度缓冲区 |
|
||||
| `Stencil` | 清除模板缓冲区 |
|
||||
|
||||
支持 `|` 操作符合并。
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
### 生命周期
|
||||
|
||||
#### `void Shutdown() override`
|
||||
|
||||
#### `void Reset() override`
|
||||
重置命令列表。
|
||||
|
||||
#### `void Close() override`
|
||||
关闭命令列表。
|
||||
|
||||
### 清除操作
|
||||
|
||||
#### `void Clear(float r, float g, float b, float a, unsigned int buffers)`
|
||||
清除指定缓冲区。
|
||||
|
||||
#### `void ClearColor(float r, float g, float b, float a)`
|
||||
|
||||
#### `void ClearDepth(float depth)`
|
||||
|
||||
#### `void ClearStencil(int stencil)`
|
||||
|
||||
#### `void ClearDepthStencil(float depth, int stencil)`
|
||||
|
||||
### RHI 接口实现
|
||||
|
||||
#### `void SetPipelineState(void* pipelineState) override`
|
||||
|
||||
#### `void SetVertexBuffer(uint32_t slot, void* buffer, uint64_t offset, uint32_t stride) override`
|
||||
|
||||
#### `void SetVertexBuffers(uint32_t startSlot, uint32_t count, ...) override`
|
||||
|
||||
#### `void SetIndexBuffer(void* buffer, uint64_t offset, Format format) override`
|
||||
|
||||
#### `void TransitionBarrier(void* resource, ...) override`
|
||||
OpenGL 实现为空(无显式状态管理)。
|
||||
|
||||
#### `void SetPrimitiveTopology(PrimitiveTopology topology) override`
|
||||
|
||||
#### `void SetViewport(const Viewport& viewport) override`
|
||||
|
||||
#### `void SetViewports(uint32_t count, const Viewport* viewports) override`
|
||||
|
||||
#### `void SetScissorRect(const Rect& rect) override`
|
||||
|
||||
#### `void SetScissorRects(uint32_t count, const Rect* rects) override`
|
||||
|
||||
#### `void SetRenderTargets(uint32_t count, void** renderTargets, void* depthStencil) override`
|
||||
|
||||
#### `void SetDepthStencilState(const DepthStencilState& state) override`
|
||||
|
||||
#### `void SetStencilRef(uint8_t ref) override`
|
||||
|
||||
#### `void SetBlendState(const BlendState& state) override`
|
||||
|
||||
#### `void SetBlendFactor(const float factor[4]) override`
|
||||
|
||||
#### `void ClearRenderTarget(void* renderTarget, const float color[4]) override`
|
||||
|
||||
#### `void ClearDepthStencil(void* depthStencil, float depth, uint8_t stencil) override`
|
||||
|
||||
#### `void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t startVertex, uint32_t startInstance) override`
|
||||
|
||||
#### `void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t startIndex, int32_t baseVertex, uint32_t startInstance) override`
|
||||
|
||||
#### `void Dispatch(uint32_t x, uint32_t y, uint32_t z) override`
|
||||
|
||||
#### `void CopyResource(void* dst, void* src) override`
|
||||
|
||||
### OpenGL 特有方法
|
||||
|
||||
#### `void SetVertexBuffer(unsigned int buffer, size_t offset, size_t stride)`
|
||||
直接设置顶点缓冲区(OpenGL 逃逸)。
|
||||
|
||||
#### `void SetVertexBuffers(unsigned int startSlot, unsigned int count, const unsigned int* buffers, const size_t* offsets, const size_t* strides)`
|
||||
|
||||
#### `void SetIndexBuffer(unsigned int buffer, unsigned int type)`
|
||||
|
||||
#### `void SetIndexBuffer(unsigned int buffer, unsigned int type, size_t offset)`
|
||||
|
||||
#### `void BindVertexArray(unsigned int vao)`
|
||||
|
||||
#### `void BindVertexArray(unsigned int vao, unsigned int indexBuffer, unsigned int indexType)`
|
||||
|
||||
#### `void UseShader(unsigned int program)`
|
||||
|
||||
### 视口与裁剪
|
||||
|
||||
#### `void SetViewport(int x, int y, int width, int height)`
|
||||
|
||||
#### `void SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth)`
|
||||
|
||||
#### `void SetViewports(unsigned int count, const float* viewports)`
|
||||
|
||||
#### `void SetScissor(int x, int y, int width, int height)`
|
||||
|
||||
#### `void SetScissorRects(unsigned int count, const int* rects)`
|
||||
|
||||
#### `void EnableScissorTest(bool enable)`
|
||||
|
||||
### 深度测试
|
||||
|
||||
#### `void EnableDepthTest(bool enable)`
|
||||
|
||||
#### `void EnableDepthWrite(bool enable)`
|
||||
|
||||
#### `void SetDepthFunc(unsigned int func)`
|
||||
|
||||
### 模板测试
|
||||
|
||||
#### `void EnableStencilTest(bool enable)`
|
||||
|
||||
#### `void SetStencilFunc(unsigned int func, int ref, unsigned int mask)`
|
||||
|
||||
#### `void SetStencilOp(unsigned int fail, unsigned int zfail, unsigned int zpass)`
|
||||
|
||||
### 混合
|
||||
|
||||
#### `void EnableBlending(bool enable)`
|
||||
|
||||
#### `void SetBlendFunc(unsigned int src, unsigned int dst)`
|
||||
|
||||
#### `void SetBlendFuncSeparate(unsigned int srcRGB, unsigned int dstRGB, unsigned int srcAlpha, unsigned int dstAlpha)`
|
||||
|
||||
#### `void SetBlendEquation(unsigned int mode)`
|
||||
|
||||
#### `void SetBlendColor(float r, float g, float b, float a)`
|
||||
|
||||
### 光栅化
|
||||
|
||||
#### `void EnableCulling(bool enable)`
|
||||
|
||||
#### `void SetCullFace(unsigned int face)`
|
||||
|
||||
#### `void SetFrontFace(unsigned int face)`
|
||||
|
||||
#### `void SetPolygonMode(unsigned int mode)`
|
||||
|
||||
#### `void SetPolygonOffset(float factor, float units)`
|
||||
|
||||
#### `void SetPrimitiveType(PrimitiveType type)`
|
||||
|
||||
### 绘制
|
||||
|
||||
#### `void Draw(PrimitiveType type, unsigned int vertexCount, unsigned int startVertex)`
|
||||
|
||||
#### `void DrawInstanced(PrimitiveType type, unsigned int vertexCount, unsigned int instanceCount, unsigned int startVertex, unsigned int startInstance)`
|
||||
|
||||
#### `void DrawIndexed(PrimitiveType type, unsigned int indexCount, unsigned int startIndex, int baseVertex)`
|
||||
|
||||
#### `void DrawIndexedInstanced(PrimitiveType type, unsigned int indexCount, unsigned int instanceCount, unsigned int startIndex, int baseVertex, unsigned int startInstance)`
|
||||
|
||||
#### `void DrawIndirect(...)`
|
||||
|
||||
#### `void DrawIndexedIndirect(...)`
|
||||
|
||||
#### `void MultiDrawArrays(PrimitiveType type, const int* first, const int* count, unsigned int drawCount)`
|
||||
|
||||
#### `void MultiDrawElements(...)`
|
||||
|
||||
### 计算着色器
|
||||
|
||||
#### `void DispatchIndirect(unsigned int buffer, size_t offset)`
|
||||
|
||||
#### `void DispatchCompute(unsigned int x, unsigned int y, unsigned int z, unsigned int groupX, unsigned int groupY, unsigned int groupZ)`
|
||||
|
||||
### 内存屏障
|
||||
|
||||
#### `void MemoryBarrier(unsigned int barriers)`
|
||||
|
||||
#### `void TextureBarrier()`
|
||||
|
||||
### 纹理绑定
|
||||
|
||||
#### `void BindTexture(unsigned int target, unsigned int unit, unsigned int texture)`
|
||||
|
||||
#### `void BindTextures(unsigned int first, unsigned int count, const unsigned int* textures)`
|
||||
|
||||
#### `void BindSampler(unsigned int unit, unsigned int sampler)`
|
||||
|
||||
#### `void BindSamplers(unsigned int first, unsigned int count, const unsigned int* samplers)`
|
||||
|
||||
#### `void BindImageTexture(...)`
|
||||
|
||||
### 缓冲区绑定
|
||||
|
||||
#### `void BindBufferBase(unsigned int target, unsigned int index, unsigned int buffer)`
|
||||
|
||||
#### `void BindBufferRange(unsigned int target, unsigned int index, unsigned int buffer, size_t offset, size_t size)`
|
||||
|
||||
### OpenGL 状态
|
||||
|
||||
#### `void Enable(unsigned int cap)`
|
||||
|
||||
#### `void Disable(unsigned int cap)`
|
||||
|
||||
#### `void Enablei(unsigned int cap, unsigned int index)`
|
||||
|
||||
#### `void Disablei(unsigned int cap, unsigned int index)`
|
||||
|
||||
### Uniform 设置
|
||||
|
||||
#### `void SetUniform1i(int location, int v)`
|
||||
|
||||
#### `void SetUniform1f(int location, float v)`
|
||||
|
||||
#### `void SetUniform2f(int location, float x, float y)`
|
||||
|
||||
#### `void SetUniform3f(int location, float x, float y, float z)`
|
||||
|
||||
#### `void SetUniform4f(int location, float x, float y, float z, float w)`
|
||||
|
||||
#### `void SetUniform1fv(int location, int count, const float* v)`
|
||||
|
||||
#### `void SetUniform2fv/3fv/4fv`
|
||||
|
||||
#### `void SetUniformMatrix4fv(int location, int count, bool transpose, const float* v)`
|
||||
|
||||
### Shader 程序
|
||||
|
||||
#### `void UseProgram(unsigned int program)`
|
||||
|
||||
#### `void BindFragDataLocation(unsigned int program, unsigned int colorNumber, const char* name)`
|
||||
|
||||
#### `void BindFragDataLocationIndexed(...)`
|
||||
|
||||
### 查询
|
||||
|
||||
#### `void BeginQuery(unsigned int target, unsigned int id)`
|
||||
|
||||
#### `void EndQuery(unsigned int target)`
|
||||
|
||||
#### `void GetQueryObjectiv/GetQueryObjectuiv`
|
||||
|
||||
### Framebuffer 操作
|
||||
|
||||
#### `void ReadPixels(int x, int y, int width, int height, unsigned int format, unsigned int type, void* data)`
|
||||
|
||||
#### `void BlitFramebuffer(...)`
|
||||
|
||||
#### `void CopyImageSubData(...)`
|
||||
|
||||
#### `void InvalidateFramebuffer(unsigned int target, unsigned int count, const unsigned int* attachments)`
|
||||
|
||||
#### `void InvalidateSubFramebuffer(...)`
|
||||
|
||||
### 调试
|
||||
|
||||
#### `void PushDebugGroup(unsigned int source, unsigned int id, int length, const char* message)`
|
||||
|
||||
#### `void PopDebugGroup()`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_primitiveType` | `unsigned int` | 当前图元类型 |
|
||||
| `m_currentVAO` | `unsigned int` | 当前 VAO |
|
||||
| `m_currentProgram` | `unsigned int` | 当前 program |
|
||||
|
||||
## 备注
|
||||
|
||||
- OpenGL 是立即模式 API,`OpenGLCommandList` 主要用于状态批处理
|
||||
- `Reset()` 和 `Close()` 是可选的,可直接调用 GL 命令
|
||||
@@ -1,63 +0,0 @@
|
||||
# OpenGLCommandQueue
|
||||
|
||||
OpenGL 命令队列实现。OpenGL 是立即模式 API,此类主要提供 RHI 接口兼容。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLCommandQueue.h>
|
||||
```
|
||||
|
||||
## 继承关系
|
||||
|
||||
```
|
||||
RHICommandQueue (interface)
|
||||
└── OpenGLCommandQueue (implementation)
|
||||
```
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
### 构造函数与析构函数
|
||||
|
||||
#### `OpenGLCommandQueue()`
|
||||
|
||||
#### `~OpenGLCommandQueue() override`
|
||||
|
||||
### 生命周期
|
||||
|
||||
#### `void Shutdown() override`
|
||||
|
||||
### 命令执行
|
||||
|
||||
#### `void ExecuteCommandLists(uint32_t count, void** lists) override`
|
||||
执行命令列表(OpenGL 下为 no-op,直接调用 GL 命令)。
|
||||
|
||||
### 同步
|
||||
|
||||
#### `void Signal(RHIFence* fence, uint64_t value) override`
|
||||
发送信号。
|
||||
|
||||
#### `void Wait(RHIFence* fence, uint64_t value) override`
|
||||
等待栅栏。
|
||||
|
||||
#### `uint64_t GetCompletedValue() override`
|
||||
|
||||
#### `void WaitForIdle() override`
|
||||
等待空闲(调用 `glFinish`)。
|
||||
|
||||
### 属性
|
||||
|
||||
#### `CommandQueueType GetType() const override`
|
||||
返回 `CommandQueueType::Direct`。
|
||||
|
||||
#### `uint64_t GetTimestampFrequency() const override`
|
||||
返回 0。
|
||||
|
||||
#### `void* GetNativeHandle() override`
|
||||
返回 `nullptr`。
|
||||
|
||||
## 备注
|
||||
|
||||
- OpenGL 没有显式的命令队列,所有命令立即执行
|
||||
- `ExecuteCommandLists` 在 OpenGL 后端为空操作
|
||||
- `Signal`/`Wait` 仍然工作,使用 GLsync/fence 对象实现
|
||||
@@ -1,105 +0,0 @@
|
||||
# OpenGLDepthStencilView
|
||||
|
||||
OpenGL 深度模板视图实现。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLDepthStencilView.h>
|
||||
```
|
||||
|
||||
## 枚举
|
||||
|
||||
### DepthStencilFormat
|
||||
|
||||
| 值 | OpenGL 内部格式 |
|
||||
|----|----------------|
|
||||
| `D16_UNORM` | `GL_DEPTH_COMPONENT16` |
|
||||
| `D24_UNORM_S8_UINT` | `GL_DEPTH24_STENCIL8` |
|
||||
| `D32_FLOAT` | `GL_DEPTH_COMPONENT32F` |
|
||||
| `D32_FLOAT_S8X24_UINT` | `GL_DEPTH32F_STENCIL8` |
|
||||
|
||||
### DepthStencilType
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `Texture2D` | 2D 纹理 |
|
||||
| `Texture2DArray` | 2D 纹理数组 |
|
||||
| `TextureCube` | 立方体贴图 |
|
||||
|
||||
## OpenGLDepthStencilViewDesc
|
||||
|
||||
```cpp
|
||||
struct OpenGLDepthStencilViewDesc {
|
||||
DepthStencilType type = DepthStencilType::Texture2D;
|
||||
int mipLevel = 0;
|
||||
int baseArraySlice = 0;
|
||||
int arraySize = 1;
|
||||
int layer = 0;
|
||||
};
|
||||
```
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
#### `OpenGLDepthStencilView()`
|
||||
|
||||
#### `~OpenGLDepthStencilView()`
|
||||
|
||||
#### `bool Initialize(unsigned int texture, const OpenGLDepthStencilViewDesc& desc)`
|
||||
|
||||
#### `bool Initialize(unsigned int texture, int mipLevel = 0)`
|
||||
|
||||
#### `bool InitializeCubemap(unsigned int cubemap, int face, int mipLevel = 0)`
|
||||
|
||||
#### `void Shutdown()`
|
||||
|
||||
#### `void Bind()`
|
||||
|
||||
#### `void Unbind()`
|
||||
|
||||
#### `void ClearDepth(float depth)`
|
||||
|
||||
#### `void ClearStencil(uint8_t stencil)`
|
||||
|
||||
#### `void ClearDepthStencil(float depth, uint8_t stencil)`
|
||||
|
||||
#### `unsigned int GetFramebuffer() const`
|
||||
|
||||
#### `unsigned int GetTexture() const`
|
||||
|
||||
#### `int GetMipLevel() const`
|
||||
|
||||
#### `int GetWidth() const`
|
||||
|
||||
#### `int GetHeight() const`
|
||||
|
||||
#### `static void BindFramebuffer(unsigned int framebuffer)`
|
||||
|
||||
#### `static void UnbindFramebuffer()`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_texture` | `unsigned int` | GL texture ID |
|
||||
| `m_framebuffer` | `unsigned int` | GL framebuffer ID |
|
||||
| `m_mipLevel` | `int` | Mip 级别 |
|
||||
| `m_width/height` | `int` | 尺寸 |
|
||||
| `m_type` | `DepthStencilType` | 类型 |
|
||||
| `m_format` | `DepthStencilFormat` | 格式 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
OpenGLDepthStencilView dsv;
|
||||
dsv.Initialize(depthTexture.GetID());
|
||||
|
||||
dsv.Bind();
|
||||
dsv.ClearDepthStencil(1.0f, 0);
|
||||
dsv.Unbind();
|
||||
|
||||
// Combined with RTV
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTex, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depthTex, 0);
|
||||
```
|
||||
@@ -1,109 +0,0 @@
|
||||
# OpenGLDevice
|
||||
|
||||
OpenGL 设备的实现,基于 GLFW 和现代 OpenGL。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLDevice.h>
|
||||
```
|
||||
|
||||
## 继承关系
|
||||
|
||||
```
|
||||
RHIDevice (interface)
|
||||
└── OpenGLDevice (implementation)
|
||||
```
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
### 初始化与销毁
|
||||
|
||||
#### `bool Initialize(const RHIDeviceDesc& desc) override`
|
||||
初始化 OpenGL 上下文和设备。
|
||||
|
||||
#### `void Shutdown() override`
|
||||
关闭设备,销毁窗口(如果拥有)。
|
||||
|
||||
#### `bool CreateRenderWindow(int width, int height, const char* title, bool enableDebug = false)`
|
||||
创建渲染窗口并初始化 OpenGL 上下文。
|
||||
|
||||
#### `bool InitializeWithExistingWindow(GLFWwindow* window)`
|
||||
使用已有的 GLFW 窗口初始化。
|
||||
|
||||
### 窗口操作
|
||||
|
||||
#### `GLFWwindow* GetWindow() const`
|
||||
获取 GLFW 窗口指针。
|
||||
|
||||
#### `void SwapBuffers()`
|
||||
交换前后缓冲区。
|
||||
|
||||
#### `bool PollEvents()`
|
||||
轮询窗口事件。
|
||||
|
||||
#### `void SetShouldClose(bool shouldClose)`
|
||||
设置关闭标志。
|
||||
|
||||
#### `bool ShouldClose() const`
|
||||
检查是否应该关闭。
|
||||
|
||||
### 资源创建
|
||||
|
||||
#### `RHIBuffer* CreateBuffer(const BufferDesc& desc) override`
|
||||
|
||||
#### `RHITexture* CreateTexture(const TextureDesc& desc) override`
|
||||
|
||||
#### `RHISwapChain* CreateSwapChain(const SwapChainDesc& desc) override`
|
||||
|
||||
#### `RHICommandList* CreateCommandList(const CommandListDesc& desc) override`
|
||||
|
||||
#### `RHICommandQueue* CreateCommandQueue(const CommandQueueDesc& desc) override`
|
||||
|
||||
#### `RHIShader* CompileShader(const ShaderCompileDesc& desc) override`
|
||||
|
||||
#### `RHIPipelineState* CreatePipelineState(const PipelineStateDesc& desc) override`
|
||||
|
||||
#### `RHIFence* CreateFence(const FenceDesc& desc) override`
|
||||
|
||||
#### `RHISampler* CreateSampler(const SamplerDesc& desc) override`
|
||||
|
||||
### 设备信息
|
||||
|
||||
#### `const RHICapabilities& GetCapabilities() const override`
|
||||
获取 OpenGL 功能支持信息。
|
||||
|
||||
#### `const RHIDeviceInfo& GetDeviceInfo() const override`
|
||||
获取设备详细信息。
|
||||
|
||||
#### `void* GetNativeDevice() override`
|
||||
返回窗口指针。
|
||||
|
||||
#### `void* GetNativeHandle() const`
|
||||
返回窗口指针。
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_window` | `GLFWwindow*` | GLFW 窗口 |
|
||||
| `m_deviceInfo` | `RHIDeviceInfo` | 设备信息 |
|
||||
| `m_capabilities` | `RHICapabilities` | 功能支持 |
|
||||
| `m_initialized` | `bool` | 是否已初始化 |
|
||||
| `m_ownsWindow` | `bool` | 是否拥有窗口 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
OpenGLDevice device;
|
||||
device.CreateRenderWindow(1920, 1080, "XCEngine", true);
|
||||
|
||||
RHIShader* shader = device.CompileShader(shaderDesc);
|
||||
RHIPipelineState* pso = device.CreatePipelineState(psoDesc);
|
||||
|
||||
while (!device.ShouldClose()) {
|
||||
device.PollEvents();
|
||||
// Render...
|
||||
device.SwapBuffers();
|
||||
}
|
||||
```
|
||||
@@ -1,99 +0,0 @@
|
||||
# OpenGLFence
|
||||
|
||||
OpenGL 栅栏同步实现,使用 `GLsync` (Fence objects)。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLFence.h>
|
||||
```
|
||||
|
||||
## FenceStatus 枚举
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `Signaled` | 栅栏已发出信号 |
|
||||
| `Unsignaled` | 栅栏未发出信号 |
|
||||
| `Error` | 错误状态 |
|
||||
|
||||
## 继承关系
|
||||
|
||||
```
|
||||
RHIFence (interface)
|
||||
└── OpenGLFence (implementation)
|
||||
```
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
### 构造函数与析构函数
|
||||
|
||||
#### `OpenGLFence()`
|
||||
|
||||
#### `~OpenGLFence() override`
|
||||
|
||||
### 初始化
|
||||
|
||||
#### `bool Initialize(bool signaled = false)`
|
||||
初始化栅栏。
|
||||
- `signaled`: 是否初始为已发出信号状态
|
||||
|
||||
#### `void Shutdown() override`
|
||||
|
||||
### 信号操作
|
||||
|
||||
#### `void Signal() override`
|
||||
发送信号。
|
||||
|
||||
#### `void Signal(uint64_t value) override`
|
||||
发送信号(值递增)。
|
||||
|
||||
#### `void Wait(uint64_t value) override`
|
||||
等待栅栏达到指定值。
|
||||
|
||||
#### `void Reset()`
|
||||
重置栅栏。
|
||||
|
||||
### 状态查询
|
||||
|
||||
#### `bool IsSignaled() const override`
|
||||
检查是否已发出信号。
|
||||
|
||||
#### `FenceStatus GetStatus() const`
|
||||
获取栅栏状态。
|
||||
|
||||
#### `uint64_t GetCompletedValue() const override`
|
||||
获取已完成值。
|
||||
|
||||
#### `uint64_t GetCurrentValue() const`
|
||||
获取当前值。
|
||||
|
||||
### 原生接口
|
||||
|
||||
#### `void* GetNativeHandle() override { return m_sync; }`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_sync` | `void*` | GLsync 对象 |
|
||||
| `m_fenceValue` | `uint64_t` | 栅栏值 |
|
||||
| `m_completedValue` | `uint64_t` | 已完成值 |
|
||||
| `m_signaled` | `bool` | 是否已发出信号 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
OpenGLFence fence;
|
||||
fence.Initialize();
|
||||
|
||||
// Insert fence after draw commands
|
||||
glFlush();
|
||||
GLsync sync = glFenceSync(GL_SYNC_GPU_commands_COMPLETE, 0);
|
||||
glClientWaitSync(sync, GL_SYNC_FLUSH_COMMANDS_BIT, timeout);
|
||||
|
||||
// Or use class
|
||||
glFlush();
|
||||
fence.Signal();
|
||||
|
||||
fence.Wait(1);
|
||||
```
|
||||
@@ -1,87 +0,0 @@
|
||||
# OpenGL Backend Overview
|
||||
|
||||
OpenGL RHI 后端实现,基于 GLFW 和现代 OpenGL (Core Profile)。
|
||||
|
||||
## 头文件
|
||||
|
||||
所有 OpenGL 后端头文件位于 `engine/include/XCEngine/RHI/OpenGL/`。
|
||||
|
||||
## 架构说明
|
||||
|
||||
OpenGL 是**立即模式** API,与 D3D12 的命令列表模式有本质区别:
|
||||
|
||||
- 无显式的命令列表录制和提交
|
||||
- 状态通过 OpenGL 状态机管理
|
||||
- `OpenGLCommandList` 主要用于状态批处理和 RHI 接口兼容
|
||||
- 交换链使用 GLFW 窗口管理
|
||||
|
||||
## 后端组件
|
||||
|
||||
| 类 | 文件 | 描述 |
|
||||
|----|------|------|
|
||||
| `OpenGLDevice` | `OpenGLDevice.h` | 主设备,管理窗口和 OpenGL 上下文 |
|
||||
| `OpenGLBuffer` | `OpenGLBuffer.h` | GPU 缓冲区(VBO/UBO/SSBO) |
|
||||
| `OpenGLTexture` | `OpenGLTexture.h` | 纹理对象(1D/2D/3D/Cube) |
|
||||
| `OpenGLCommandList` | `OpenGLCommandList.h` | 命令列表(状态批处理) |
|
||||
| `OpenGLCommandQueue` | `OpenGLCommandQueue.h` | 命令队列(RHI 兼容层) |
|
||||
| `OpenGLSwapChain` | `OpenGLSwapChain.h` | 交换链(GLFW 窗口) |
|
||||
| `OpenGLFence` | `OpenGLFence.h` | 栅栏同步(GLsync) |
|
||||
| `OpenGLShader` | `OpenGLShader.h` | Shader Program |
|
||||
| `OpenGLPipelineState` | `OpenGLPipelineState.h` | 管线状态 |
|
||||
| `OpenGLSampler` | `OpenGLSampler.h` | 采样器对象 |
|
||||
| `OpenGLVertexArray` | `OpenGLVertexArray.h` | 顶点数组对象 (VAO) |
|
||||
| `OpenGLRenderTargetView` | `OpenGLRenderTargetView.h` | 渲染目标 (FBO) |
|
||||
| `OpenGLDepthStencilView` | `OpenGLDepthStencilView.h` | 深度模板 (FBO) |
|
||||
|
||||
## 初始化流程
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLDevice.h>
|
||||
|
||||
using namespace XCEngine::RHI;
|
||||
|
||||
OpenGLDevice device;
|
||||
device.CreateRenderWindow(1920, 1080, "XCEngine", true);
|
||||
|
||||
// Create resources
|
||||
OpenGLShader shader;
|
||||
shader.CompileFromFile("shaders/Default.vert", "shaders/Default.frag");
|
||||
|
||||
OpenGLBuffer vb;
|
||||
vb.InitializeVertexBuffer(vertices, sizeof(vertices));
|
||||
|
||||
OpenGLTexture texture;
|
||||
texture.LoadFromFile("textures/diffuse.png");
|
||||
|
||||
// Render loop
|
||||
while (!device.ShouldClose()) {
|
||||
device.PollEvents();
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
shader.Use();
|
||||
vb.Bind();
|
||||
texture.Bind(0);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, vertexCount);
|
||||
|
||||
device.SwapBuffers();
|
||||
}
|
||||
```
|
||||
|
||||
## 与 D3D12 的差异
|
||||
|
||||
| 方面 | D3D12 | OpenGL |
|
||||
|------|-------|--------|
|
||||
| 模式 | 命令列表录制 | 立即模式 |
|
||||
| 状态管理 | 显式资源状态 | OpenGL 状态机 |
|
||||
| 描述符 | 描述符堆 + 句柄 | 绑定点 |
|
||||
| 管线状态 | PSO(不可变) | 可变状态 |
|
||||
| 内存管理 | 显式显存管理 | 驱动自动管理 |
|
||||
| 多线程 | 需要 Bundle | 上下文共享 |
|
||||
|
||||
## 扩展模块
|
||||
|
||||
- **GLFW**: 窗口管理和输入
|
||||
- **GLSL**: 着色器语言 (Core Profile)
|
||||
- **stb_image**: 纹理文件加载
|
||||
@@ -1,229 +0,0 @@
|
||||
# OpenGLPipelineState
|
||||
|
||||
OpenGL 管线状态对象实现,封装多种 OpenGL 状态。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLPipelineState.h>
|
||||
```
|
||||
|
||||
## 继承关系
|
||||
|
||||
```
|
||||
RHIPipelineState (interface)
|
||||
└── OpenGLPipelineState (implementation)
|
||||
```
|
||||
|
||||
## 枚举
|
||||
|
||||
### OpenGLPrimitiveTopology
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `Points` | 点 |
|
||||
| `Lines` | 线 |
|
||||
| `LineStrip` | 线带 |
|
||||
| `Triangles` | 三角形 |
|
||||
| `TriangleStrip` | 三角形带 |
|
||||
|
||||
### OpenGLBlendOp
|
||||
|
||||
| 值 | OpenGL 常量 |
|
||||
|----|-------------|
|
||||
| `Add` | `GL_FUNC_ADD` |
|
||||
| `Subtract` | `GL_FUNC_SUBTRACT` |
|
||||
| `ReverseSubtract` | `GL_FUNC_REVERSE_SUBTRACT` |
|
||||
| `Min` | `GL_MIN` |
|
||||
| `Max` | `GL_MAX` |
|
||||
|
||||
### CullFace / FrontFace / PolygonMode
|
||||
|
||||
```cpp
|
||||
enum class CullFace { Front, Back, FrontAndBack };
|
||||
enum class FrontFace { Clockwise, CounterClockwise };
|
||||
enum class PolygonMode { Point, Line, Fill };
|
||||
```
|
||||
|
||||
## 状态结构体
|
||||
|
||||
### OpenGLDepthStencilState
|
||||
|
||||
```cpp
|
||||
struct OpenGLDepthStencilState {
|
||||
bool depthTestEnable = true;
|
||||
bool depthWriteEnable = true;
|
||||
ComparisonFunc depthFunc = ComparisonFunc::Less;
|
||||
bool stencilEnable = false;
|
||||
uint8_t stencilReadMask = 0xFF;
|
||||
uint8_t stencilWriteMask = 0xFF;
|
||||
int stencilRef = 0;
|
||||
ComparisonFunc stencilFunc = ComparisonFunc::Always;
|
||||
StencilOp stencilFailOp = StencilOp::Keep;
|
||||
StencilOp stencilDepthFailOp = StencilOp::Keep;
|
||||
StencilOp stencilDepthPassOp = StencilOp::Keep;
|
||||
};
|
||||
```
|
||||
|
||||
### OpenGLBlendState
|
||||
|
||||
```cpp
|
||||
struct OpenGLBlendState {
|
||||
bool blendEnable = false;
|
||||
BlendFactor srcBlend = BlendFactor::SrcAlpha;
|
||||
BlendFactor dstBlend = BlendFactor::InvSrcAlpha;
|
||||
BlendFactor srcBlendAlpha = BlendFactor::One;
|
||||
BlendFactor dstBlendAlpha = BlendFactor::Zero;
|
||||
BlendOp blendOp = BlendOp::Add;
|
||||
BlendOp blendOpAlpha = BlendOp::Add;
|
||||
uint8_t colorWriteMask = 0xF;
|
||||
float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
};
|
||||
```
|
||||
|
||||
### OpenGLRasterizerState
|
||||
|
||||
```cpp
|
||||
struct OpenGLRasterizerState {
|
||||
bool cullFaceEnable = true;
|
||||
CullFace cullFace = CullFace::Back;
|
||||
FrontFace frontFace = FrontFace::CounterClockwise;
|
||||
PolygonMode polygonMode = PolygonMode::Fill;
|
||||
float polygonOffsetFactor = 0.0f;
|
||||
float polygonOffsetUnits = 0.0f;
|
||||
bool depthClipEnable = true;
|
||||
bool scissorTestEnable = false;
|
||||
bool multisampleEnable = false;
|
||||
bool sampleAlphaToCoverageEnable = false;
|
||||
};
|
||||
```
|
||||
|
||||
### ViewportState / ScissorState / LogicalOperation
|
||||
|
||||
```cpp
|
||||
struct ViewportState {
|
||||
float x = 0.0f, y = 0.0f;
|
||||
float width = 0.0f, height = 0.0f;
|
||||
float minDepth = 0.0f, maxDepth = 1.0f;
|
||||
};
|
||||
|
||||
struct ScissorState {
|
||||
bool enable = false;
|
||||
int x = 0, y = 0, width = 0, height = 0;
|
||||
};
|
||||
|
||||
struct LogicalOperation {
|
||||
bool enable = false;
|
||||
uint32_t operation = 0;
|
||||
};
|
||||
```
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
### 生命周期
|
||||
|
||||
#### `OpenGLPipelineState()`
|
||||
|
||||
#### `~OpenGLPipelineState() override`
|
||||
|
||||
#### `void Shutdown() override`
|
||||
|
||||
### 绑定
|
||||
|
||||
#### `void Bind() override`
|
||||
应用所有状态。
|
||||
|
||||
#### `void Unbind() override`
|
||||
|
||||
#### `void* GetNativeHandle() override`
|
||||
|
||||
#### `PipelineType GetType() const override { return PipelineType::Graphics; }`
|
||||
|
||||
### 状态设置
|
||||
|
||||
#### `void SetDepthStencilState(const OpenGLDepthStencilState& state)`
|
||||
|
||||
#### `void SetBlendState(const OpenGLBlendState& state)`
|
||||
|
||||
#### `void SetRasterizerState(const OpenGLRasterizerState& state)`
|
||||
|
||||
#### `void SetViewport(const ViewportState& state)`
|
||||
|
||||
#### `void SetScissor(const ScissorState& state)`
|
||||
|
||||
#### `void SetLogicalOperation(const LogicalOperation& state)`
|
||||
|
||||
### 状态应用
|
||||
|
||||
#### `void Apply()`
|
||||
应用所有状态。
|
||||
|
||||
#### `void ApplyDepthStencil()`
|
||||
|
||||
#### `void ApplyBlend()`
|
||||
|
||||
#### `void ApplyRasterizer()`
|
||||
|
||||
#### `void ApplyViewport()`
|
||||
|
||||
#### `void ApplyScissor()`
|
||||
|
||||
### 清除
|
||||
|
||||
#### `void SetClearColor(float r, float g, float b, float a)`
|
||||
|
||||
#### `void Clear(unsigned int buffers)`
|
||||
|
||||
### Shader 附加
|
||||
|
||||
#### `void AttachShader(unsigned int program)`
|
||||
|
||||
#### `void DetachShader()`
|
||||
|
||||
### 属性获取
|
||||
|
||||
#### `const OpenGLDepthStencilState& GetDepthStencilState() const`
|
||||
|
||||
#### `const OpenGLBlendState& GetBlendState() const`
|
||||
|
||||
#### `const OpenGLRasterizerState& GetRasterizerState() const`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_depthStencilState` | `OpenGLDepthStencilState` | 深度模板状态 |
|
||||
| `m_blendState` | `OpenGLBlendState` | 混合状态 |
|
||||
| `m_rasterizerState` | `OpenGLRasterizerState` | 光栅化状态 |
|
||||
| `m_viewportState` | `ViewportState` | 视口状态 |
|
||||
| `m_scissorState` | `ScissorState` | 裁剪状态 |
|
||||
| `m_logicalOperation` | `LogicalOperation` | 逻辑操作 |
|
||||
| `m_clearColor` | `float[4]` | 清除颜色 |
|
||||
| `m_program` | `unsigned int` | GL program |
|
||||
| `m_programAttached` | `bool` | program 是否附加 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
OpenGLPipelineState pso;
|
||||
|
||||
OpenGLDepthStencilState ds;
|
||||
ds.depthTestEnable = true;
|
||||
ds.depthWriteEnable = true;
|
||||
ds.depthFunc = ComparisonFunc::Less;
|
||||
pso.SetDepthStencilState(ds);
|
||||
|
||||
OpenGLBlendState blend;
|
||||
blend.blendEnable = true;
|
||||
blend.srcBlend = BlendFactor::SrcAlpha;
|
||||
blend.dstBlend = BlendFactor::InvSrcAlpha;
|
||||
pso.SetBlendState(blend);
|
||||
|
||||
OpenGLRasterizerState raster;
|
||||
raster.cullFaceEnable = true;
|
||||
raster.cullFace = CullFace::Back;
|
||||
pso.SetRasterizerState(raster);
|
||||
|
||||
pso.AttachShader(shaderProgram);
|
||||
pso.Bind();
|
||||
```
|
||||
@@ -1,106 +0,0 @@
|
||||
# OpenGLRenderTargetView
|
||||
|
||||
OpenGL 渲染目标视图实现,使用 framebuffer object (FBO)。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLRenderTargetView.h>
|
||||
```
|
||||
|
||||
## 枚举
|
||||
|
||||
### RenderTargetType
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `Texture2D` | 2D 纹理 |
|
||||
| `Texture2DArray` | 2D 纹理数组 |
|
||||
| `Texture3D` | 3D 纹理 |
|
||||
| `TextureCube` | 立方体贴图 |
|
||||
| `TextureCubeArray` | 立方体贴图数组 |
|
||||
|
||||
## OpenGLRenderTargetViewDesc
|
||||
|
||||
```cpp
|
||||
struct OpenGLRenderTargetViewDesc {
|
||||
RenderTargetType type = RenderTargetType::Texture2D;
|
||||
int mipLevel = 0;
|
||||
int baseArraySlice = 0;
|
||||
int arraySize = 1;
|
||||
int layer = 0;
|
||||
uint32_t format = 0;
|
||||
};
|
||||
```
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
#### `OpenGLRenderTargetView()`
|
||||
|
||||
#### `~OpenGLRenderTargetView()`
|
||||
|
||||
#### `bool Initialize(unsigned int texture, const OpenGLRenderTargetViewDesc& desc)`
|
||||
|
||||
#### `bool Initialize(unsigned int texture, int mipLevel = 0)`
|
||||
|
||||
#### `bool InitializeCubemap(unsigned int cubemap, int face, int mipLevel = 0)`
|
||||
|
||||
#### `void Shutdown()`
|
||||
|
||||
#### `void Bind(unsigned int slot = 0)`
|
||||
|
||||
#### `void Bind(unsigned int count, const unsigned int* framebuffers, const int* drawBuffers)`
|
||||
|
||||
#### `void Unbind()`
|
||||
|
||||
#### `void Clear(float r, float g, float b, float a)`
|
||||
|
||||
#### `void Clear(float r, float g, float b, float a, float depth, uint8_t stencil)`
|
||||
|
||||
#### `unsigned int GetFramebuffer() const`
|
||||
|
||||
#### `unsigned int GetTexture() const`
|
||||
|
||||
#### `int GetMipLevel() const`
|
||||
|
||||
#### `int GetWidth() const`
|
||||
|
||||
#### `int GetHeight() const`
|
||||
|
||||
#### `static void BindFramebuffer(unsigned int framebuffer)`
|
||||
|
||||
#### `static void UnbindFramebuffer()`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_texture` | `unsigned int` | GL texture ID |
|
||||
| `m_framebuffer` | `unsigned int` | GL framebuffer ID |
|
||||
| `m_mipLevel` | `int` | Mip 级别 |
|
||||
| `m_width/height` | `int` | 尺寸 |
|
||||
| `m_type` | `RenderTargetType` | 类型 |
|
||||
| `m_framebuffers` | `vector<unsigned int>` | 额外 framebuffer 列表 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
// Create framebuffer with color attachment
|
||||
OpenGLRenderTargetView rtv;
|
||||
rtv.Initialize(texture.GetID());
|
||||
|
||||
rtv.Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
rtv.Unbind();
|
||||
|
||||
// MRT
|
||||
OpenGLRenderTargetView rtvs[2];
|
||||
rtvs[0].Initialize(texture0.GetID());
|
||||
rtvs[1].Initialize(texture1.GetID());
|
||||
|
||||
unsigned int fbs[] = { rtvs[0].GetFramebuffer(), rtvs[1].GetFramebuffer() };
|
||||
int draws[] = { 0, 1 };
|
||||
rtvs[0].Bind(2, fbs, draws);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
```
|
||||
@@ -1,102 +0,0 @@
|
||||
# OpenGLSampler
|
||||
|
||||
OpenGL 采样器实现。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLSampler.h>
|
||||
```
|
||||
|
||||
## 继承关系
|
||||
|
||||
```
|
||||
RHISampler (interface)
|
||||
└── OpenGLSampler (implementation)
|
||||
```
|
||||
|
||||
## 枚举
|
||||
|
||||
### SamplerWrapMode
|
||||
|
||||
| 值 | OpenGL 常量 |
|
||||
|----|-------------|
|
||||
| `Repeat` | `GL_REPEAT` |
|
||||
| `MirroredRepeat` | `GL_MIRRORED_REPEAT` |
|
||||
| `ClampToEdge` | `GL_CLAMP_TO_EDGE` |
|
||||
| `ClampToBorder` | `GL_CLAMP_TO_BORDER` |
|
||||
|
||||
### SamplerFilter
|
||||
|
||||
| 值 | OpenGL 常量 |
|
||||
|----|-------------|
|
||||
| `Nearest` | `GL_NEAREST` |
|
||||
| `Linear` | `GL_LINEAR` |
|
||||
| `NearestMipmapNearest` | `GL_NEAREST_MIPMAP_NEAREST` |
|
||||
| `LinearMipmapNearest` | `GL_LINEAR_MIPMAP_NEAREST` |
|
||||
| `NearestMipmapLinear` | `GL_NEAREST_MIPMAP_LINEAR` |
|
||||
| `LinearMipmapLinear` | `GL_LINEAR_MIPMAP_LINEAR` |
|
||||
|
||||
### SamplerCompareMode
|
||||
|
||||
| 值 | OpenGL 常量 |
|
||||
|----|-------------|
|
||||
| `None` | `GL_NONE` |
|
||||
| `CompareToRef` | `GL_COMPARE_REF_TO_TEXTURE` |
|
||||
|
||||
## OpenGLSamplerDesc
|
||||
|
||||
```cpp
|
||||
struct OpenGLSamplerDesc {
|
||||
SamplerFilter minFilter = SamplerFilter::LinearMipmapLinear;
|
||||
SamplerFilter magFilter = SamplerFilter::Linear;
|
||||
SamplerWrapMode wrapS = SamplerWrapMode::Repeat;
|
||||
SamplerWrapMode wrapT = SamplerWrapMode::Repeat;
|
||||
SamplerWrapMode wrapR = SamplerWrapMode::Repeat;
|
||||
SamplerCompareMode compareMode = SamplerCompareMode::None;
|
||||
int compareFunc = 0;
|
||||
float maxAnisotropy = 1.0f;
|
||||
float minLod = -1000.0f;
|
||||
float maxLod = 1000.0f;
|
||||
};
|
||||
```
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
#### `OpenGLSampler()`
|
||||
|
||||
#### `~OpenGLSampler() override`
|
||||
|
||||
#### `bool Initialize(const OpenGLSamplerDesc& desc)`
|
||||
|
||||
#### `void Shutdown() override`
|
||||
|
||||
#### `void Bind(unsigned int unit) override`
|
||||
|
||||
#### `void Unbind(unsigned int unit) override`
|
||||
|
||||
#### `unsigned int GetID() const`
|
||||
|
||||
#### `void* GetNativeHandle() override`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_sampler` | `unsigned int` | GL sampler ID |
|
||||
| `m_desc` | `OpenGLSamplerDesc` | 采样器描述 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
OpenGLSampler sampler;
|
||||
OpenGLSamplerDesc desc;
|
||||
desc.minFilter = SamplerFilter::LinearMipmapLinear;
|
||||
desc.magFilter = SamplerFilter::Linear;
|
||||
desc.wrapS = desc.wrapT = SamplerWrapMode::Repeat;
|
||||
desc.maxAnisotropy = 16.0f;
|
||||
sampler.Initialize(desc);
|
||||
|
||||
sampler.Bind(0);
|
||||
glBindTextureUnit(0, texture.GetID());
|
||||
```
|
||||
@@ -1,151 +0,0 @@
|
||||
# OpenGLShader
|
||||
|
||||
OpenGL 着色器实现,封装 shader program。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLShader.h>
|
||||
```
|
||||
|
||||
## 继承关系
|
||||
|
||||
```
|
||||
RHIShader (interface)
|
||||
└── OpenGLShader (implementation)
|
||||
```
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
### 构造函数与析构函数
|
||||
|
||||
#### `OpenGLShader()`
|
||||
|
||||
#### `~OpenGLShader() override`
|
||||
|
||||
### RHI 接口实现
|
||||
|
||||
#### `bool CompileFromFile(const wchar_t* filePath, const char* entryPoint, const char* target) override`
|
||||
从文件编译(适配 RHI 接口,`target` 被忽略)。
|
||||
|
||||
#### `bool Compile(const void* sourceData, size_t sourceSize, const char* entryPoint, const char* target) override`
|
||||
从内存编译。
|
||||
|
||||
#### `void Shutdown() override`
|
||||
|
||||
### OpenGL 特有编译方法
|
||||
|
||||
#### `bool CompileFromFile(const char* vertexPath, const char* fragmentPath)`
|
||||
编译顶点+片元着色器。
|
||||
|
||||
#### `bool CompileFromFile(const char* vertexPath, const char* fragmentPath, const char* geometryPath)`
|
||||
编译 VS + GS + FS。
|
||||
|
||||
#### `bool Compile(const char* vertexSource, const char* fragmentSource)`
|
||||
从源码编译 VS + FS。
|
||||
|
||||
#### `bool Compile(const char* vertexSource, const char* fragmentSource, const char* geometrySource)`
|
||||
|
||||
#### `bool CompileCompute(const char* computeSource)`
|
||||
编译计算着色器。
|
||||
|
||||
#### `bool Compile(const char* source, ShaderType type)`
|
||||
按类型编译单个着色器。
|
||||
|
||||
### 绑定
|
||||
|
||||
#### `void Use() const`
|
||||
使用此 program。
|
||||
|
||||
#### `void Bind() override { Use(); }`
|
||||
|
||||
#### `void Unbind() override`
|
||||
|
||||
### Uniform 设置
|
||||
|
||||
#### `void SetInt(const char* name, int value) override`
|
||||
|
||||
#### `void SetIntArray(const char* name, const int* values, unsigned int count)`
|
||||
|
||||
#### `void SetFloat(const char* name, float value) override`
|
||||
|
||||
#### `void SetFloatArray(const char* name, const float* values, unsigned int count)`
|
||||
|
||||
#### `void SetVec3(const char* name, float x, float y, float z) override`
|
||||
|
||||
#### `void SetVec3(const char* name, const float* values)`
|
||||
|
||||
#### `void SetVec4(const char* name, float x, float y, float z, float w) override`
|
||||
|
||||
#### `void SetVec4(const char* name, const float* values)`
|
||||
|
||||
#### `void SetMat2(const char* name, const float* value)`
|
||||
|
||||
#### `void SetMat3(const char* name, const float* value)`
|
||||
|
||||
#### `void SetMat4(const char* name, const float* value) override`
|
||||
|
||||
#### `void SetMat4Array(const char* name, const float* values, unsigned int count)`
|
||||
|
||||
### 属性
|
||||
|
||||
#### `int GetUniformLocation(const char* name) const`
|
||||
获取 uniform location。
|
||||
|
||||
#### `unsigned int GetID() const`
|
||||
获取 GL program ID。
|
||||
|
||||
#### `void* GetNativeHandle() override`
|
||||
|
||||
#### `bool IsValid() const override`
|
||||
检查 program 是否有效。
|
||||
|
||||
#### `ShaderType GetType() const override`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_program` | `unsigned int` | GL program ID |
|
||||
| `m_type` | `ShaderType` | 着色器类型 |
|
||||
|
||||
## 私有方法
|
||||
|
||||
#### `bool CheckCompileErrors(unsigned int shader, const char* type)`
|
||||
检查单个 shader 编译错误。
|
||||
|
||||
#### `bool CheckLinkErrors(unsigned int program)`
|
||||
检查 program 链接错误。
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
// Simple shader
|
||||
OpenGLShader shader;
|
||||
shader.Compile(R"(
|
||||
#version 450 core
|
||||
layout(location=0) in vec3 aPos;
|
||||
void main() { gl_Position = vec4(aPos, 1.0); }
|
||||
)",
|
||||
R"(
|
||||
#version 450 core
|
||||
out vec4 FragColor;
|
||||
void main() { FragColor = vec4(1.0); }
|
||||
)",
|
||||
"vs", "fs");
|
||||
|
||||
shader.Use();
|
||||
shader.SetMat4("u_model", glm::value_ptr(model));
|
||||
shader.SetVec3("u_color", 1.0f, 0.0f, 0.0f);
|
||||
shader.SetInt("u_texture", 0);
|
||||
|
||||
// From files
|
||||
OpenGLShader shader2;
|
||||
shader2.CompileFromFile("shaders/Default.vert", "shaders/Default.frag");
|
||||
```
|
||||
|
||||
## 备注
|
||||
|
||||
- 使用 GLSL 450 core profile
|
||||
- 编译/链接错误通过日志输出
|
||||
- `GetUniformLocation` 返回 -1 表示 uniform 不存在
|
||||
@@ -1,138 +0,0 @@
|
||||
# OpenGLSwapChain
|
||||
|
||||
OpenGL 交换链实现,基于 GLFW 窗口和双缓冲。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLSwapChain.h>
|
||||
```
|
||||
|
||||
## 枚举
|
||||
|
||||
### PresentMode
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `Immediate` | 立即呈现,无垂直同步 |
|
||||
| `VSync` | 等待垂直同步 |
|
||||
| `Mailbox` | 邮箱模式(渲染时不阻塞) |
|
||||
| `Fifo` | 标准 FIFO 队列(默认) |
|
||||
|
||||
### SurfaceFormat
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `RGBA8` | 8-bit RGBA |
|
||||
| `RGBA16F` | 16-bit float RGBA |
|
||||
| `RGBA32F` | 32-bit float RGBA |
|
||||
| `BGRA8` | BGRA 格式 |
|
||||
|
||||
## 继承关系
|
||||
|
||||
```
|
||||
RHISwapChain (interface)
|
||||
└── OpenGLSwapChain (implementation)
|
||||
```
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
### 构造函数与析构函数
|
||||
|
||||
#### `OpenGLSwapChain()`
|
||||
|
||||
#### `~OpenGLSwapChain() override`
|
||||
|
||||
### 初始化
|
||||
|
||||
#### `bool Initialize(GLFWwindow* window, bool vsync = true)`
|
||||
初始化交换链。
|
||||
|
||||
#### `bool Initialize(GLFWwindow* window, int width, int height, PresentMode mode = PresentMode::VSync)`
|
||||
|
||||
#### `void Shutdown() override`
|
||||
|
||||
### 呈现操作
|
||||
|
||||
#### `void Present(uint32_t syncInterval = 1, uint32_t flags = 0) override`
|
||||
呈现帧。
|
||||
- `syncInterval`: 垂直同步间隔
|
||||
|
||||
#### `void SwapBuffers()`
|
||||
直接交换缓冲区。
|
||||
|
||||
### 尺寸管理
|
||||
|
||||
#### `void Resize(uint32_t width, uint32_t height) override`
|
||||
|
||||
#### `void SetFramebufferSize(int width, int height)`
|
||||
|
||||
### 垂直同步
|
||||
|
||||
#### `void SetVSync(bool enabled)`
|
||||
设置垂直同步。
|
||||
|
||||
#### `bool IsVSync() const`
|
||||
检查是否启用垂直同步。
|
||||
|
||||
### 全屏
|
||||
|
||||
#### `void SetFullscreen(bool fullscreen) override`
|
||||
|
||||
#### `bool IsFullscreen() const override`
|
||||
|
||||
### 窗口事件
|
||||
|
||||
#### `bool ShouldClose() const override`
|
||||
|
||||
#### `void SetShouldClose(bool shouldClose) override`
|
||||
|
||||
#### `void PollEvents() override`
|
||||
|
||||
### 缓冲区查询
|
||||
|
||||
#### `uint32_t GetCurrentBackBufferIndex() const override`
|
||||
返回 0(OpenGL 单缓冲区索引)。
|
||||
|
||||
#### `RHITexture* GetCurrentBackBuffer() override`
|
||||
返回 `nullptr`(OpenGL 使用默认 framebuffer)。
|
||||
|
||||
### 属性
|
||||
|
||||
#### `int GetWidth() const`
|
||||
|
||||
#### `int GetHeight() const`
|
||||
|
||||
#### `int GetFramebufferWidth() const`
|
||||
|
||||
#### `int GetFramebufferHeight() const`
|
||||
|
||||
#### `GLFWwindow* GetWindow() const`
|
||||
|
||||
#### `void* GetNativeHandle() override`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_window` | `GLFWwindow*` | GLFW 窗口 |
|
||||
| `m_width/height` | `int` | 窗口尺寸 |
|
||||
| `m_framebufferWidth/height` | `int` | 帧缓冲尺寸 (DPI aware) |
|
||||
| `m_vsync` | `bool` | 是否垂直同步 |
|
||||
| `m_presentMode` | `PresentMode` | 呈现模式 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
OpenGLSwapChain swapChain;
|
||||
swapChain.Initialize(window, true);
|
||||
|
||||
while (!swapChain.ShouldClose()) {
|
||||
swapChain.PollEvents();
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
// Render...
|
||||
|
||||
swapChain.Present(1);
|
||||
}
|
||||
```
|
||||
@@ -1,149 +0,0 @@
|
||||
# OpenGLTexture
|
||||
|
||||
OpenGL 纹理的实现,封装 OpenGL texture object。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLTexture.h>
|
||||
```
|
||||
|
||||
## 继承关系
|
||||
|
||||
```
|
||||
RHITexture (interface)
|
||||
└── OpenGLTexture (implementation)
|
||||
```
|
||||
|
||||
## 枚举
|
||||
|
||||
### OpenGLTextureType
|
||||
|
||||
| 值 | 描述 |
|
||||
|----|------|
|
||||
| `Texture1D` | 1D 纹理 |
|
||||
| `Texture2D` | 2D 纹理 |
|
||||
| `Texture2DArray` | 2D 纹理数组 |
|
||||
| `Texture3D` | 3D 纹理 |
|
||||
| `TextureCube` | 立方体贴图 |
|
||||
| `TextureCubeArray` | 立方体贴图数组 |
|
||||
|
||||
### OpenGLFormat / OpenGLInternalFormat
|
||||
|
||||
| OpenGLFormat | OpenGLInternalFormat | 描述 |
|
||||
|--------------|---------------------|------|
|
||||
| `R8` | `1` | 单通道 8-bit |
|
||||
| `RG8` | `2` | 双通道 8-bit |
|
||||
| `RGBA8` | `4` | 四通道 8-bit |
|
||||
| `RGBA16F` | `11` | 四通道 16-bit float |
|
||||
| `RGBA32F` | `16` | 四通道 32-bit float |
|
||||
| `Depth24Stencil8` | `38` | 24-bit depth + 8-bit stencil |
|
||||
| `Depth32F` | `31` | 32-bit float depth |
|
||||
| `CompressedDXT1` | `21` | DXT1 压缩 |
|
||||
| `CompressedDXT5` | `22` | DXT5 压缩 |
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
### 构造函数与析构函数
|
||||
|
||||
#### `OpenGLTexture()`
|
||||
|
||||
#### `~OpenGLTexture() override`
|
||||
|
||||
### 初始化
|
||||
|
||||
#### `bool Initialize(OpenGLTextureType type, int width, int height, int depth, int mipLevels, OpenGLFormat format, const void* data = nullptr)`
|
||||
通用初始化。
|
||||
|
||||
#### `bool Initialize2D(int width, int height, int channels, const void* data, bool generateMipmap = true)`
|
||||
便捷的 2D 纹理初始化。
|
||||
- `channels`: 通道数 (1-4)
|
||||
|
||||
#### `bool InitializeCubeMap(int size, int mipLevels, OpenGLFormat format, const void* data = nullptr)`
|
||||
初始化立方体贴图。
|
||||
|
||||
#### `bool LoadFromFile(const char* path, bool flipVertical = true)`
|
||||
从图片文件加载纹理(需要 stb_image)。
|
||||
|
||||
#### `void Shutdown() override`
|
||||
|
||||
### 绑定操作
|
||||
|
||||
#### `void Bind(int slot = 0) const`
|
||||
绑定纹理到纹理单元。
|
||||
|
||||
#### `void Unbind() const`
|
||||
|
||||
#### `void BindImage(int slot, bool read, bool write) const`
|
||||
绑定为 image texture(用于 compute shader)。
|
||||
|
||||
### 纹理操作
|
||||
|
||||
#### `void GenerateMipmap()`
|
||||
生成 Mipmap。
|
||||
|
||||
#### `void SetFiltering(int minFilter, int magFilter)`
|
||||
设置过滤模式。
|
||||
|
||||
#### `void SetWrapping(int wrapS, int wrapT, int wrapR = -1)`
|
||||
设置纹理环绕模式。
|
||||
|
||||
### 属性
|
||||
|
||||
#### `unsigned int GetID() const`
|
||||
获取 OpenGL texture ID。
|
||||
|
||||
#### `OpenGLTextureType GetOpenGLType() const`
|
||||
获取纹理类型。
|
||||
|
||||
#### `uint32_t GetWidth() const override`
|
||||
|
||||
#### `uint32_t GetHeight() const override`
|
||||
|
||||
#### `uint32_t GetDepth() const override`
|
||||
|
||||
#### `uint32_t GetMipLevels() const override`
|
||||
|
||||
#### `TextureType GetTextureType() const override`
|
||||
转换为 RHI TextureType。
|
||||
|
||||
#### `void* GetNativeHandle() override`
|
||||
|
||||
#### `Format GetFormat() const override / void SetFormat(Format format)`
|
||||
|
||||
#### `const std::string& GetName() const override / void SetName(...)`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_texture` | `unsigned int` | GL texture ID |
|
||||
| `m_type` | `OpenGLTextureType` | 纹理类型 |
|
||||
| `m_width/height/depth` | `int` | 尺寸 |
|
||||
| `m_mipLevels` | `int` | Mipmap 级别 |
|
||||
| `m_channels` | `int` | 通道数 |
|
||||
| `m_format` | `Format` | RHI 格式 |
|
||||
| `m_name` | `std::string` | 名称 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
// Load from file
|
||||
OpenGLTexture diffuse;
|
||||
diffuse.LoadFromFile("textures/diffuse.png");
|
||||
|
||||
// Create from data
|
||||
OpenGLTexture texture;
|
||||
unsigned char pixels[] = { ... };
|
||||
texture.Initialize2D(512, 512, 4, pixels);
|
||||
texture.SetFiltering(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
|
||||
texture.SetWrapping(GL_REPEAT, GL_REPEAT);
|
||||
texture.GenerateMipmap();
|
||||
|
||||
// Bind
|
||||
texture.Bind(0);
|
||||
glBindTextureUnit(0, texture.GetID());
|
||||
|
||||
// Compute image binding
|
||||
texture.BindImage(0, true, false);
|
||||
```
|
||||
@@ -1,88 +0,0 @@
|
||||
# OpenGLVertexArray
|
||||
|
||||
OpenGL 顶点数组对象 (VAO) 封装。
|
||||
|
||||
## 头文件
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/RHI/OpenGL/OpenGLVertexArray.h>
|
||||
```
|
||||
|
||||
## VertexAttribute
|
||||
|
||||
```cpp
|
||||
struct VertexAttribute {
|
||||
unsigned int index; // 属性索引 (layout location)
|
||||
int count; // 组件数量 (1-4)
|
||||
unsigned int type; // GL 类型 (GL_FLOAT, etc.)
|
||||
bool normalized; // 是否归一化
|
||||
size_t stride; // 顶点步长
|
||||
size_t offset; // 属性偏移
|
||||
};
|
||||
```
|
||||
|
||||
## 公共成员函数
|
||||
|
||||
#### `OpenGLVertexArray()`
|
||||
|
||||
#### `~OpenGLVertexArray()`
|
||||
|
||||
#### `bool Initialize()`
|
||||
|
||||
#### `void AddVertexBuffer(unsigned int buffer, const VertexAttribute& attribute)`
|
||||
|
||||
#### `void SetIndexBuffer(unsigned int buffer, unsigned int type)`
|
||||
|
||||
#### `void Shutdown()`
|
||||
|
||||
#### `void Bind() const`
|
||||
|
||||
#### `void Unbind() const`
|
||||
|
||||
#### `unsigned int GetID() const`
|
||||
|
||||
#### `unsigned int GetIndexBuffer() const`
|
||||
|
||||
#### `unsigned int GetIndexCount() const`
|
||||
|
||||
## 内部成员
|
||||
|
||||
| 成员 | 类型 | 描述 |
|
||||
|------|------|------|
|
||||
| `m_vao` | `unsigned int` | GL VAO ID |
|
||||
| `m_indexBuffer` | `unsigned int` | 索引缓冲区 |
|
||||
| `m_indexCount` | `unsigned int` | 索引数量 |
|
||||
| `m_vertexBufferCount` | `int` | 顶点缓冲区数量 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
OpenGLVertexArray vao;
|
||||
vao.Initialize();
|
||||
|
||||
// Position attribute
|
||||
VertexAttribute pos;
|
||||
pos.index = 0;
|
||||
pos.count = 3;
|
||||
pos.type = GL_FLOAT;
|
||||
pos.normalized = false;
|
||||
pos.stride = sizeof(Vertex);
|
||||
pos.offset = 0;
|
||||
vao.AddVertexBuffer(vb.GetID(), pos);
|
||||
|
||||
// UV attribute
|
||||
VertexAttribute uv;
|
||||
uv.index = 1;
|
||||
uv.count = 2;
|
||||
uv.type = GL_FLOAT;
|
||||
uv.normalized = false;
|
||||
uv.stride = sizeof(Vertex);
|
||||
uv.offset = sizeof(float) * 3;
|
||||
vao.AddVertexBuffer(vb.GetID(), uv);
|
||||
|
||||
// Index buffer
|
||||
vao.SetIndexBuffer(ib.GetID(), GL_UNSIGNED_SHORT);
|
||||
|
||||
vao.Bind();
|
||||
glDrawElements(GL_TRIANGLES, vao.GetIndexCount(), GL_UNSIGNED_SHORT, 0);
|
||||
```
|
||||
41
docs/api/rhi/opengl/overview.md
Normal file
41
docs/api/rhi/opengl/overview.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# OpenGL 后端概览
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**类型**: `module`
|
||||
|
||||
**描述**: OpenGL 后端实现模块,基于 GLFW 和现代 OpenGL (Core Profile)。
|
||||
|
||||
## 组件列表
|
||||
|
||||
| 组件 | 文档 |
|
||||
|------|------|
|
||||
| [OpenGLDevice](device/device.md) | OpenGL 设备实现 |
|
||||
| [OpenGLBuffer](buffer/buffer.md) | OpenGL 缓冲区实现 |
|
||||
| [OpenGLTexture](texture/texture.md) | OpenGL 纹理实现 |
|
||||
| [OpenGLCommandList](command-list/command-list.md) | OpenGL 命令列表实现 |
|
||||
| [OpenGLCommandQueue](command-queue/command-queue.md) | OpenGL 命令队列实现 |
|
||||
| [OpenGLSwapChain](swap-chain/swap-chain.md) | OpenGL 交换链实现 |
|
||||
| [OpenGLFence](fence/fence.md) | OpenGL 同步栅栏实现 |
|
||||
| [OpenGLShader](shader/shader.md) | OpenGL 着色器实现 |
|
||||
| [OpenGLPipelineState](pipeline-state/pipeline-state.md) | OpenGL 管线状态实现 |
|
||||
| [OpenGLSampler](sampler/sampler.md) | OpenGL 采样器实现 |
|
||||
| [OpenGLVertexArray](vertex-array/vertex-array.md) | OpenGL 顶点数组实现 |
|
||||
| [OpenGLRenderTargetView](render-target-view/render-target-view.md) | OpenGL 渲染目标实现 |
|
||||
| [OpenGLDepthStencilView](depth-stencil-view/depth-stencil-view.md) | OpenGL 深度模板实现 |
|
||||
|
||||
## 与 D3D12 的差异
|
||||
|
||||
| 方面 | D3D12 | OpenGL |
|
||||
|------|-------|--------|
|
||||
| 模式 | 命令列表录制 | 立即模式 |
|
||||
| 状态管理 | 显式资源状态 | OpenGL 状态机 |
|
||||
| 描述符 | 描述符堆 + 句柄 | 绑定点 |
|
||||
| 管线状态 | PSO(不可变) | 可变状态 |
|
||||
| 内存管理 | 显式显存管理 | 驱动自动管理 |
|
||||
| 多线程 | 需要 Bundle | 上下文共享 |
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [../rhi/rhi.md](../rhi.md) - RHI 模块总览
|
||||
- [D3D12 后端](overview.md)
|
||||
21
docs/api/rhi/opengl/pipeline-state/apply-blend.md
Normal file
21
docs/api/rhi/opengl/pipeline-state/apply-blend.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# OpenGLPipelineState::ApplyBlend
|
||||
|
||||
```cpp
|
||||
void ApplyBlend();
|
||||
```
|
||||
|
||||
应用混合状态到 OpenGL。
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
pipelineState->SetBlendState(blendState);
|
||||
pipelineState->ApplyBlend();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [Apply](apply.md) - 应用所有状态
|
||||
21
docs/api/rhi/opengl/pipeline-state/apply-depth-stencil.md
Normal file
21
docs/api/rhi/opengl/pipeline-state/apply-depth-stencil.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# OpenGLPipelineState::ApplyDepthStencil
|
||||
|
||||
```cpp
|
||||
void ApplyDepthStencil();
|
||||
```
|
||||
|
||||
应用深度模板状态到 OpenGL。
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
pipelineState->SetDepthStencilState(dsState);
|
||||
pipelineState->ApplyDepthStencil();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [Apply](apply.md) - 应用所有状态
|
||||
21
docs/api/rhi/opengl/pipeline-state/apply-rasterizer.md
Normal file
21
docs/api/rhi/opengl/pipeline-state/apply-rasterizer.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# OpenGLPipelineState::ApplyRasterizer
|
||||
|
||||
```cpp
|
||||
void ApplyRasterizer();
|
||||
```
|
||||
|
||||
应用光栅化状态到 OpenGL。
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
pipelineState->SetRasterizerState(rsState);
|
||||
pipelineState->ApplyRasterizer();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [Apply](apply.md) - 应用所有状态
|
||||
21
docs/api/rhi/opengl/pipeline-state/apply-scissor.md
Normal file
21
docs/api/rhi/opengl/pipeline-state/apply-scissor.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# OpenGLPipelineState::ApplyScissor
|
||||
|
||||
```cpp
|
||||
void ApplyScissor();
|
||||
```
|
||||
|
||||
应用裁剪状态到 OpenGL。
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
pipelineState->SetScissor(scissor);
|
||||
pipelineState->ApplyScissor();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [Apply](apply.md) - 应用所有状态
|
||||
21
docs/api/rhi/opengl/pipeline-state/apply-viewport.md
Normal file
21
docs/api/rhi/opengl/pipeline-state/apply-viewport.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# OpenGLPipelineState::ApplyViewport
|
||||
|
||||
```cpp
|
||||
void ApplyViewport();
|
||||
```
|
||||
|
||||
应用视口状态到 OpenGL。
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
pipelineState->SetViewport(viewport);
|
||||
pipelineState->ApplyViewport();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [Apply](apply.md) - 应用所有状态
|
||||
27
docs/api/rhi/opengl/pipeline-state/apply.md
Normal file
27
docs/api/rhi/opengl/pipeline-state/apply.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# OpenGLPipelineState::Apply
|
||||
|
||||
```cpp
|
||||
void Apply();
|
||||
```
|
||||
|
||||
应用所有管线状态(深度模板、混合、光栅化、视口、裁剪)。
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
pipelineState->SetDepthStencilState(dsState);
|
||||
pipelineState->SetBlendState(blendState);
|
||||
pipelineState->SetRasterizerState(rsState);
|
||||
pipelineState->SetViewport(viewport);
|
||||
pipelineState->SetScissor(scissor);
|
||||
pipelineState->Apply();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [ApplyDepthStencil](apply-depth-stencil.md) - 仅应用深度模板
|
||||
- [ApplyBlend](apply-blend.md) - 仅应用混合
|
||||
- [ApplyRasterizer](apply-rasterizer.md) - 仅应用光栅化
|
||||
23
docs/api/rhi/opengl/pipeline-state/attach-shader.md
Normal file
23
docs/api/rhi/opengl/pipeline-state/attach-shader.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# OpenGLPipelineState::AttachShader
|
||||
|
||||
```cpp
|
||||
void AttachShader(unsigned int program);
|
||||
```
|
||||
|
||||
附加 OpenGL 着色器程序到管线状态。
|
||||
|
||||
**参数:**
|
||||
- `program` - OpenGL 着色器程序 ID
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
pipelineState->AttachShader(shaderProgram);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [DetachShader](detach-shader.md) - 分离着色器程序
|
||||
20
docs/api/rhi/opengl/pipeline-state/detach-shader.md
Normal file
20
docs/api/rhi/opengl/pipeline-state/detach-shader.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLPipelineState::DetachShader
|
||||
|
||||
```cpp
|
||||
void DetachShader();
|
||||
```
|
||||
|
||||
从管线状态分离着色器程序。
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
pipelineState->DetachShader();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [AttachShader](attach-shader.md) - 附加着色器程序
|
||||
25
docs/api/rhi/opengl/pipeline-state/get-blend-state.md
Normal file
25
docs/api/rhi/opengl/pipeline-state/get-blend-state.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# OpenGLPipelineState::GetBlendState
|
||||
|
||||
```cpp
|
||||
const OpenGLBlendState& GetBlendState() const;
|
||||
```
|
||||
|
||||
获取当前混合状态。
|
||||
|
||||
**返回:** 混合状态结构体引用
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
const auto& blendState = pipelineState->GetBlendState();
|
||||
if (blendState.blendEnable) {
|
||||
// blend is enabled
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [SetBlendState](set-blend-state.md) - 设置混合状态
|
||||
@@ -0,0 +1,25 @@
|
||||
# OpenGLPipelineState::GetDepthStencilState
|
||||
|
||||
```cpp
|
||||
const OpenGLDepthStencilState& GetDepthStencilState() const;
|
||||
```
|
||||
|
||||
获取当前深度模板状态。
|
||||
|
||||
**返回:** 深度模板状态结构体引用
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
const auto& dsState = pipelineState->GetDepthStencilState();
|
||||
if (dsState.depthTestEnable) {
|
||||
// depth test is enabled
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [SetDepthStencilState](set-depth-stencil-state.md) - 设置深度模板状态
|
||||
25
docs/api/rhi/opengl/pipeline-state/get-rasterizer-state.md
Normal file
25
docs/api/rhi/opengl/pipeline-state/get-rasterizer-state.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# OpenGLPipelineState::GetRasterizerState
|
||||
|
||||
```cpp
|
||||
const OpenGLRasterizerState& GetRasterizerState() const;
|
||||
```
|
||||
|
||||
获取当前光栅化状态。
|
||||
|
||||
**返回:** 光栅化状态结构体引用
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
const auto& rsState = pipelineState->GetRasterizerState();
|
||||
if (rsState.cullFaceEnable) {
|
||||
// culling is enabled
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [SetRasterizerState](set-rasterizer-state.md) - 设置光栅化状态
|
||||
39
docs/api/rhi/opengl/pipeline-state/pipeline-state.md
Normal file
39
docs/api/rhi/opengl/pipeline-state/pipeline-state.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# OpenGLPipelineState
|
||||
|
||||
**命名空间**: `XCEngine::RHI`
|
||||
|
||||
**描述**: OpenGL 管线状态对象实现,继承自 `RHIPipelineState`。
|
||||
|
||||
## 方法列表
|
||||
|
||||
| 方法 | 文档 |
|
||||
|------|------|
|
||||
| `Shutdown` | [详细文档](../../../threading/task-system/shutdown.md) |
|
||||
| `Bind` | [详细文档](../../shader/bind.md) |
|
||||
| `Unbind` | [详细文档](../../shader/unbind.md) |
|
||||
| `GetNativeHandle` | [详细文档](../../buffer/get-native-handle.md) |
|
||||
| `GetType` | [详细文档](../../shader/get-type.md) |
|
||||
| `SetDepthStencilState` | [详细文档](set-depth-stencil-state.md) |
|
||||
| `SetBlendState` | [详细文档](set-blend-state.md) |
|
||||
| `SetRasterizerState` | [详细文档](set-rasterizer-state.md) |
|
||||
| `SetViewport` | [详细文档](set-viewport.md) |
|
||||
| `SetScissor` | [详细文档](set-scissor.md) |
|
||||
| `SetLogicalOperation` | [详细文档](set-logical-operation.md) |
|
||||
| `Apply` | [详细文档](apply.md) |
|
||||
| `ApplyDepthStencil` | [详细文档](apply-depth-stencil.md) |
|
||||
| `ApplyBlend` | [详细文档](apply-blend.md) |
|
||||
| `ApplyRasterizer` | [详细文档](apply-rasterizer.md) |
|
||||
| `ApplyViewport` | [详细文档](apply-viewport.md) |
|
||||
| `ApplyScissor` | [详细文档](apply-scissor.md) |
|
||||
| `SetClearColor` | [详细文档](set-clear-color.md) |
|
||||
| `Clear` | [详细文档](../../../memory/linear-allocator/clear.md) |
|
||||
| `AttachShader` | [详细文档](attach-shader.md) |
|
||||
| `DetachShader` | [详细文档](detach-shader.md) |
|
||||
| `GetDepthStencilState` | [详细文档](get-depth-stencil-state.md) |
|
||||
| `GetBlendState` | [详细文档](get-blend-state.md) |
|
||||
| `GetRasterizerState` | [详细文档](get-rasterizer-state.md) |
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGL 后端总览](../overview.md)
|
||||
- [RHIPipelineState](../../pipeline-state/pipeline-state.md) - 抽象管线状态接口
|
||||
27
docs/api/rhi/opengl/pipeline-state/set-blend-state.md
Normal file
27
docs/api/rhi/opengl/pipeline-state/set-blend-state.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# OpenGLPipelineState::SetBlendState
|
||||
|
||||
```cpp
|
||||
void SetBlendState(const OpenGLBlendState& state);
|
||||
```
|
||||
|
||||
设置混合状态。
|
||||
|
||||
**参数:**
|
||||
- `state` - 混合状态结构体
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLBlendState blendState;
|
||||
blendState.blendEnable = true;
|
||||
blendState.srcBlend = BlendFactor::SrcAlpha;
|
||||
blendState.dstBlend = BlendFactor::InvSrcAlpha;
|
||||
pipelineState->SetBlendState(blendState);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [GetBlendState](get-blend-state.md) - 获取混合状态
|
||||
26
docs/api/rhi/opengl/pipeline-state/set-clear-color.md
Normal file
26
docs/api/rhi/opengl/pipeline-state/set-clear-color.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# OpenGLPipelineState::SetClearColor
|
||||
|
||||
```cpp
|
||||
void SetClearColor(float r, float g, float b, float a);
|
||||
```
|
||||
|
||||
设置清除颜色值。
|
||||
|
||||
**参数:**
|
||||
- `r` - 红色通道 (0.0 ~ 1.0)
|
||||
- `g` - 绿色通道 (0.0 ~ 1.0)
|
||||
- `b` - 蓝色通道 (0.0 ~ 1.0)
|
||||
- `a` - Alpha 通道 (0.0 ~ 1.0)
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
pipelineState->SetClearColor(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
pipelineState->Clear(GL_COLOR_BUFFER_BIT);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
@@ -0,0 +1,27 @@
|
||||
# OpenGLPipelineState::SetDepthStencilState
|
||||
|
||||
```cpp
|
||||
void SetDepthStencilState(const OpenGLDepthStencilState& state);
|
||||
```
|
||||
|
||||
设置深度模板状态。
|
||||
|
||||
**参数:**
|
||||
- `state` - 深度模板状态结构体
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLDepthStencilState dsState;
|
||||
dsState.depthTestEnable = true;
|
||||
dsState.depthWriteEnable = true;
|
||||
dsState.depthFunc = ComparisonFunc::Less;
|
||||
pipelineState->SetDepthStencilState(dsState);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [GetDepthStencilState](get-depth-stencil-state.md) - 获取深度模板状态
|
||||
25
docs/api/rhi/opengl/pipeline-state/set-logical-operation.md
Normal file
25
docs/api/rhi/opengl/pipeline-state/set-logical-operation.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# OpenGLPipelineState::SetLogicalOperation
|
||||
|
||||
```cpp
|
||||
void SetLogicalOperation(const LogicalOperation& state);
|
||||
```
|
||||
|
||||
设置逻辑操作状态。
|
||||
|
||||
**参数:**
|
||||
- `state` - 逻辑操作状态结构体
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
LogicalOperation op;
|
||||
op.enable = false;
|
||||
op.operation = 0;
|
||||
pipelineState->SetLogicalOperation(op);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
27
docs/api/rhi/opengl/pipeline-state/set-rasterizer-state.md
Normal file
27
docs/api/rhi/opengl/pipeline-state/set-rasterizer-state.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# OpenGLPipelineState::SetRasterizerState
|
||||
|
||||
```cpp
|
||||
void SetRasterizerState(const OpenGLRasterizerState& state);
|
||||
```
|
||||
|
||||
设置光栅化状态。
|
||||
|
||||
**参数:**
|
||||
- `state` - 光栅化状态结构体
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLRasterizerState rsState;
|
||||
rsState.cullFaceEnable = true;
|
||||
rsState.cullFace = CullFace::Back;
|
||||
rsState.frontFace = FrontFace::CounterClockwise;
|
||||
pipelineState->SetRasterizerState(rsState);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [GetRasterizerState](get-rasterizer-state.md) - 获取光栅化状态
|
||||
29
docs/api/rhi/opengl/pipeline-state/set-scissor.md
Normal file
29
docs/api/rhi/opengl/pipeline-state/set-scissor.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# OpenGLPipelineState::SetScissor
|
||||
|
||||
```cpp
|
||||
void SetScissor(const ScissorState& state);
|
||||
```
|
||||
|
||||
设置裁剪状态。
|
||||
|
||||
**参数:**
|
||||
- `state` - 裁剪状态结构体
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ScissorState scissor;
|
||||
scissor.enable = true;
|
||||
scissor.x = 0;
|
||||
scissor.y = 0;
|
||||
scissor.width = 1920;
|
||||
scissor.height = 1080;
|
||||
pipelineState->SetScissor(scissor);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [ApplyScissor](apply-scissor.md) - 应用裁剪状态
|
||||
30
docs/api/rhi/opengl/pipeline-state/set-viewport.md
Normal file
30
docs/api/rhi/opengl/pipeline-state/set-viewport.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# OpenGLPipelineState::SetViewport
|
||||
|
||||
```cpp
|
||||
void SetViewport(const ViewportState& state);
|
||||
```
|
||||
|
||||
设置视口状态。
|
||||
|
||||
**参数:**
|
||||
- `state` - 视口状态结构体
|
||||
|
||||
**线程安全:** ❌
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
ViewportState viewport;
|
||||
viewport.x = 0;
|
||||
viewport.y = 0;
|
||||
viewport.width = 1920;
|
||||
viewport.height = 1080;
|
||||
viewport.minDepth = 0.0f;
|
||||
viewport.maxDepth = 1.0f;
|
||||
pipelineState->SetViewport(viewport);
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
|
||||
- [ApplyViewport](apply-viewport.md) - 应用视口状态
|
||||
20
docs/api/rhi/opengl/render-target-view/bind-framebuffer.md
Normal file
20
docs/api/rhi/opengl/render-target-view/bind-framebuffer.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# OpenGLRenderTargetView::BindFramebuffer
|
||||
|
||||
```cpp
|
||||
static void BindFramebuffer(unsigned int framebuffer)
|
||||
```
|
||||
|
||||
静态方法,将指定帧缓冲区绑定为当前渲染目标。
|
||||
|
||||
**参数:**
|
||||
- `framebuffer` - 帧缓冲区 ID(0 表示解除绑定)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
OpenGLRenderTargetView::BindFramebuffer(rtv.GetFramebuffer());
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLRenderTargetView](render-target-view.md) - 返回类总览
|
||||
19
docs/api/rhi/opengl/render-target-view/get-framebuffer.md
Normal file
19
docs/api/rhi/opengl/render-target-view/get-framebuffer.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLRenderTargetView::GetFramebuffer
|
||||
|
||||
```cpp
|
||||
unsigned int GetFramebuffer() const
|
||||
```
|
||||
|
||||
获取帧缓冲区对象 ID。
|
||||
|
||||
**返回:** `unsigned int` - 帧缓冲区 ID
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
unsigned int fbo = rtv.GetFramebuffer();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLRenderTargetView](render-target-view.md) - 返回类总览
|
||||
19
docs/api/rhi/opengl/render-target-view/get-mip-level.md
Normal file
19
docs/api/rhi/opengl/render-target-view/get-mip-level.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# OpenGLRenderTargetView::GetMipLevel
|
||||
|
||||
```cpp
|
||||
int GetMipLevel() const
|
||||
```
|
||||
|
||||
获取 mipmap 级别。
|
||||
|
||||
**返回:** `int` - mip 级别
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
int mipLevel = rtv.GetMipLevel();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [OpenGLRenderTargetView](render-target-view.md) - 返回类总览
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user