fix: improve doc link navigation and tree display

- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
This commit is contained in:
2026-03-19 12:44:08 +08:00
parent e003fe6513
commit 58a83f445a
1012 changed files with 56880 additions and 22 deletions

View 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 抽象层](overview.md)

View 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) - 返回类总览

View File

@@ -0,0 +1,17 @@
# OpenGLBuffer::Bind
```cpp
void Bind() const;
```
绑定缓冲区到 OpenGL 目标。
**示例:**
```cpp
buffer.Bind();
```
## 相关文档
- [OpenGLBuffer 总览](buffer.md) - 返回类总览

View File

@@ -0,0 +1,38 @@
# OpenGLBuffer
**命名空间**: `XCEngine::RHI`
**描述**: OpenGL 缓冲区的实现,继承自 `RHIBuffer`
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Initialize`](initialize.md) | 初始化缓冲区 |
| [`InitializeVertexBuffer`](initialize-vertex-buffer.md) | 初始化顶点缓冲 |
| [`InitializeIndexBuffer`](initialize-index-buffer.md) | 初始化索引缓冲 |
| [`Shutdown`](../../../threading/task-system/shutdown.md) | 关闭缓冲区 |
| [`Bind`](bind.md) | 绑定缓冲区 |
| [`Unbind`](unbind.md) | 解绑缓冲区 |
| [`BindBase`](bind-base.md) | 绑定到基准点 |
| [`Map`](../../buffer/map.md) | 映射缓冲区 |
| [`Unmap`](../../buffer/unmap.md) | 取消映射 |
| [`SetData`](../../buffer/set-data.md) | 设置数据 |
| [`GetID`](get-id.md) | 获取 OpenGL 缓冲 ID |
| [`GetSize`](../../buffer/get-size.md) | 获取缓冲区大小 |
| [`GetType`](get-type.md) | 获取缓冲区类型 |
| [`IsDynamic`](is-dynamic.md) | 检查是否动态 |
| [`GetBufferType`](../../buffer/get-buffer-type.md) | 获取缓冲区类型 |
| [`SetBufferType`](../../buffer/set-buffer-type.md) | 设置缓冲区类型 |
| [`GetStride`](../../buffer/get-stride.md) | 获取步长 |
| [`SetStride`](../../buffer/set-stride.md) | 设置步长 |
| [`GetNativeHandle`](../../buffer/get-native-handle.md) | 获取原生句柄 |
| [`GetState`](../../buffer/get-state.md) | 获取资源状态 |
| [`SetState`](../../buffer/set-state.md) | 设置资源状态 |
| [`GetName`](../../buffer/get-name.md) | 获取资源名称 |
| [`SetName`](../../buffer/set-name.md) | 设置资源名称 |
## 相关文档
- [OpenGL 后端总览](../overview.md)
- [RHIBuffer](../../buffer/buffer.md) - 抽象缓冲区接口

View 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) - 返回类总览

View File

@@ -0,0 +1,19 @@
# OpenGLBuffer::GetType
```cpp
OpenGLBufferType GetType() const;
```
获取缓冲区类型。
**返回:** OpenGL 缓冲区类型
**示例:**
```cpp
OpenGLBufferType type = buffer.GetType();
```
## 相关文档
- [OpenGLBuffer 总览](buffer.md) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View File

@@ -0,0 +1,26 @@
# OpenGLBuffer::Initialize
```cpp
bool Initialize(OpenGLBufferType type, size_t size, const void* data = nullptr, bool dynamic = false);
```
初始化 OpenGL 缓冲区。
**参数:**
- `type` - 缓冲区类型
- `size` - 缓冲区大小(字节)
- `data` - 初始数据指针(可选)
- `dynamic` - 是否为动态缓冲区
**返回:** 成功返回 true
**示例:**
```cpp
OpenGLBuffer buffer;
buffer.Initialize(OpenGLBufferType::Vertex, sizeof(vertices), vertices);
```
## 相关文档
- [OpenGLBuffer 总览](buffer.md) - 返回类总览

View 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) - 返回类总览

View File

@@ -0,0 +1,17 @@
# OpenGLBuffer::Unbind
```cpp
void Unbind() const;
```
解除绑定缓冲区。
**示例:**
```cpp
buffer.Unbind();
```
## 相关文档
- [OpenGLBuffer 总览](buffer.md) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View File

@@ -0,0 +1,20 @@
# OpenGLCommandList::ClearStencil
```cpp
void ClearStencil(int stencil)
```
清除模板缓冲区。
**参数:**
- `stencil` - 模板值
**示例:**
```cpp
commandList->ClearStencil(0);
```
## 相关文档
- [OpenGLCommandList](command-list.md) - 返回类总览

View File

@@ -0,0 +1,24 @@
# OpenGLCommandList::Clear
```cpp
void Clear(float r, float g, float b, float a, unsigned int buffers);
```
清除缓冲区。
**参数:**
- `r` - 红色分量
- `g` - 绿色分量
- `b` - 蓝色分量
- `a` - Alpha 分量
- `buffers` - 要清除的缓冲区标志
**示例:**
```cpp
commandList->Clear(0.0f, 0.0f, 0.0f, 1.0f, Color | Depth);
```
## 相关文档
- [OpenGLCommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,44 @@
# OpenGLCommandList
**命名空间**: `XCEngine::RHI`
**描述**: OpenGL 命令列表实现,继承自 `RHICommandList`
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Shutdown`](../../../threading/task-system/shutdown.md) | 关闭命令列表 |
| [`Reset`](../../command-list/reset.md) | 重置命令列表 |
| [`Close`](../../command-list/close.md) | 关闭命令列表 |
| [`Clear`](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) | 清除渲染目标 |
| [`Draw`](draw.md) | 绘制 |
| [`DrawIndexed`](draw-indexed.md) | 索引绘制 |
| [`Dispatch`](dispatch.md) | 分发计算任务 |
| [`CopyResource`](copy-resource.md) | 复制资源 |
| [`OpenGLMethods`](opengl-methods.md) | OpenGL 特有方法 |
## 相关文档
- [OpenGL 后端总览](../overview.md)
- [RHICommandList](../../command-list/command-list.md) - 抽象命令列表接口

