Update API documentation and remove obsolete plan files

This commit is contained in:
2026-03-21 15:55:04 +08:00
parent 7a6cd412c8
commit 629455df07
75 changed files with 1075 additions and 1816 deletions

View File

@@ -0,0 +1,34 @@
# OpenGLShader::SetMat2
设置 2x2 矩阵 uniform 变量。
```cpp
void SetMat2(const char* name, const float* value);
```
通过名称查找并设置着色器中的 2x2 变换矩阵 uniform 变量。矩阵按列主序存储。
**参数:**
- `name` - uniform 变量名称
- `value` - 指向 4 个 float 元素的数组指针(列主序排列)
**返回:**
**线程安全:** ❌(需要在渲染线程调用)
**示例:**
```cpp
// 设置 2x2 旋转矩阵
float rotation[4] = {
cos(angle), sin(angle), // 第一列
-sin(angle), cos(angle) // 第二列
};
shader->SetMat2("u_rotation", rotation);
```
## 相关文档
- [OpenGLShader 总览](shader.md) - 返回类总览
- [SetMat3](set-mat3.md) - 设置 3x3 矩阵
- [SetMat4](../../shader/set-mat4.md) - 设置 4x4 矩阵

View File

@@ -0,0 +1,35 @@
# OpenGLShader::SetMat3
设置 3x3 矩阵 uniform 变量。
```cpp
void SetMat3(const char* name, const float* value);
```
通过名称查找并设置着色器中的 3x3 变换矩阵 uniform 变量。矩阵按列主序存储。常见用途包括设置法线矩阵、模型矩阵的 3x3 部分等。
**参数:**
- `name` - uniform 变量名称
- `value` - 指向 9 个 float 元素的数组指针(列主序排列)
**返回:**
**线程安全:** ❌(需要在渲染线程调用)
**示例:**
```cpp
// 设置 3x3 法线矩阵
float normalMatrix[9] = {
1.0f, 0.0f, 0.0f, // 第一列
0.0f, 1.0f, 0.0f, // 第二列
0.0f, 0.0f, 1.0f // 第三列
};
shader->SetMat3("u_normalMatrix", normalMatrix);
```
## 相关文档
- [OpenGLShader 总览](shader.md) - 返回类总览
- [SetMat2](set-mat2.md) - 设置 2x2 矩阵
- [SetMat4](../../shader/set-mat4.md) - 设置 4x4 矩阵

View File

@@ -0,0 +1,44 @@
# OpenGLShader::SetMat4Array
设置 4x4 矩阵数组 uniform 变量。
```cpp
void SetMat4Array(const char* name, const float* values, unsigned int count);
```
通过名称查找并设置着色器中的 4x4 矩阵数组 uniform 变量。矩阵按列主序存储。
**参数:**
- `name` - uniform 变量名称
- `values` - 指向 `count * 16` 个 float 元素的数组指针(列主序排列)
- `count` - 矩阵数量
**返回:**
**线程安全:** ❌(需要在渲染线程调用)
**示例:**
```cpp
// 设置多个变换矩阵(例如骨骼动画)
const unsigned int boneCount = 4;
float boneMatrices[4 * 16] = {
// 第一个矩阵
1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f,
// 第二个矩阵
0.5f, 0.0f, 0.0f, 0.0f,
0.0f, 0.5f, 0.0f, 0.0f,
0.0f, 0.0f, 0.5f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f,
// ...更多矩阵
};
shader->SetMat4Array("u_boneMatrices", boneMatrices, boneCount);
```
## 相关文档
- [OpenGLShader 总览](shader.md) - 返回类总览
- [SetMat4 (single)](../../shader/set-mat4.md) - 设置单个 4x4 矩阵

View File

