Update API documentation and remove obsolete plan files
This commit is contained in:
@@ -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) - 整数矩形
|
||||
|
||||
Reference in New Issue
Block a user