View 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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View 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()
```
推送/弹出调试组。

View 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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View File

@@ -0,0 +1,20 @@
# OpenGLCommandList::SetPipelineState
```cpp
void SetPipelineState(void* pipelineState)
```
设置渲染管线状态。
**参数:**
- `pipelineState` - 管线状态对象指针
**示例:**
```cpp
commandList->SetPipelineState(pipelineState);
```
## 相关文档
- [OpenGLCommandList](command-list.md) - 返回类总览

View File

@@ -0,0 +1,20 @@
# OpenGLCommandList::SetPrimitiveTopology
```cpp
void SetPrimitiveTopology(PrimitiveTopology topology)
```
设置图元拓扑类型。
**参数:**
- `topology` - 图元拓扑类型
**示例:**
```cpp
commandList->SetPrimitiveTopology(PrimitiveTopology::TriangleList);
```
## 相关文档
- [OpenGLCommandList](command-list.md) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View File

@@ -0,0 +1,20 @@
# OpenGLCommandList::SetStencilRef
```cpp
void SetStencilRef(uint8_t ref)
```
设置模板测试参考值。
**参数:**
- `ref` - 模板参考值
**示例:**
```cpp
commandList->SetStencilRef(1);
```
## 相关文档
- [OpenGLCommandList](command-list.md) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View 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`](../../command-queue/get-type.md) | 获取队列类型 |
| [`GetTimestampFrequency`](get-timestamp-frequency.md) | 获取时间戳频率 |
| [`GetNativeHandle`](../../buffer/get-native-handle.md) | 获取原生句柄 |
## 相关文档
- [OpenGL 后端总览](../overview.md)
- [RHICommandQueue](../../command-queue/command-queue.md) - 抽象命令队列接口

View 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) - 返回类总览

View File

@@ -0,0 +1,19 @@
# OpenGLCommandQueue::GetCompletedValue
```cpp
uint64_t GetCompletedValue()
```
获取已完成的值。
**返回:** 已完成的围栏值
**示例:**
```cpp
uint64_t value = commandQueue->GetCompletedValue();
```
## 相关文档
- [OpenGLCommandQueue](command-queue.md) - 返回类总览

View File

@@ -0,0 +1,19 @@
# OpenGLCommandQueue::GetTimestampFrequency
```cpp
uint64_t GetTimestampFrequency() const
```
获取时间戳频率。
**返回:** 时间戳频率Hz
**示例:**
```cpp
uint64_t frequency = commandQueue->GetTimestampFrequency();
```
## 相关文档
- [OpenGLCommandQueue](command-queue.md) - 返回类总览

