docs: update RHI API docs

This commit is contained in:
2026-03-20 02:35:45 +08:00
parent ea756c0177
commit 070b444f8f
501 changed files with 13493 additions and 2022 deletions

View File

@@ -4,10 +4,14 @@
void Bind(unsigned int unit);
```
绑定采样器到纹理单元。
绑定采样器到指定纹理单元。调用 `glBindSampler` 将采样器对象绑定到对应的纹理单元,后续纹理采样操作将使用该采样器。
**参数:**
- `unit` - 纹理单元编号
- `unit` - 纹理单元编号,通常为 0-15
**返回:**
**线程安全:**
**复杂度:** O(1)

View File

@@ -0,0 +1,23 @@
# OpenGLSampler::OpenGLSampler
```cpp
OpenGLSampler();
```
构造一个空的 OpenGLSampler 对象。实际采样器 ID 在调用 `Initialize` 之前无效(为 0
**参数:**
**返回:**
**复杂度:** O(1)
**示例:**
```cpp
OpenGLSampler sampler;
```
## 相关文档
- [OpenGLSampler 总览](sampler.md) - 返回类总览

View File

@@ -1,13 +1,19 @@
# OpenGLSampler::GetID
```cpp
unsigned int GetID() const
unsigned int GetID() override
unsigned int GetID() const;
unsigned int GetID() override;
```
获取 OpenGL 采样器对象 ID。
获取 OpenGL 采样器对象 ID。返回 `glGenSamplers` 生成的采样器对象名称。
**返回** `unsigned int` - 采样器 ID
**参数**
**返回:** `unsigned int` - OpenGL 采样器 ID
**线程安全:**
**复杂度:** O(1)
**示例:**

View File

@@ -4,13 +4,25 @@
bool Initialize(const OpenGLSamplerDesc& desc);
```
初始化采样器。
初始化采样器。创建 OpenGL 采样器对象并根据描述符设置各项参数,包括过滤模式、环绕模式、各向异性级别和 LOD 范围。
**参数:**
- `desc` - 采样器描述符
- `desc` - 采样器描述符,包含以下字段:
- `minFilter` - 缩小过滤模式
- `magFilter` - 放大过滤模式
- `wrapS` - S轴环绕模式
- `wrapT` - T轴环绕模式
- `wrapR` - R轴环绕模式
- `maxAnisotropy` - 各向异性级别
- `minLod` - 最小 LOD 值
- `maxLod` - 最大 LOD 值
- `compareMode` - 比较模式(当前实现未使用)
- `compareFunc` - 比较函数(当前实现未使用)
**返回:** 成功返回 `true`,失败返回 `false`
**线程安全:**
**复杂度:** O(1)
**示例:**
@@ -21,7 +33,14 @@ desc.minFilter = SamplerFilter::LinearMipmapLinear;
desc.magFilter = SamplerFilter::Linear;
desc.wrapS = SamplerWrapMode::Repeat;
desc.wrapT = SamplerWrapMode::Repeat;
sampler.Initialize(desc);
desc.maxAnisotropy = 16.0f;
desc.minLod = -1000.0f;
desc.maxLod = 1000.0f;
OpenGLSampler sampler;
if (sampler.Initialize(desc)) {
// 采样器初始化成功
}
```
## 相关文档

View File

@@ -1,19 +1,70 @@
# OpenGLSampler
**命名空间**: `XCEngine::RHI`
## 命名空间
**描述**: OpenGL 采样器实现,继承自 `RHISampler`
`XCEngine::RHI`
## 头文件
`XCEngine/RHI/OpenGL/OpenGLSampler.h`
## 类型
| 类型 | 说明 |
|------|------|
| `OpenGLSampler` | OpenGL 采样器封装类,继承自 `RHISampler` |
| `OpenGLSamplerDesc` | 采样器描述结构体 |
| `SamplerWrapMode` | 采样器环绕模式枚举 |
| `SamplerFilter` | 采样器滤镜模式枚举 |
| `SamplerCompareMode` | 采样器比较模式枚举 |
## 描述
OpenGL 采样器实现,继承自 `RHISampler`
## 概述
`OpenGLSampler` 是 RHI 抽象层对 OpenGL 纹理采样器的封装。通过 `OpenGLSamplerDesc` 配置采样参数过滤模式、环绕模式、各向异性、LOD 等),`Initialize` 方法创建 OpenGL 采样器对象,`Bind`/`Unbind` 控制采样器与纹理单元的绑定状态。
**关键特性:**
- 支持点采样、线性采样、各向异性采样
- 支持 Repeat、Mirror、Clamp、Border 等寻址模式
- 支持 Mipmap 多级渐远纹理过滤
- 支持各向异性过滤和 LOD 范围控制
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Initialize`](initialize.md) | 初始化采样器 |
| [`Shutdown`](../../../threading/task-system/shutdown.md) | 关闭采样器 |
| [`Bind`](bind.md) | 绑定采样器 |
| [`OpenGLSampler`](constructor.md) | 构造函数 |
| [`Initialize`](initialize.md) | 初始化采样器OpenGL 特有) |
| [`Shutdown`](shutdown.md) | 关闭采样器 |
| [`Bind`](bind.md) | 绑定采样器到纹理单元 |
| [`Unbind`](unbind.md) | 解绑采样器 |
| [`GetID`](get-id.md) | 获取采样器 ID |
| [`GetNativeHandle`](../../buffer/get-native-handle.md) | 获取原生句柄 |
| [`GetNativeHandle`](../../sampler/get-native-handle.md) | 获取原生句柄(继承自 `RHISampler` |
## 使用示例
```cpp
#include "XCEngine/RHI/OpenGL/OpenGLSampler.h"
using namespace XCEngine::RHI;
OpenGLSamplerDesc desc;
desc.minFilter = SamplerFilter::LinearMipmapLinear;
desc.magFilter = SamplerFilter::Linear;
desc.wrapS = SamplerWrapMode::Repeat;
desc.wrapT = SamplerWrapMode::Repeat;
desc.maxAnisotropy = 16.0f;
OpenGLSampler sampler;
if (sampler.Initialize(desc)) {
sampler.Bind(0);
sampler.Unbind(0);
sampler.Shutdown();
}
```
## 相关文档

View File

@@ -0,0 +1,29 @@
# OpenGLSampler::Shutdown
```cpp
void Shutdown() override;
```
关闭采样器。释放 OpenGL 采样器对象,调用 `glDeleteSamplers` 删除采样器并重置 ID 为 0。
**参数:**
**返回:**
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
OpenGLSampler sampler;
if (sampler.Initialize(desc)) {
sampler.Bind(0);
sampler.Shutdown();
}
```
## 相关文档
- [OpenGLSampler 总览](sampler.md) - 返回类总览

View File

@@ -4,10 +4,14 @@
void Unbind(unsigned int unit);
```
解绑采样器。
解绑采样器。将指定纹理单元的采样器绑定解除,实际调用 `glBindSampler(unit, 0)`
**参数:**
- `unit` - 纹理单元编号
- `unit` - 纹理单元编号,通常为 0-15
**返回:**
**线程安全:**
**复杂度:** O(1)