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

@@ -58,7 +58,7 @@ using namespace XCEngine::Math;
void MatrixExample() {
Matrix4 mat = Matrix4::TRS(
Vector3(1.0f, 2.0f, 3.0f),
Quaternion::FromEuler(0.0f, 90.0f, 0.0f),
Quaternion::FromEulerAngles(0.0f, 90.0f, 0.0f),
Vector3(1.5f, 1.5f, 1.5f)
);

View File

@@ -65,5 +65,5 @@ struct Rect {
## 相关文档
- [Math 模块总览](../math.md) - 返回 Rect 模块总览
- [RectInt](rectint.md) - 整数矩形版本
- [Viewport](viewport.md) - 渲染视口
- [RectInt](../rectint/rectint.md) - 整数矩形版本
- [Viewport](../viewport/viewport.md) - 渲染视口

View File

@@ -76,6 +76,6 @@ int main() {
## 相关文档
- [`RectInt`](rectint.md) - 整数矩形
- [`Viewport`](viewport.md) - 视口
- [`RectInt`](../rectint/rectint.md) - 整数矩形
- [`Viewport`](../viewport/viewport.md) - 视口
- [`Vector2`](../vector2/vector2.md) - 二维向量

View File

@@ -1,24 +0,0 @@
# RectInt::Contains
```cpp
bool Contains(int32_t px, int32_t py) const
```
检测整数坐标点是否在矩形内。
**参数:**
- `px` - 点的 x 坐标
- `py` - 点的 y 坐标
**返回:** `bool` - 点在矩形内(包含边界)返回 true
**复杂度:** O(1)
**示例:**
```cpp
RectInt rect(0, 0, 1920, 1080);
if (rect.Contains(pixelX, pixelY)) {
// 像素在矩形内
}
```

View File

@@ -1,18 +0,0 @@
# RectInt::GetBottom
```cpp
int32_t GetBottom() const
```
获取矩形下边界。
**返回:** `int32_t` - 下边界坐标 (y + height)
**复杂度:** O(1)
**示例:**
```cpp
RectInt rect(10, 20, 100, 50);
int32_t bottom = rect.GetBottom(); // 70
```

View File

@@ -1,18 +0,0 @@
# RectInt::GetCenter
```cpp
Vector2 GetCenter() const
```
获取矩形中心点(转换为浮点)。
**返回:** `Vector2` - 中心点坐标
**复杂度:** O(1)
**示例:**
```cpp
RectInt rect(10, 20, 100, 50);
Vector2 center = rect.GetCenter(); // (60.0f, 45.0f)
```

View File

@@ -1,18 +0,0 @@
# RectInt::GetLeft
```cpp
int32_t GetLeft() const
```
获取矩形左边界。
**返回:** `int32_t` - 左边界坐标 (x)
**复杂度:** O(1)
**示例:**
```cpp
RectInt rect(10, 20, 100, 50);
int32_t left = rect.GetLeft(); // 10
```

View File

@@ -1,18 +0,0 @@
# RectInt::GetPosition
```cpp
Vector2 GetPosition() const
```
获取矩形左上角位置(转换为浮点)。
**返回:** `Vector2` - 位置向量
**复杂度:** O(1)
**示例:**
```cpp
RectInt rect(10, 20, 100, 50);
Vector2 pos = rect.GetPosition(); // (10.0f, 20.0f)
```

View File

@@ -1,18 +0,0 @@
# RectInt::GetRight
```cpp
int32_t GetRight() const
```
获取矩形右边界。
**返回:** `int32_t` - 右边界坐标 (x + width)
**复杂度:** O(1)
**示例:**
```cpp
RectInt rect(10, 20, 100, 50);
int32_t right = rect.GetRight(); // 110
```

View File

@@ -1,18 +0,0 @@
# RectInt::GetSize
```cpp
Vector2 GetSize() const
```
获取矩形尺寸(转换为浮点)。
**返回:** `Vector2` - 尺寸向量
**复杂度:** O(1)
**示例:**
```cpp
RectInt rect(10, 20, 100, 50);
Vector2 size = rect.GetSize(); // (100.0f, 50.0f)
```

View File

@@ -1,18 +0,0 @@
# RectInt::GetTop
```cpp
int32_t GetTop() const
```
获取矩形上边界。
**返回:** `int32_t` - 上边界坐标 (y)
**复杂度:** O(1)
**示例:**
```cpp
RectInt rect(10, 20, 100, 50);
int32_t top = rect.GetTop(); // 20
```

View File

@@ -1,24 +0,0 @@
# RectInt::Intersects
```cpp
bool Intersects(const RectInt& other) const
```
检测两整数矩形是否相交。
**参数:**
- `other` - 另一个整数矩形
**返回:** `bool` - 两矩形相交返回 true
**复杂度:** O(1)
**示例:**
```cpp
RectInt rectA(0, 0, 100, 100);
RectInt rectB(50, 50, 100, 100);
if (rectA.Intersects(rectB)) {
// 两矩形相交
}
```

View File

@@ -1,53 +0,0 @@
# RectInt
整数矩形结构体,用于像素级 2D 区域表示。
**头文件:** `#include <XCEngine/Math/Rect.h>`
**命名空间:** `XCEngine::Math`
## 结构体定义
```cpp
struct RectInt {
int32_t x = 0;
int32_t y = 0;
int32_t width = 0;
int32_t height = 0;
RectInt() = default;
RectInt(int32_t x, int32_t y, int32_t w, int32_t h);
};
```
## 构造函数
| 方法 | 描述 |
|------|------|
| `RectInt()` | 默认构造 |
| `RectInt(x, y, w, h)` | 从整数坐标和尺寸构造 |
## 边界访问
| 方法 | 返回值 | 描述 |
|------|--------|------|
| [GetLeft()](rectint-getleft.md) | `int32_t` | 左边界 |
| [GetRight()](rectint-getright.md) | `int32_t` | 右边界 |
| [GetTop()](rectint-gettop.md) | `int32_t` | 上边界 |
| [GetBottom()](rectint-getbottom.md) | `int32_t` | 下边界 |
| [GetPosition()](rectint-getposition.md) | `Vector2` | 位置(转换为浮点) |
| [GetSize()](rectint-getsize.md) | `Vector2` | 尺寸(转换为浮点) |
| [GetCenter()](rectint-getcenter.md) | `Vector2` | 中心点 |
## 检测方法
| 方法 | 返回值 | 描述 |
|------|--------|------|
| [Contains(px, py)](rectint-contains.md) | `bool` | 整数坐标点检测 |
| [Intersects(other)](rectint-intersects.md) | `bool` | 与另一矩形相交 |
## 相关文档
- [Math 模块总览](../math.md) - 返回 Rect 模块总览
- [Rect](rect-overview.md) - 浮点矩形版本
- [Viewport](viewport.md) - 渲染视口

View File

@@ -1,18 +0,0 @@
# Viewport::GetAspectRatio
```cpp
float GetAspectRatio() const
```
获取视口宽高比。
**返回:** `float` - 宽高比 (width / height)height 为 0 时返回 0.0f
**复杂度:** O(1)
**示例:**
```cpp
Viewport viewport(0, 0, 1920, 1080);
float aspect = viewport.GetAspectRatio(); // 1.777... (16:9)
```

View File

@@ -1,18 +0,0 @@
# Viewport::GetRect
```cpp
Rect GetRect() const
```
将视口转换为 Rect。
**返回:** `Rect` - 对应的矩形 (x, y, width, height),不包含深度范围
**复杂度:** O(1)
**示例:**
```cpp
Viewport viewport(0, 0, 1920, 1080, 0.0f, 1.0f);
Rect rect = viewport.GetRect(); // (0, 0, 1920, 1080)
```

View File

@@ -1,45 +0,0 @@
# Viewport
渲染视口结构体,用于屏幕到归一化坐标的映射。
**头文件:** `#include <XCEngine/Math/Rect.h>`
**命名空间:** `XCEngine::Math`
## 结构体定义
```cpp
struct Viewport {
float x = 0.0f;
float y = 0.0f;
float width = 0.0f;
float height = 0.0f;
float minDepth = 0.0f;
float maxDepth = 1.0f;
Viewport() = default;
Viewport(float x, float y, float w, float h);
Viewport(float x, float y, float w, float h, float minD, float maxD);
};
```
## 构造函数
| 方法 | 描述 |
|------|------|
| `Viewport()` | 默认构造 |
| `Viewport(x, y, w, h)` | 2D 视口 |
| `Viewport(x, y, w, h, minD, maxD)` | 带深度范围的 3D 视口 |
## 方法
| 方法 | 返回值 | 描述 |
|------|--------|------|
| [GetAspectRatio()](viewport-getaspectratio.md) | `float` | 宽高比 (width / height) |
| [GetRect()](viewport-getrect.md) | `Rect` | 转换为 Rect |
## 相关文档
- [Math 模块总览](../math.md) - 返回 Math 模块总览
- [Rect](rect-overview.md) - 浮点矩形
- [RectInt](rectint.md) - 整数矩形

View File

@@ -1,47 +1,24 @@
# RectInt::Contains
```cpp
bool Contains(int32_t px, int32_t py) const;
bool Contains(int32_t px, int32_t py) const
```
判断整数坐标点是否在矩形内
矩形使用左上位坐标系内部定义为x >= left && x < right && y >= top && y < bottom。即左边界和上边界在内部右边界和下边界在外部。
检测整数坐标点是否在矩形内。
**参数:**
- `px` - 点的 x 坐标
- `py` - 点的 y 坐标
**返回:** 点在矩形内部返回 true否则返回 false
**线程安全:**
**返回:** `bool` - 点在矩形内(包含边界)返回 true
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(0, 0, 1920, 1080);
if (rect.Contains(960, 540)) {
std::cout << "Point (960, 540) is inside\n";
}
if (!rect.Contains(2000, 1000)) {
std::cout << "Point (2000, 1000) is outside\n";
}
return 0;
RectInt rect(0, 0, 1920, 1080);
if (rect.Contains(pixelX, pixelY)) {
// 像素在矩形内
}
```
## 相关文档
- [`RectInt::Intersects`](intersects.md) - 判断是否相交
- [RectInt 总览](rectint.md)

View File

@@ -1,36 +1,18 @@
# RectInt::GetBottom
```cpp
int32_t GetBottom() const;
int32_t GetBottom() const
```
获取矩形下边界 y 坐标
获取矩形下边界。
**返回:** 矩形下边界 y 坐标(等于 y + height
**线程安全:**
**返回:** `int32_t` - 下边界坐标 (y + height)
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
int32_t bottom = rect.GetBottom();
std::cout << "Bottom: " << bottom << "\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
int32_t bottom = rect.GetBottom(); // 70
```
## 相关文档
- [`RectInt::GetLeft`](getleft.md) - 获取左边界
- [`RectInt::GetRight`](getright.md) - 获取右边界
- [`RectInt::GetTop`](gettop.md) - 获取上边界
- [RectInt 总览](rectint.md)

View File

@@ -1,35 +1,18 @@
# RectInt::GetCenter
```cpp
Vector2 GetCenter() const;
Vector2 GetCenter() const
```
获取矩形中心点坐标
获取矩形中心点(转换为浮点)
**返回:** 表示矩形中心点的 Vector2转换为浮点
**线程安全:**
**返回:** `Vector2` - 中心点坐标
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
Vector2 center = rect.GetCenter();
std::cout << "Center: (" << center.x << ", " << center.y << ")\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
Vector2 center = rect.GetCenter(); // (60.0f, 45.0f)
```
## 相关文档
- [`RectInt::GetPosition`](getposition.md) - 获取位置
- [`RectInt::GetSize`](getsize.md) - 获取尺寸
- [RectInt 总览](rectint.md)

View File

@@ -1,36 +1,18 @@
# RectInt::GetLeft
```cpp
int32_t GetLeft() const;
int32_t GetLeft() const
```
获取矩形左边界 x 坐标
获取矩形左边界。
**返回:** 矩形左边界 x 坐标(等于 x 成员变量)
**线程安全:**
**返回:** `int32_t` - 左边界坐标 (x)
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
int32_t left = rect.GetLeft();
std::cout << "Left: " << left << "\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
int32_t left = rect.GetLeft(); // 10
```
## 相关文档
- [`RectInt::GetRight`](getright.md) - 获取右边界
- [`RectInt::GetTop`](gettop.md) - 获取上边界
- [`RectInt::GetBottom`](getbottom.md) - 获取下边界
- [RectInt 总览](rectint.md)

View File

@@ -1,35 +1,18 @@
# RectInt::GetPosition
```cpp
Vector2 GetPosition() const;
Vector2 GetPosition() const
```
获取矩形位置x, y 坐标)。
获取矩形左上角位置(转换为浮点)。
**返回:** 表示矩形位置的 Vector2转换为浮点
**线程安全:**
**返回:** `Vector2` - 位置向量
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
Vector2 pos = rect.GetPosition();
std::cout << "Position: (" << pos.x << ", " << pos.y << ")\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
Vector2 pos = rect.GetPosition(); // (10.0f, 20.0f)
```
## 相关文档
- [`RectInt::GetSize`](getsize.md) - 获取尺寸
- [`RectInt::GetCenter`](getcenter.md) - 获取中心点
- [RectInt 总览](rectint.md)

View File

@@ -1,36 +1,18 @@
# RectInt::GetRight
```cpp
int32_t GetRight() const;
int32_t GetRight() const
```
获取矩形右边界 x 坐标
获取矩形右边界。
**返回:** 矩形右边界 x 坐标(等于 x + width
**线程安全:**
**返回:** `int32_t` - 右边界坐标 (x + width)
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
int32_t right = rect.GetRight();
std::cout << "Right: " << right << "\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
int32_t right = rect.GetRight(); // 110
```
## 相关文档
- [`RectInt::GetLeft`](getleft.md) - 获取左边界
- [`RectInt::GetTop`](gettop.md) - 获取上边界
- [`RectInt::GetBottom`](getbottom.md) - 获取下边界
- [RectInt 总览](rectint.md)

View File

@@ -1,35 +1,18 @@
# RectInt::GetSize
```cpp
Vector2 GetSize() const;
Vector2 GetSize() const
```
获取矩形尺寸(width, height)。
获取矩形尺寸(转换为浮点)。
**返回:** 表示矩形尺寸的 Vector2转换为浮点
**线程安全:**
**返回:** `Vector2` - 尺寸向量
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
Vector2 size = rect.GetSize();
std::cout << "Size: (" << size.x << ", " << size.y << ")\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
Vector2 size = rect.GetSize(); // (100.0f, 50.0f)
```
## 相关文档
- [`RectInt::GetPosition`](getposition.md) - 获取位置
- [`RectInt::GetCenter`](getcenter.md) - 获取中心点
- [RectInt 总览](rectint.md)

View File

@@ -1,36 +1,18 @@
# RectInt::GetTop
```cpp
int32_t GetTop() const;
int32_t GetTop() const
```
获取矩形上边界 y 坐标
获取矩形上边界。
**返回:** 矩形上边界 y 坐标(等于 y 成员变量)
**线程安全:**
**返回:** `int32_t` - 上边界坐标 (y)
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rect(10, 20, 100, 50);
int32_t top = rect.GetTop();
std::cout << "Top: " << top << "\n";
return 0;
}
RectInt rect(10, 20, 100, 50);
int32_t top = rect.GetTop(); // 20
```
## 相关文档
- [`RectInt::GetLeft`](getleft.md) - 获取左边界
- [`RectInt::GetRight`](getright.md) - 获取右边界
- [`RectInt::GetBottom`](getbottom.md) - 获取下边界
- [RectInt 总览](rectint.md)

View File

@@ -1,48 +1,24 @@
# RectInt::Intersects
```cpp
bool Intersects(const RectInt& other) const;
bool Intersects(const RectInt& other) const
```
判断此矩形是否与另一矩形相交。
使用 AABB轴对齐包围盒碰撞检测算法。如果两个矩形在 x 轴和 y 轴上都有重叠,则返回 true。
检测两整数矩形是否相交。
**参数:**
- `other` - 另一个矩形
- `other` - 另一个整数矩形
**返回:** 两矩形相交返回 true否则返回 false
**线程安全:**
**返回:** `bool` - 两矩形相交返回 true
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
RectInt rectA(0, 0, 100, 100);
RectInt rectB(50, 50, 100, 100);
if (rectA.Intersects(rectB)) {
std::cout << "Rects intersect\n";
}
RectInt rectC(200, 200, 50, 50);
if (!rectA.Intersects(rectC)) {
std::cout << "Rects do not intersect\n";
}
return 0;
RectInt rectA(0, 0, 100, 100);
RectInt rectB(50, 50, 100, 100);
if (rectA.Intersects(rectB)) {
// 两矩形相交
}
```
## 相关文档
- [`RectInt::Contains`](contains.md) - 判断点是否在矩形内
- [RectInt 总览](rectint.md)

View File

@@ -1,63 +1,53 @@
# RectInt
**命名空间**: `XCEngine::Math`
整数矩形结构体,用于像素级 2D 区域表示。
**类型**: `struct`
**头文件:** `#include <XCEngine/Math/Rect.h>`
**头文件**: `XCEngine/Math/Rect.h`
**命名空间:** `XCEngine::Math`
**描述**: 二维整数矩形,用于表示像素级 2D 区域
## 结构体定义
## 概述
```cpp
struct RectInt {
int32_t x = 0;
int32_t y = 0;
int32_t width = 0;
int32_t height = 0;
RectInt 结构体表示一个二维整数矩形,由整数位置 `(x, y)` 和尺寸 `(width, height)` 组成。与 Rect 不同,它使用 `int32_t` 类型,适合像素级操作和坐标计算。
RectInt() = default;
RectInt(int32_t x, int32_t y, int32_t w, int32_t h);
};
```
## 公共方法
## 构造函数
| 方法 | 描述 |
|------|------|
| [`GetLeft`](getleft.md) | 获取矩形左边界 |
| [`GetRight`](getright.md) | 获取矩形右边界 |
| [`GetTop`](gettop.md) | 获取矩形上边界 |
| [`GetBottom`](getbottom.md) | 获取矩形下边界 |
| [`GetPosition`](getposition.md) | 获取矩形位置 |
| [`GetSize`](getsize.md) | 获取矩形尺寸 |
| [`GetCenter`](getcenter.md) | 获取矩形中心点 |
| [`Contains`](contains.md) | 判断点是否在矩形内 |
| [`Intersects`](intersects.md) | 判断是否与另一矩形相交 |
| `RectInt()` | 默认构造 |
| `RectInt(x, y, w, h)` | 从整数坐标和尺寸构造 |
## 使用示例
## 边界访问
```cpp
#include "XCEngine/Math/Rect.h"
#include "XCEngine/Math/Vector2.h"
#include <iostream>
| 方法 | 返回值 | 描述 |
|------|--------|------|
| [GetLeft()](rectint-getleft.md) | `int32_t` | 左边界 |
| [GetRight()](rectint-getright.md) | `int32_t` | 右边界 |
| [GetTop()](rectint-gettop.md) | `int32_t` | 上边界 |
| [GetBottom()](rectint-getbottom.md) | `int32_t` | 下边界 |
| [GetPosition()](rectint-getposition.md) | `Vector2` | 位置(转换为浮点) |
| [GetSize()](rectint-getsize.md) | `Vector2` | 尺寸(转换为浮点) |
| [GetCenter()](rectint-getcenter.md) | `Vector2` | 中心点 |
using namespace XCEngine::Math;
## 检测方法
int main() {
RectInt rect(10, 20, 100, 50);
std::cout << "Position: (" << rect.x << ", " << rect.y << ")\n";
std::cout << "Size: " << rect.width << " x " << rect.height << "\n";
std::cout << "Left: " << rect.GetLeft() << ", Right: " << rect.GetRight() << "\n";
std::cout << "Top: " << rect.GetTop() << ", Bottom: " << rect.GetBottom() << "\n";
if (rect.Contains(50, 30)) {
std::cout << "Point (50, 30) is inside rect\n";
}
RectInt other(60, 40, 100, 50);
if (rect.Intersects(other)) {
std::cout << "Rects intersect\n";
}
return 0;
}
```
| 方法 | 返回值 | 描述 |
|------|--------|------|
| [Contains(px, py)](rectint-contains.md) | `bool` | 整数坐标点检测 |
| [Intersects(other)](rectint-intersects.md) | `bool` | 与另一矩形相交 |
## 相关文档
- [`Rect`](../rect/rect.md) - 浮点矩形
- [`Viewport`](../rect/viewport.md) - 视口
- [`Vector2`](../vector2/vector2.md) - 二维向量
- [Math 模块总览](../math.md) - 返回 Rect 模块总览
- [Rect](rect-overview.md) - 浮点矩形版本
- [Viewport](viewport.md) - 渲染视口

View File

@@ -0,0 +1,40 @@
# Transform::Space
**命名空间**: `XCEngine::Math`
**类型**: `enum class`
**头文件**: `XCEngine/Math/Transform.h`
## 概述
`Space` 枚举用于指定变换操作的参考空间。
## 枚举值
| 枚举值 | 数值 | 描述 |
|--------|------|------|
| `Self` | `0` | 相对于自身空间进行变换 |
| `World` | `1` | 相对于世界空间进行变换 |
## 使用示例
```cpp
#include "XCEngine/Math/Transform.h"
#include "XCEngine/Math/Vector3.h"
using namespace XCEngine::Math;
Transform transform;
transform.position = Vector3(10.0f, 0.0f, 0.0f);
// 在自身空间旋转
// transform.Rotate(Vector3::Up(), 45.0f * DEG_TO_RAD, Space::Self);
// 在世界空间旋转
// transform.Rotate(Vector3::Up(), 45.0f * DEG_TO_RAD, Space::World);
```
## 相关文档
- [Transform 总览](transform.md) - Transform 类总览

View File

@@ -34,6 +34,12 @@
| [`InverseTransformPoint`](inverse-transform-point.md) | 逆变换一个点 |
| [`InverseTransformDirection`](inverse-transform-direction.md) | 逆变换一个方向 |
## 枚举
| 枚举 | 描述 |
|------|------|
| [`Space`](space.md) | 变换参考空间Self 或 World |
## 使用示例
```cpp

View File

@@ -0,0 +1,29 @@
# Vector2::operator+=
```cpp
Vector2& operator+=(const Vector2& other)
```
向量加法赋值,将 `other` 的分量加到当前向量。
**参数:**
- `other` - 要加的向量
**返回:** `Vector2&` - 引用到修改后的当前向量
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector2 v(1.0f, 2.0f);
v += Vector2(3.0f, 4.0f); // v = (4.0f, 6.0f)
```
## 相关文档
- [Vector2 总览](vector2.md)
- [`operator+`](operator-add.md) - 加法
- [`operator-=`](operator-sub-assign.md) - 减法赋值

View File

@@ -0,0 +1,30 @@
# Vector2::operator+
```cpp
Vector2 operator+(const Vector2& other) const
```
向量加法,将当前向量与另一个向量相加。
**参数:**
- `other` - 要相加的向量
**返回:** `Vector2` - 相加结果向量
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector2 a(1.0f, 2.0f);
Vector2 b(3.0f, 4.0f);
Vector2 c = a + b; // (4.0f, 6.0f)
```
## 相关文档
- [Vector2 总览](vector2.md)
- [`operator-`](operator-sub.md) - 减法
- [`operator+=`](operator-add-assign.md) - 加法赋值

View File

@@ -0,0 +1,29 @@
# Vector2::operator/=
```cpp
Vector2& operator/=(float scalar)
```
向量除法赋值,将当前向量除以标量。
**参数:**
- `scalar` - 标量值(不能为零)
**返回:** `Vector2&` - 引用到修改后的当前向量
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector2 v(4.0f, 6.0f);
v /= 2.0f; // v = (2.0f, 3.0f)
```
## 相关文档
- [Vector2 总览](vector2.md)
- [`operator/`](operator-div.md) - 除法
- [`operator*=`](operator-mul-assign.md) - 乘法赋值

View File

@@ -0,0 +1,29 @@
# Vector2::operator/
```cpp
Vector2 operator/(float scalar) const
```
向量数除,将向量除以标量。
**参数:**
- `scalar` - 标量值(不能为零)
**返回:** `Vector2` - 缩放后的向量
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector2 v(4.0f, 6.0f);
Vector2 result = v / 2.0f; // (2.0f, 3.0f)
```
## 相关文档
- [Vector2 总览](vector2.md)
- [`operator*`](operator-mul.md) - 乘法
- [`operator/=`](operator-div-assign.md) - 除法赋值

View File

@@ -0,0 +1,29 @@
# Vector2::operator==
```cpp
bool operator==(const Vector2& other) const
```
判断两个向量是否相等。使用 EPSILON 进行浮点比较。
**参数:**
- `other` - 要比较的向量
**返回:** `bool` - 如果所有分量差的绝对值都小于 EPSILON 则返回 true
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector2 a(1.0f, 2.0f);
Vector2 b(1.0f, 2.0f);
bool equal = (a == b); // true
```
## 相关文档
- [Vector2 总览](vector2.md)
- [`operator!=`](operator-neq.md) - 不等比较

View File

@@ -0,0 +1,29 @@
# Vector2::operator*=
```cpp
Vector2& operator*=(float scalar)
```
向量乘法赋值,将当前向量乘以标量。
**参数:**
- `scalar` - 标量值
**返回:** `Vector2&` - 引用到修改后的当前向量
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector2 v(2.0f, 3.0f);
v *= 2.0f; // v = (4.0f, 6.0f)
```
## 相关文档
- [Vector2 总览](vector2.md)
- [`operator*`](operator-mul.md) - 乘法
- [`operator/=`](operator-div-assign.md) - 除法赋值

View File

@@ -0,0 +1,29 @@
# Vector2::operator*
```cpp
Vector2 operator*(float scalar) const
```
向量数乘,将向量与标量相乘。
**参数:**
- `scalar` - 标量值
**返回:** `Vector2` - 缩放后的向量
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector2 v(2.0f, 3.0f);
Vector2 scaled = v * 2.0f; // (4.0f, 6.0f)
```
## 相关文档
- [Vector2 总览](vector2.md)
- [`operator/`](operator-div.md) - 除法
- [`operator*=`](operator-mul-assign.md) - 乘法赋值

View File

@@ -0,0 +1,29 @@
# Vector2::operator!=
```cpp
bool operator!=(const Vector2& other) const
```
判断两个向量是否不相等。
**参数:**
- `other` - 要比较的向量
**返回:** `bool` - 如果任何分量差的绝对值大于等于 EPSILON 则返回 true
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector2 a(1.0f, 2.0f);
Vector2 b(3.0f, 4.0f);
bool notEqual = (a != b); // true
```
## 相关文档
- [Vector2 总览](vector2.md)
- [`operator==`](operator-eq.md) - 相等比较

View File

@@ -0,0 +1,29 @@
# Vector2::operator-=
```cpp
Vector2& operator-=(const Vector2& other)
```
向量减法赋值,将 `other` 的分量从当前向量减去。
**参数:**
- `other` - 要减的向量
**返回:** `Vector2&` - 引用到修改后的当前向量
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector2 v(5.0f, 8.0f);
v -= Vector2(2.0f, 3.0f); // v = (3.0f, 5.0f)
```
## 相关文档
- [Vector2 总览](vector2.md)
- [`operator-`](operator-sub.md) - 减法
- [`operator+=`](operator-add-assign.md) - 加法赋值

View File

@@ -0,0 +1,30 @@
# Vector2::operator-
```cpp
Vector2 operator-(const Vector2& other) const
```
向量减法,将当前向量减去另一个向量。
**参数:**
- `other` - 要减去的向量
**返回:** `Vector2` - 相减结果向量
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector2 a(5.0f, 8.0f);
Vector2 b(2.0f, 3.0f);
Vector2 c = a - b; // (3.0f, 5.0f)
```
## 相关文档
- [Vector2 总览](vector2.md)
- [`operator+`](operator-add.md) - 加法
- [`operator-=`](operator-sub-assign.md) - 减法赋值

View File

@@ -23,31 +23,30 @@ Vector2 是 XCEngine 中的二维向量结构体,用于表示 2D 空间中的
| 方法 | 描述 |
|------|------|
| [`Zero`](Zero.md) | 返回 (0, 0) 零向量 |
| [`One`](One.md) | 返回 (1, 1) 单位向量 |
| [`Up`](Up.md) | 返回 (0, 1) 上方向 |
| [`Down`](Down.md) | 返回 (0, -1) 下方向 |
| [`Right`](Right.md) | 返回 (1, 0) 右方向 |
| [`Left`](Left.md) | 返回 (-1, 0) 左方向 |
| [`Dot`](Dot.md) | 计算两个向量的点积 |
| [`Cross`](Cross.md) | 计算两个向量的叉积(返回标量) |
| [`Normalize`](Normalize.md) | 归一化向量为单位长度 |
| [`Magnitude`](Magnitude.md) | 计算向量长度 |
| [`SqrMagnitude`](SqrMagnitude.md) | 计算向量长度平方 |
| [`Lerp`](Lerp.md) | 线性插值 |
| [`MoveTowards`](MoveTowards.md) | 朝目标移动 |
| [`Magnitude`](Magnitude.md) | 实例方法,计算当前向量长度 |
| [`SqrMagnitude`](SqrMagnitude.md) | 实例方法,计算当前向量长度平方 |
| [`Normalized`](Normalized.md) | 实例方法,返回归一化副本 |
| [`Zero`](zero.md) | 返回 (0, 0) 零向量 |
| [`One`](one.md) | 返回 (1, 1) 单位向量 |
| [`Up`](up.md) | 返回 (0, 1) 上方向 |
| [`Down`](down.md) | 返回 (0, -1) 下方向 |
| [`Right`](right.md) | 返回 (1, 0) 右方向 |
| [`Left`](left.md) | 返回 (-1, 0) 左方向 |
| [`Dot`](dot.md) | 计算两个向量的点积 |
| [`Cross`](cross.md) | 计算两个向量的叉积(返回标量) |
| [`Normalize`](normalize.md) | 归一化向量为单位长度(静态方法) |
| [`Magnitude`](magnitude.md) | 计算向量长度 |
| [`SqrMagnitude`](sqrmagnitude.md) | 计算向量长度平方 |
| [`Lerp`](lerp.md) | 线性插值 |
| [`MoveTowards`](movetowards.md) | 朝目标移动 |
| [`Normalized`](normalized.md) | 实例方法,返回归一化副本 |
## 运算符
| 运算符 | 描述 |
|--------|------|
| `+`, `-` | 向量加减运算 |
| `*`, `/` | 向量与标量乘除运算 |
| `+=`, `-=`, `*=`, `/=` | 复合赋值运算 |
| `==`, `!=` | 相等性比较(基于 EPSILON 浮点比较) |
| [`+`](operator-add.md), [`-`](operator-sub.md) | 向量加减运算 |
| [`*`](operator-mul.md), [`/`](operator-div.md) | 向量与标量乘除运算 |
| [`*=`](operator-mul-assign.md), [`/=`](operator-div-assign.md) | 复合赋值运算 |
| [`+=`](operator-add-assign.md), [`-=`](operator-sub-assign.md) | 复合赋值运算 |
| [`==`](operator-eq.md), [`!=`](operator-neq.md) | 相等性比较(基于 EPSILON 浮点比较) |
## 使用示例

View File

@@ -0,0 +1,27 @@
# Vector3::Magnitude
```cpp
float Magnitude() const
```
计算向量的长度(模)。
**返回:** `float` - 向量的长度
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector3 v(3.0f, 4.0f, 0.0f);
float mag = v.Magnitude(); // 5.0f
```
## 相关文档
- [Vector3 总览](vector3.md)
- [`SqrMagnitude`](sqrmagnitude.md) - 长度的平方
- [`Normalized`](normalized.md) - 归一化副本
- [`static Magnitude`](magnitude.md) - 静态版本

View File

@@ -0,0 +1,27 @@
# Vector3::Normalized
```cpp
Vector3 Normalized() const
```
返回向量的归一化副本(单位长度为 1 的向量)。不会修改原向量。
**返回:** `Vector3` - 归一化后的向量副本;如果向量长度接近零,则返回零向量
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector3 v(3.0f, 4.0f, 0.0f);
Vector3 normalized = v.Normalized(); // (0.6f, 0.8f, 0.0f)
// v 仍然是 (3.0f, 4.0f, 0.0f)
```
## 相关文档
- [Vector3 总览](vector3.md)
- [`static Normalize`](normalize.md) - 静态版本(会修改原向量)
- [`Magnitude`](magnitude-instance.md) - 向量长度

View File

@@ -0,0 +1,27 @@
# Vector3::SqrMagnitude
```cpp
float SqrMagnitude() const
```
计算向量长度的平方。用于在不计算平方根的情况下比较长度,性能更优。
**返回:** `float` - 向量长度的平方
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector3 v(3.0f, 4.0f, 0.0f);
float sqrMag = v.SqrMagnitude(); // 25.0f
```
## 相关文档
- [Vector3 总览](vector3.md)
- [`Magnitude`](magnitude-instance.md) - 向量长度
- [`Normalized`](normalized.md) - 归一化副本
- [`static SqrMagnitude`](sqrmagnitude.md) - 静态版本

View File

@@ -51,11 +51,20 @@ Vector3 是 XCEngine 中用于表示三维向量的核心类型,支持常见
|--------|------|
| [`+`](operator_add.md), [`-`](operator_sub.md) | 向量加减 |
| [`*`](operator_mul.md), [`/`](operator_div.md) | 向量与标量或分量相乘/相除 |
| [`+=`](operator_add_assign.md), [`-=`](operator_sub_assign.md) | 复合赋值运算符 |
| [`*=`](operator_mul_assign.md), [`/=`](operator_div_assign.md) | 复合赋值运算符 |
| [`[]`](./operator_index.md) | 下标访问 x, y, z 分量 |
| [`==`](operator_eq.md), [`!=`](operator_neq.md) | 相等性比较 |
| [`* (Quaternion)`](quaternion-multiply.md) | 用四元数旋转向量 |
## 实例方法
| 方法 | 描述 |
|------|------|
| [`Magnitude()`](magnitude-instance.md) | 计算向量长度 |
| [`SqrMagnitude()`](sqrmagnitude-instance.md) | 计算向量长度的平方 |
| [`Normalized()`](normalized-instance.md) | 返回归一化副本 |
## 使用示例
```cpp

View File

@@ -0,0 +1,26 @@
# Vector4::operator-
```cpp
Vector4 operator-() const
```
一元负号运算符,返回当前向量的负向量。
**返回:** `Vector4` - 每个分量取负的新向量
**线程安全:**
**复杂度:** O(1)
**示例:**
```cpp
Vector4 v(1.0f, 2.0f, 3.0f, 4.0f);
Vector4 neg = -v; // (-1.0f, -2.0f, -3.0f, -4.0f)
```
## 相关文档
- [Vector4 总览](vector4.md)
- [`operator+`](operator-add.md) - 加法
- [`operator-`](operator-sub.md) - 二元减法

View File

@@ -1,34 +1,18 @@
# Viewport::GetAspectRatio
```cpp
float GetAspectRatio() const;
float GetAspectRatio() const
```
获取视口宽高比。
**返回:** 宽高比 (width / height)如果 height 为 0 返回 0.0f
**线程安全:**
**返回:** `float` - 宽高比 (width / height)height 为 0 返回 0.0f
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
Viewport viewport(0.0f, 0.0f, 1920.0f, 1080.0f);
float aspect = viewport.GetAspectRatio();
std::cout << "Aspect Ratio: " << aspect << "\n";
return 0;
}
Viewport viewport(0, 0, 1920, 1080);
float aspect = viewport.GetAspectRatio(); // 1.777... (16:9)
```
## 相关文档
- [`Viewport::GetRect`](getrect.md) - 转换为 Rect
- [Viewport 总览](viewport.md)

View File

@@ -1,34 +1,18 @@
# Viewport::GetRect
```cpp
Rect GetRect() const;
Rect GetRect() const
```
将视口转换为 Rect。
**返回:** 对应的 Rectx, y, width, height,不包含深度范围
**线程安全:**
**返回:** `Rect` - 对应的矩形 (x, y, width, height),不包含深度范围
**复杂度:** O(1)
**示例:**
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
Viewport viewport(0.0f, 0.0f, 1920.0f, 1080.0f, 0.0f, 1.0f);
Rect rect = viewport.GetRect();
std::cout << "Rect: (" << rect.x << ", " << rect.y << ", " << rect.width << ", " << rect.height << ")\n";
return 0;
}
Viewport viewport(0, 0, 1920, 1080, 0.0f, 1.0f);
Rect rect = viewport.GetRect(); // (0, 0, 1920, 1080)
```
## 相关文档
- [`Viewport::GetAspectRatio`](getaspectratio.md) - 获取宽高比
- [Viewport 总览](viewport.md)

View File

@@ -1,49 +1,45 @@
# Viewport
**命名空间**: `XCEngine::Math`
渲染视口结构体,用于屏幕到归一化坐标的映射。
**类型**: `struct`
**头文件:** `#include <XCEngine/Math/Rect.h>`
**头文件**: `XCEngine/Math/Viewport.h`
**命名空间:** `XCEngine::Math`
**描述**: 视口,用于渲染目标区域和坐标映射
## 结构体定义
## 概述
```cpp
struct Viewport {
float x = 0.0f;
float y = 0.0f;
float width = 0.0f;
float height = 0.0f;
float minDepth = 0.0f;
float maxDepth = 1.0f;
Viewport 结构体表示一个渲染视口,除了位置和尺寸外,还包含深度范围 `(minDepth, maxDepth)`。主要用于屏幕到归一化设备坐标NDC的映射以及渲染目标区域的定义。
Viewport() = default;
Viewport(float x, float y, float w, float h);
Viewport(float x, float y, float w, float h, float minD, float maxD);
};
```
## 公共方法
## 构造函数
| 方法 | 描述 |
|------|------|
| [`GetAspectRatio`](getaspectratio.md) | 获取视口宽高比 |
| [`GetRect`](getrect.md) | 转换为 Rect |
| `Viewport()` | 默认构造 |
| `Viewport(x, y, w, h)` | 2D 视口 |
| `Viewport(x, y, w, h, minD, maxD)` | 带深度范围的 3D 视口 |
## 使用示例
## 方法
```cpp
#include "XCEngine/Math/Rect.h"
#include <iostream>
using namespace XCEngine::Math;
int main() {
Viewport viewport(0.0f, 0.0f, 1920.0f, 1080.0f, 0.0f, 1.0f);
std::cout << "Position: (" << viewport.x << ", " << viewport.y << ")\n";
std::cout << "Size: " << viewport.width << " x " << viewport.height << "\n";
std::cout << "Depth: " << viewport.minDepth << " to " << viewport.maxDepth << "\n";
std::cout << "Aspect Ratio: " << viewport.GetAspectRatio() << "\n";
Rect rect = viewport.GetRect();
std::cout << "As Rect: (" << rect.x << ", " << rect.y << ", " << rect.width << ", " << rect.height << ")\n";
return 0;
}
```
| 方法 | 返回值 | 描述 |
|------|--------|------|
| [GetAspectRatio()](viewport-getaspectratio.md) | `float` | 宽高比 (width / height) |
| [GetRect()](viewport-getrect.md) | `Rect` | 转换为 Rect |
## 相关文档
- [`Rect`](../rect/rect.md) - 浮点矩形
- [`RectInt`](../rect/rectint.md) - 整数矩形
- [`Vector2`](../vector2/vector2.md) - 二维向量
- [Math 模块总览](../math.md) - 返回 Math 模块总览
- [Rect](rect-overview.md) - 浮点矩形
- [RectInt](rectint.md) - 整数矩形

View File

@@ -0,0 +1,28 @@
# D3D12CommandList::ClearUnorderedAccessView
```cpp
void ClearUnorderedAccessView(
D3D12_GPU_DESCRIPTOR_HANDLE viewHandle,
D3D12_CPU_DESCRIPTOR_HANDLE resourceHandle,
ID3D12Resource* unorderedAccess,
const float values[4],
uint32_t rectCount = 0,
const D3D12_RECT* rects = nullptr
);
```
清除无序访问视图。
**参数:**
- `viewHandle` - GPU 描述符句柄
- `resourceHandle` - CPU 描述符句柄
- `unorderedAccess` - UAV 资源指针
- `values` - 清除值 [x, y, z, w]
- `rectCount` - 清除矩形数量
- `rects` - 清除矩形数组
**复杂度:** O(n) 其中 n 为 rectCount
## 相关文档
- [D3D12CommandList 总览](command-list.md) - 返回类总览

View File

@@ -21,8 +21,8 @@
| 方法 | 描述 |
|------|------|
| [`D3D12CommandList`](../../../threading/lambdatask/constructor.md) | 构造函数 |
| [`~D3D12CommandList`](../../../threading/readwritelock/destructor.md) | 析构函数 |
| [`D3D12CommandList`](constructor.md) | 构造函数 |
| [`~D3D12CommandList`](destructor.md) | 析构函数 |
| [`Initialize`](initialize.md) | 初始化命令列表 |
| [`Shutdown`](shutdown.md) | 关闭命令列表 |
| [`Reset`](reset.md) | 重置命令列表 |
@@ -51,6 +51,8 @@
| [`SetGraphicsRootDescriptorTable`](set-graphics-root-descriptor-table.md) | 设置图形根描述符表 |
| [`SetGraphicsRootShaderResourceView`](set-graphics-root-shader-resource-view.md) | 设置图形根着色器资源视图 |
| [`SetStencilRef`](set-stencil-ref.md) | 设置模板引用值 |
| [`SetDepthStencilState`](set-depth-stencil-state.md) | 设置深度模板状态 |
| [`SetBlendState`](set-blend-state.md) | 设置混合状态 |
| [`SetBlendFactor`](set-blend-factor.md) | 设置混合因子 |
| [`SetDepthBias`](set-depth-bias.md) | 设置深度偏移 |
| [`Draw`](draw.md) | 绘制 |
@@ -60,6 +62,7 @@
| [`Clear`](clear.md) | 清除 |
| [`ClearRenderTarget`](clear-render-target.md) | 清除渲染目标 |
| [`ClearDepthStencil`](clear-depth-stencil.md) | 清除深度模板 |
| [`ClearUnorderedAccessView`](clear-unordered-access-view.md) | 清除无序访问视图 |
| [`CopyResource`](copy-resource.md) | 复制资源 |
| [`CopyBuffer`](copy-buffer.md) | 复制缓冲区 |
| [`CopyTexture`](copy-texture.md) | 复制纹理 |

View File

@@ -0,0 +1,16 @@
# D3D12CommandList::SetBlendState
```cpp
void SetBlendState(const BlendState& state) override;
```
设置混合状态。
**参数:**
- `state` - 混合状态结构体
**复杂度:** O(1)
## 相关文档
- [D3D12CommandList 总览](command-list.md) - 返回类总览

View File

@@ -0,0 +1,16 @@
# D3D12CommandList::SetDepthStencilState
```cpp
void SetDepthStencilState(const DepthStencilState& state) override;
```
设置深度模板状态。
**参数:**
- `state` - 深度模板状态结构体
**复杂度:** O(1)
## 相关文档
- [D3D12CommandList 总览](command-list.md) - 返回类总览

View File

@@ -74,4 +74,4 @@
## 相关文档
- [../rhi/rhi.md](../rhi.md) - RHI 模块总览
- [OpenGL 后端](../opengl/overview.md)
- [OpenGL 后端](../opengl/opengl.md)

View File

@@ -0,0 +1,27 @@
# D3D12DepthStencilView::D3D12DepthStencilView
## 函数签名
```cpp
D3D12DepthStencilView()
```
## 描述
默认构造函数。创建空的深度模板视图实例,成员变量初始化为零值和空指针。
## 返回值
## 示例
```cpp
D3D12DepthStencilView dsv; // 创建空实例
```
## 相关文档
- [D3D12DepthStencilView](depth-stencil-view.md) - 类总览
- [D3D12DepthStencilView::Initialize](initialize.md) - 初始化方法
- [D3D12DepthStencilView::~D3D12DepthStencilView](destructor.md) - 析构函数

View File

@@ -4,6 +4,8 @@
**类型**: `class`
**头文件**: `XCEngine/RHI/D3D12/D3D12DepthStencilView.h`
**描述**: DirectX 12 深度模板视图的 D3D12 实现,用于渲染管线中的深度/模板测试。
## 概述
@@ -14,8 +16,8 @@
| 方法 | 描述 |
|------|------|
| [`D3D12DepthStencilView()`](initialize.md) | 构造函数 |
| [`~D3D12DepthStencilView()`](initialize.md) | 析构函数 |
| [`D3D12DepthStencilView()`](constructor.md) | 构造函数 |
| [`~D3D12DepthStencilView()`](destructor.md) | 析构函数 |
| [`Initialize`](initialize.md) | 初始化深度模板视图 |
| [`InitializeAt`](initialize-at.md) | 在指定位置初始化深度模板视图 |
| [`Shutdown`](shutdown.md) | 关闭深度模板视图 |

View File

@@ -0,0 +1,34 @@
# D3D12DepthStencilView::~D3D12DepthStencilView
## 函数签名
```cpp
~D3D12DepthStencilView()
```
## 描述
析构函数。自动调用 `Shutdown()` 释放内部资源。
## 返回值
## 注意事项
此析构函数不直接释放 D3D12 资源,仅清理类内部状态。实际资源释放由描述符堆管理。
## 示例
```cpp
{
D3D12DepthStencilView dsv;
dsv.Initialize(device, depthBuffer, nullptr);
// 使用 dsv...
} // dsv 析构时自动调用 Shutdown()
```
## 相关文档
- [D3D12DepthStencilView](depth-stencil-view.md) - 类总览
- [D3D12DepthStencilView::Shutdown](shutdown.md) - 关闭方法

View File

@@ -59,4 +59,4 @@ heap.Shutdown();
- [D3D12 后端总览](../d3d12.md)
- [RHIDescriptorPool](../../descriptor-pool/descriptor-pool.md) - 抽象描述符池接口
- [D3D12Enum](d3d12-enum.md) - D3D12 类型枚举映射
- [D3D12Enum](../enums/enums.md) - D3D12 类型枚举映射

View File

@@ -2,6 +2,10 @@
**命名空间**: `XCEngine::RHI`
**类型**: `class`
**头文件**: `XCEngine/RHI/D3D12/D3D12RenderTargetView.h`
**描述**: DirectX 12 渲染目标视图的 D3D12 实现,用于在渲染管线中作为渲染目标使用。
## 公共方法

View File

@@ -0,0 +1,27 @@
# D3D12RootSignature::D3D12RootSignature
## 函数签名
```cpp
D3D12RootSignature()
```
## 描述
默认构造函数。创建空的根签名实例,成员变量初始化为零值和空指针。
## 返回值
## 示例
```cpp
D3D12RootSignature rootSig; // 创建空实例
```
## 相关文档
- [D3D12RootSignature](root-signature.md) - 类总览
- [D3D12RootSignature::Initialize](initialize.md) - 初始化方法
- [D3D12RootSignature::~D3D12RootSignature](destructor.md) - 析构函数

View File

@@ -0,0 +1,34 @@
# D3D12RootSignature::~D3D12RootSignature
## 函数签名
```cpp
~D3D12RootSignature()
```
## 描述
析构函数。自动调用 `Shutdown()` 释放内部资源。
## 返回值
## 注意事项
此析构函数自动调用 Shutdown() 确保资源被正确释放。
## 示例
```cpp
{
D3D12RootSignature rootSig;
rootSig.Initialize(device, desc);
// 使用 rootSig...
} // rootSig 析构时自动调用 Shutdown()
```
## 相关文档
- [D3D12RootSignature](root-signature.md) - 类总览
- [D3D12RootSignature::Shutdown](shutdown.md) - 关闭方法

View File

@@ -4,12 +4,16 @@
**类型**: `class` (D3D12-specific, does not inherit from RHI)
**头文件**: `XCEngine/RHI/D3D12/D3D12RootSignature.h`
**描述**: DirectX 12 根签名的 D3D12 实现,提供根签名序列化、参数创建等功能。
## 公共方法
| 方法 | 描述 |
|------|------|
| [`D3D12RootSignature`](constructor.md) | 构造函数 |
| [`~D3D12RootSignature`](destructor.md) | 析构函数 |
| [`Initialize`](initialize.md) | 初始化根签名 |
| [`Shutdown`](shutdown.md) | 关闭根签名 |
| [`GetRootSignature`](get-root-signature.md) | 获取 D3D12 根签名 |
@@ -44,4 +48,4 @@ if (rootSig.Initialize(device, desc)) {
## 相关文档
- [D3D12 后端总览](../../opengl/overview.md)
- [D3D12 后端总览](../d3d12.md)

View File

@@ -13,4 +13,4 @@
## 相关文档
- [D3D12 后端总览](../../opengl/overview.md)
- [D3D12 后端总览](../d3d12.md)

View File

@@ -45,4 +45,4 @@ delete srv;
## 相关文档
- [D3D12 后端概览](../d3d12.md)
- [OpenGL 后端](../../opengl/overview.md)
- [OpenGL 后端](../../opengl/opengl.md)

View File

@@ -35,6 +35,8 @@
| [`CreateRenderWindow`](create-render-window.md) | 创建渲染窗口 |
| [`InitializeWithExistingWindow`](initialize-with-existing-window.md) | 使用现有窗口初始化 |
| [`GetWindow`](get-window.md) | 获取 GLFW 窗口指针 |
| [`GetDC`](get-dc.md) | 获取 Windows 设备上下文 |
| [`GetContext`](get-context.md) | 获取 OpenGL 渲染上下文 |
| [`GetDeviceInfoImpl`](get-device-info-impl.md) | 获取设备信息实现 |
| [`SwapBuffers`](swap-buffers.md) | 交换前后缓冲区 |
| [`PollEvents`](poll-events.md) | 处理窗口事件 |

View File

@@ -0,0 +1,31 @@
# OpenGLDevice::GetContext
获取 OpenGL 渲染上下文Rendering Context
```cpp
HGLRC GetContext() const;
```
返回 OpenGL 渲染上下文的句柄。
**参数:**
**返回:** `HGLRC` - OpenGL 渲染上下文句柄
**线程安全:**
**注意:** 此方法返回原生 OpenGL 渲染上下文句柄,可用于 `wglShareLists``wglMakeCurrent` 等原生 OpenGL 上下文操作。大多数情况下不需要直接使用此方法。
**示例:**
```cpp
HGLRC hglrc = device.GetContext();
// 可以使用 hglrc 进行原生 OpenGL 上下文操作
HGLRC currentContext = wglGetCurrentContext();
```
## 相关文档
- [OpenGLDevice 总览](device.md) - 返回类总览
- [GetDC](get-dc.md) - 获取 Windows 设备上下文
- [GetWindow](get-window.md) - 获取 GLFW 窗口指针

View File

@@ -0,0 +1,31 @@
# OpenGLDevice::GetDC
获取 OpenGL 设备的设备上下文Device Context
```cpp
HDC GetDC() const;
```
返回与 OpenGL 渲染上下文关联的 Windows 设备上下文句柄。
**参数:**
**返回:** `HDC` - Windows 设备上下文句柄
**线程安全:**
**注意:** 此方法返回原生 Windows HDC可用于低级 GDI 操作或与原生 Windows OpenGL 上下文交互。大多数情况下不需要直接使用此方法。
**示例:**
```cpp
HDC hdc = device.GetDC();
// 可以使用 hdc 进行原生 Windows OpenGL 操作
HDC currentDC = wglGetCurrentDC();
```
## 相关文档
- [OpenGLDevice 总览](device.md) - 返回类总览
- [GetContext](get-context.md) - 获取 OpenGL 渲染上下文
- [GetWindow](get-window.md) - 获取 GLFW 窗口指针

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) | 获取原生句柄 |

View File

@@ -116,7 +116,7 @@ delete device;
## 后端文档
- [D3D12 后端](d3d12/d3d12.md) - DirectX 12 实现详情
- [OpenGL 后端](opengl/overview.md) - OpenGL 实现详情
- [OpenGL 后端](opengl/opengl.md) - OpenGL 实现详情
### D3D12 实现