View 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) - 返回类总览

View File

@@ -0,0 +1,17 @@
# OpenGLCommandQueue::WaitForIdle
```cpp
void WaitForIdle()
```
等待命令队列空闲。
**示例:**
```cpp
commandQueue->WaitForIdle();
```
## 相关文档
- [OpenGLCommandQueue](command-queue.md) - 返回类总览

View File

@@ -0,0 +1,20 @@
# OpenGLDepthStencilView::BindFramebuffer
```cpp
static void BindFramebuffer(unsigned int framebuffer)
```
静态方法,将指定帧缓冲区绑定为当前深度模板帧缓冲区。
**参数:**
- `framebuffer` - 帧缓冲区 ID0 表示解除绑定)
**示例:**
```cpp
OpenGLDepthStencilView::BindFramebuffer(dsv.GetFramebuffer());
```
## 相关文档
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览

View File

@@ -0,0 +1,11 @@
# OpenGLDepthStencilView::Bind
```cpp
void Bind() const;
```
绑定深度模板视图。
## 相关文档
- [OpenGLDepthStencilView 总览](depth-stencil-view.md) - 返回类总览

View File

@@ -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) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View File

@@ -0,0 +1,29 @@
# OpenGLDepthStencilView
**命名空间**: `XCEngine::RHI`
**描述**: OpenGL 深度模板视图实现。
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Initialize`](initialize.md) | 初始化深度模板视图 |
| [`InitializeCubemap`](initialize-cubemap.md) | 初始化立方体贴图深度模板视图 |
| [`Shutdown`](shutdown.md) | 关闭深度模板视图 |
| [`Bind`](bind.md) | 绑定深度模板视图 |
| [`Unbind`](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) | 获取 Mip 级别 |
| [`GetWidth`](get-size.md) | 获取宽度 |
| [`GetHeight`](get-size.md) | 获取高度 |
| [`BindFramebuffer`](bind-framebuffer.md) | 绑定帧缓冲 |
| [`UnbindFramebuffer`](unbind-framebuffer.md) | 解绑帧缓冲 |
## 相关文档
- [OpenGL 后端总览](../overview.md)

View 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) - 返回类总览

View File

@@ -0,0 +1,19 @@
# OpenGLDepthStencilView::GetMipLevel
```cpp
int GetMipLevel() const
```
获取 mipmap 级别。
**返回:** `int` - mip 级别
**示例:**
```cpp
int mipLevel = dsv.GetMipLevel();
```
## 相关文档
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览

View File

@@ -0,0 +1,14 @@
# OpenGLDepthStencilView::GetWidth / GetHeight
```cpp
int GetWidth() const;
int GetHeight() const;
```
获取深度模板视图的宽度和高度。
**返回:** 宽度/高度
## 相关文档
- [OpenGLDepthStencilView 总览](depth-stencil-view.md) - 返回类总览

View 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) - 返回类总览

View 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) - 返回类总览

View File

@@ -0,0 +1,18 @@
# OpenGLDepthStencilView::Initialize
```cpp
bool Initialize(unsigned int texture, int width, int height);
```
初始化深度模板视图。
**参数:**
- `texture` - OpenGL 纹理 ID
- `width` - 宽度
- `height` - 高度
**返回:** 成功返回 true
## 相关文档
- [OpenGLDepthStencilView 总览](depth-stencil-view.md) - 返回类总览

View File

@@ -0,0 +1,11 @@
# OpenGLDepthStencilView::Shutdown
```cpp
void Shutdown();
```
关闭深度模板视图。
## 相关文档
- [OpenGLDepthStencilView 总览](depth-stencil-view.md) - 返回类总览

View File

@@ -0,0 +1,17 @@
# OpenGLDepthStencilView::UnbindFramebuffer
```cpp
static void UnbindFramebuffer()
```
静态方法,解除当前深度模板帧缓冲区的绑定。
**示例:**
```cpp
OpenGLDepthStencilView::UnbindFramebuffer();
```
## 相关文档
- [OpenGLDepthStencilView](depth-stencil-view.md) - 返回类总览

View File

@@ -0,0 +1,11 @@
# OpenGLDepthStencilView::Unbind
```cpp
void Unbind() const;
```
解除绑定深度模板视图。
## 相关文档
- [OpenGLDepthStencilView 总览](depth-stencil-view.md) - 返回类总览

View 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) - 返回类总览

View 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) - 抽象设备接口

View 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) - 返回类总览

View File

@@ -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) - 返回类总览

View File

@@ -0,0 +1,23 @@
# OpenGLDevice::PollEvents
```cpp
bool PollEvents()
```
处理所有挂起的 GLFW 事件(窗口事件、输入事件等)。
**返回:** `bool` - 如果窗口应保持打开返回 true如果窗口应关闭返回 false
**示例:**
```cpp
while (device.PollEvents()) {
// 渲染和交换缓冲区
renderScene();
device.SwapBuffers();
}
```
## 相关文档
- [OpenGLDevice](device.md) - 返回类总览

View File

@@ -0,0 +1,20 @@
# OpenGLDevice::SetShouldClose
```cpp
void SetShouldClose(bool shouldClose)
```
设置窗口是否应该关闭的标志。
**参数:**
- `shouldClose` - true 表示窗口应该关闭false 表示保持打开
**示例:**
```cpp
device.SetShouldClose(true); // 请求关闭窗口
```
## 相关文档
- [OpenGLDevice](device.md) - 返回类总览

View 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) - 返回类总览

View File

@@ -0,0 +1,19 @@
# OpenGLDevice::SwapBuffers
```cpp
void SwapBuffers()
```
交换前后缓冲区,将渲染内容显示到屏幕上。
**示例:**
```cpp
// 渲染完成后交换缓冲区
renderScene();
device.SwapBuffers();
```
## 相关文档
- [OpenGLDevice](device.md) - 返回类总览

View File

@@ -0,0 +1,25 @@
# OpenGLFence
**命名空间**: `XCEngine::RHI`
**描述**: OpenGL 栅栏同步实现,继承自 `RHIFence`
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Initialize`](initialize.md) | 初始化栅栏 |
| [`Shutdown`](../../../threading/task-system/shutdown.md) | 关闭栅栏 |
| [`Signal`](signal.md) | 信号栅栏 |
| [`Wait`](../../../threading/task-group/wait.md) | 等待栅栏 |
| [`Reset`](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) - 抽象栅栏接口