@@ -0,0 +1,35 @@
# OpenGLShader::SetVec3
设置三维向量 uniform 变量(数组重载版本)。
```cpp
void SetVec3(const char* name, const float* values);
```
通过名称查找并设置着色器中的三维向量 uniform 变量,使用浮点数数组作为输入。
**参数:**
- `name` - uniform 变量名称
- `values` - 指向 3 个 float 元素的数组指针
**返回:**
**线程安全:** ❌(需要在渲染线程调用)
**示例:**
```cpp
// 设置光照方向
float lightDir[3] = { 0.5f, 1.0f, 0.3f };
shader->SetVec3("u_lightDir", lightDir);
// 设置法线
float normal[3] = { 0.0f, 1.0f, 0.0f };
shader->SetVec3("u_normal", normal);
```
## 相关文档
- [OpenGLShader 总览](shader.md) - 返回类总览
- [SetVec3 (xyz)](../../shader/set-vec3.md) - xyz分量版本
- [SetVec4 (float*)](set-vec4-array.md) - 四维向量数组版本

View File

@@ -0,0 +1,35 @@
# OpenGLShader::SetVec4
设置四维向量 uniform 变量(数组重载版本)。
```cpp
void SetVec4(const char* name, const float* values);
```
通过名称查找并设置着色器中的四维向量 uniform 变量,使用浮点数数组作为输入。
**参数:**
- `name` - uniform 变量名称
- `values` - 指向 4 个 float 元素的数组指针
**返回:**
**线程安全:** ❌(需要在渲染线程调用)
**示例:**
```cpp
// 设置颜色
float color[4] = { 1.0f, 0.5f, 0.2f, 1.0f };
shader->SetVec4("u_color", color);
// 设置齐次坐标
float position[4] = { 10.0f, 20.0f, 30.0f, 1.0f };
shader->SetVec4("u_position", position);
```
## 相关文档
- [OpenGLShader 总览](shader.md) - 返回类总览
- [SetVec4 (xyzw)](../../shader/set-vec4.md) - xyzw分量版本
- [SetVec3 (float*)](set-vec3-array.md) - 三维向量数组版本

View File

@@ -6,6 +6,8 @@
## 公共方法
### 编译方法
| 方法 | 描述 |
|------|------|
| [`CompileFromFile`](compile-from-file-vs-fs.md) | 从文件编译顶点+片段着色器 |
@@ -13,16 +15,36 @@
| [`Compile`](compile-type.md) | 从源码编译单着色器 |
| [`CompileCompute`](compile-compute.md) | 编译计算着色器 |
| [`Shutdown`](../../shader/shutdown.md) | 关闭着色器 |
### 绑定方法
| 方法 | 描述 |
|------|------|
| [`Use`](use.md) | 使用着色器 |
| [`Bind`](../../shader/bind.md) | 绑定着色器 |
| [`Unbind`](../../shader/unbind.md) | 解绑着色器 |
### Uniform 设置方法
| 方法 | 描述 |
|------|------|
| [`SetInt`](../../shader/set-int.md) | 设置整数 uniform |
| [`SetIntArray`](set-int-array.md) | 设置整数数组 uniform |
| [`SetFloat`](../../shader/set-float.md) | 设置浮点数 uniform |
| [`SetFloatArray`](set-float-array.md) | 设置浮点数数组 uniform |
| [`SetVec3`](../../shader/set-vec3.md) | 设置 vec3 uniform |
| [`SetVec4`](../../shader/set-vec4.md) | 设置 vec4 uniform |
| [`SetVec3`](../../shader/set-vec3.md) | 设置 vec3 uniform (xyz分量) |
| [`SetVec3`](set-vec3-array.md) | 设置 vec3 uniform (数组) |
| [`SetVec4`](../../shader/set-vec4.md) | 设置 vec4 uniform (xyzw分量) |
| [`SetVec4`](set-vec4-array.md) | 设置 vec4 uniform (数组) |
| [`SetMat2`](set-mat2.md) | 设置 mat2 uniform |
| [`SetMat3`](set-mat3.md) | 设置 mat3 uniform |
| [`SetMat4`](../../shader/set-mat4.md) | 设置 mat4 uniform |
| [`SetMat4Array`](set-mat4-array.md) | 设置 mat4 数组 uniform |
### 查询方法
| 方法 | 描述 |
|------|------|
| [`GetUniformLocation`](get-uniform-location.md) | 获取 uniform 位置 |
| [`GetID`](get-id.md) | 获取着色器 ID |
| [`GetNativeHandle`](../../buffer/get-native-handle.md) | 获取原生句柄 |