View File

@@ -0,0 +1,19 @@
# OpenGLFence::GetCompletedValue
```cpp
uint64_t GetCompletedValue() const override
```
获取已完成的最大栅栏值。
**返回:** `uint64_t` - 已完成的栅栏值
**示例:**
```cpp
uint64_t completed = fence.GetCompletedValue();
```
## 相关文档
- [OpenGLFence](fence.md) - 返回类总览

View File

@@ -0,0 +1,19 @@
# OpenGLFence::GetCurrentValue
```cpp
uint64_t GetCurrentValue() const
```
获取栅栏的当前值。
**返回:** `uint64_t` - 当前栅栏值
**示例:**
```cpp
uint64_t current = fence.GetCurrentValue();
```
## 相关文档
- [OpenGLFence](fence.md) - 返回类总览

View 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) - 返回类总览

View File

@@ -0,0 +1,23 @@
# OpenGLFence::Initialize
```cpp
bool Initialize(bool signaled = false);
```
初始化 OpenGL 栅栏。
**参数:**
- `signaled` - 初始是否为 signaled 状态
**返回:** 成功返回 true
**示例:**
```cpp
OpenGLFence fence;
fence.Initialize(true);
```
## 相关文档
- [OpenGLFence 总览](fence.md) - 返回类总览

View File

@@ -0,0 +1,21 @@
# OpenGLFence::IsSignaled
```cpp
bool IsSignaled() const override
```
检查栅栏是否处于 signaled 状态。
**返回:** `bool` - 如果栅栏已signaled返回 true否则返回 false
**示例:**
```cpp
if (fence.IsSignaled()) {
// 可以安全地继续执行
}
```
## 相关文档
- [OpenGLFence](fence.md) - 返回类总览

View File

@@ -0,0 +1,17 @@
# OpenGLFence::Reset
```cpp
void Reset();
```
重置栅栏。
**示例:**
```cpp
fence->Reset();
```
## 相关文档
- [OpenGLFence 总览](fence.md) - 返回类总览

View 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) - 返回类总览

View 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)

View File

@@ -0,0 +1,21 @@
# OpenGLPipelineState::ApplyBlend
```cpp
void ApplyBlend();
```
应用混合状态到 OpenGL。
**线程安全:**
**示例:**
```cpp
pipelineState->SetBlendState(blendState);
pipelineState->ApplyBlend();
```
## 相关文档
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
- [Apply](apply.md) - 应用所有状态

View File

@@ -0,0 +1,21 @@
# OpenGLPipelineState::ApplyDepthStencil
```cpp
void ApplyDepthStencil();
```
应用深度模板状态到 OpenGL。
**线程安全:**
**示例:**
```cpp
pipelineState->SetDepthStencilState(dsState);
pipelineState->ApplyDepthStencil();
```
## 相关文档
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
- [Apply](apply.md) - 应用所有状态

View File

@@ -0,0 +1,21 @@
# OpenGLPipelineState::ApplyRasterizer
```cpp
void ApplyRasterizer();
```
应用光栅化状态到 OpenGL。
**线程安全:**
**示例:**
```cpp
pipelineState->SetRasterizerState(rsState);
pipelineState->ApplyRasterizer();
```
## 相关文档
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
- [Apply](apply.md) - 应用所有状态

View File

@@ -0,0 +1,21 @@
# OpenGLPipelineState::ApplyScissor
```cpp
void ApplyScissor();
```
应用裁剪状态到 OpenGL。
**线程安全:**
**示例:**
```cpp
pipelineState->SetScissor(scissor);
pipelineState->ApplyScissor();
```
## 相关文档
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
- [Apply](apply.md) - 应用所有状态

View File

@@ -0,0 +1,21 @@
# OpenGLPipelineState::ApplyViewport
```cpp
void ApplyViewport();
```
应用视口状态到 OpenGL。
**线程安全:**
**示例:**
```cpp
pipelineState->SetViewport(viewport);
pipelineState->ApplyViewport();
```
## 相关文档
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
- [Apply](apply.md) - 应用所有状态

View 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) - 仅应用光栅化

View 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) - 分离着色器程序

View File

@@ -0,0 +1,20 @@
# OpenGLPipelineState::DetachShader
```cpp
void DetachShader();
```
从管线状态分离着色器程序。
**线程安全:**
**示例:**
```cpp
pipelineState->DetachShader();
```
## 相关文档
- [OpenGLPipelineState 总览](pipeline-state.md) - 返回类总览
- [AttachShader](attach-shader.md) - 附加着色器程序

View 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) - 设置混合状态

View File

@@ -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) - 设置深度模板状态

View 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) - 设置光栅化状态

View 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`](../../command-queue/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`](../../command-list/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) - 抽象管线状态接口

View 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) - 获取混合状态

View 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) - 返回类总览

View File

@@ -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) - 获取深度模板状态

View 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) - 返回类总览

View 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) - 获取光栅化状态

View 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) - 应用裁剪状态

View 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) - 应用视口状态

View File

@@ -0,0 +1,20 @@
# OpenGLRenderTargetView::BindFramebuffer
```cpp
static void BindFramebuffer(unsigned int framebuffer)
```
静态方法,将指定帧缓冲区绑定为当前渲染目标。
**参数:**
- `framebuffer` - 帧缓冲区 ID0 表示解除绑定)
**示例:**
```cpp
OpenGLRenderTargetView::BindFramebuffer(rtv.GetFramebuffer());
```
## 相关文档
- [OpenGLRenderTargetView](render-target-view.md) - 返回类总览

View File

@@ -0,0 +1,11 @@
# OpenGLRenderTargetView::Bind
```cpp
void Bind() const;
```
绑定渲染目标视图。
## 相关文档
- [OpenGLRenderTargetView 总览](render-target-view.md) - 返回类总览

View File

@@ -0,0 +1,17 @@
# OpenGLRenderTargetView::Clear
```cpp
void Clear(float r, float g, float b, float a);
```
清除渲染目标视图。
**参数:**
- `r` - 红色分量
- `g` - 绿色分量
- `b` - 蓝色分量
- `a` - Alpha 分量
## 相关文档
- [OpenGLRenderTargetView 总览](render-target-view.md) - 返回类总览

View 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) - 返回类总览

View 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