docs: 新增 light-component 全部方法文档及更新其他模块

- components: 新增 light-component 全部12个方法文档
- resources: 更新 audio-loader, resource-file-system 文档
- rhi: 更新 opengl/fence 文档
This commit is contained in:
2026-03-26 02:02:21 +08:00
parent ab5ba1d57a
commit c2354530b9
16 changed files with 480 additions and 39 deletions

View File

@@ -0,0 +1,38 @@
# GetCastsShadows
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 检查光源是否投射阴影。
## 函数签名
```cpp
bool GetCastsShadows() const;
```
## 返回值
| 类型 | 描述 |
|------|------|
| `bool` | true 表示投射阴影false 表示不投射阴影 |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void CheckShadowCasting(LightComponent* light) {
if (light->GetCastsShadows()) {
printf("This light casts shadows\n");
}
}
```
## 相关文档
- [LightComponent](./light-component.md) - 光源组件
- [SetCastsShadows](./set-casts-shadows.md) - 设置阴影投射

View File

@@ -0,0 +1,37 @@
# GetColor
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 获取光源的颜色。
## 函数签名
```cpp
const Math::Color& GetColor() const;
```
## 返回值
| 类型 | 描述 |
|------|------|
| `const Math::Color&` | 光源颜色引用 |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void PrintLightColor(LightComponent* light) {
const auto& color = light->GetColor();
printf("Light color: (%.2f, %.2f, %.2f)\n", color.r, color.g, color.b);
}
```
## 相关文档
- [LightComponent](light-component.md) - 光源组件
- [SetColor](set-color.md) - 设置光源颜色

View File

@@ -0,0 +1,37 @@
# GetIntensity
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 获取光源的强度。
## 函数签名
```cpp
float GetIntensity() const;
```
## 返回值
| 类型 | 描述 |
|------|------|
| `float` | 光源强度,默认值为 1.0 |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void PrintLightIntensity(LightComponent* light) {
float intensity = light->GetIntensity();
printf("Light intensity: %.2f\n", intensity);
}
```
## 相关文档
- [LightComponent](./light-component.md) - 光源组件
- [SetIntensity](./set-intensity.md) - 设置光源强度

View File

@@ -0,0 +1,42 @@
# GetLightType
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 获取光源的类型。
## 函数签名
```cpp
LightType GetLightType() const;
```
## 返回值
| 类型 | 描述 |
|------|------|
| `LightType` | 光源类型:`Directional`(定向光)、`Point`(点光源)或 `Spot`(聚光灯) |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void CheckLightType(LightComponent* light) {
if (light->GetLightType() == LightType::Directional) {
printf("Directional light\n");
} else if (light->GetLightType() == LightType::Point) {
printf("Point light\n");
} else {
printf("Spot light\n");
}
}
```
## 相关文档
- [LightComponent](light-component.md) - 光源组件
- [SetLightType](set-light-type.md) - 设置光源类型

View File

@@ -0,0 +1,37 @@
# GetRange
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 获取光源的作用范围(仅对点光源和聚光灯有效)。
## 函数签名
```cpp
float GetRange() const;
```
## 返回值
| 类型 | 描述 |
|------|------|
| `float` | 作用范围(米),默认值为 10.0 |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void PrintLightRange(LightComponent* light) {
float range = light->GetRange();
printf("Light range: %.2f meters\n", range);
}
```
## 相关文档
- [LightComponent](./light-component.md) - 光源组件
- [SetRange](./set-range.md) - 设置作用范围

View File

@@ -0,0 +1,37 @@
# GetSpotAngle
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 获取聚光灯的角度(仅对聚光灯有效)。
## 函数签名
```cpp
float GetSpotAngle() const;
```
## 返回值
| 类型 | 描述 |
|------|------|
| `float` | 聚光灯角度(度),默认值为 30.0 |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void PrintSpotAngle(LightComponent* light) {
float angle = light->GetSpotAngle();
printf("Spot angle: %.1f degrees\n", angle);
}
```
## 相关文档
- [LightComponent](./light-component.md) - 光源组件
- [SetSpotAngle](./set-spot-angle.md) - 设置聚光灯角度

View File

@@ -0,0 +1,40 @@
# SetCastsShadows
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 设置光源是否投射阴影。
## 函数签名
```cpp
void SetCastsShadows(bool value);
```
## 参数
| 参数 | 类型 | 描述 |
|------|------|------|
| `value` | `bool` | true 启用阴影投射false 禁用阴影投射 |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void SetupShadowCasting(LightComponent* light) {
// 启用阴影
light->SetCastsShadows(true);
// 禁用阴影(性能优化)
light->SetCastsShadows(false);
}
```
## 相关文档
- [LightComponent](./light-component.md) - 光源组件
- [GetCastsShadows](./get-casts-shadows.md) - 检查阴影投射

View File

@@ -0,0 +1,43 @@
# SetColor
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 设置光源的颜色。
## 函数签名
```cpp
void SetColor(const Math::Color& value);
```
## 参数
| 参数 | 类型 | 描述 |
|------|------|------|
| `value` | `const Math::Color&` | 光源颜色 |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void SetupLightColor(LightComponent* light) {
// 白色光源
light->SetColor(Math::Color::White());
// 暖色光源
light->SetColor(Math::Color(1.0f, 0.9f, 0.7f, 1.0f));
// 蓝色光源
light->SetColor(Math::Color(0.5f, 0.7f, 1.0f, 1.0f));
}
```
## 相关文档
- [LightComponent](light-component.md) - 光源组件
- [GetColor](get-color.md) - 获取光源颜色

View File

@@ -0,0 +1,43 @@
# SetIntensity
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 设置光源的强度。
## 函数签名
```cpp
void SetIntensity(float value);
```
## 参数
| 参数 | 类型 | 描述 |
|------|------|------|
| `value` | `float` | 光源强度,值越大光线越亮 |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void SetupLightIntensity(LightComponent* light) {
// 标准强度
light->SetIntensity(1.0f);
// 高强度(太阳光)
light->SetIntensity(3.0f);
// 低强度(月光)
light->SetIntensity(0.2f);
}
```
## 相关文档
- [LightComponent](./light-component.md) - 光源组件
- [GetIntensity](./get-intensity.md) - 获取光源强度

View File

@@ -0,0 +1,43 @@
# SetLightType
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 设置光源的类型。
## 函数签名
```cpp
void SetLightType(LightType value);
```
## 参数
| 参数 | 类型 | 描述 |
|------|------|------|
| `value` | `LightType` | 光源类型:`Directional`(定向光)、`Point`(点光源)或 `Spot`(聚光灯) |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void SetupLightType(LightComponent* light) {
// 定向光(太阳光)
light->SetLightType(LightType::Directional);
// 点光源(灯泡)
light->SetLightType(LightType::Point);
// 聚光灯(手电筒)
light->SetLightType(LightType::Spot);
}
```
## 相关文档
- [LightComponent](light-component.md) - 光源组件
- [GetLightType](get-light-type.md) - 获取光源类型

View File

@@ -0,0 +1,37 @@
# SetRange
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 设置光源的作用范围(仅对点光源和聚光灯有效)。
## 函数签名
```cpp
void SetRange(float value);
```
## 参数
| 参数 | 类型 | 描述 |
|------|------|------|
| `value` | `float` | 作用范围(米) |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void SetupLightRange(LightComponent* light) {
light->SetLightType(LightType::Point);
light->SetRange(15.0f); // 15米范围
}
```
## 相关文档
- [LightComponent](./light-component.md) - 光源组件
- [GetRange](./get-range.md) - 获取作用范围

View File

@@ -0,0 +1,37 @@
# SetSpotAngle
**所属类**: `LightComponent`
**头文件**: `XCEngine/Components/LightComponent.h`
**描述**: 设置聚光灯的角度(仅对聚光灯有效)。
## 函数签名
```cpp
void SetSpotAngle(float value);
```
## 参数
| 参数 | 类型 | 描述 |
|------|------|------|
| `value` | `float` | 聚光灯角度(度),通常在 1.0 到 90.0 之间 |
## 使用示例
```cpp
#include <XCEngine/Components/LightComponent.h>
using namespace XCEngine::Components;
void SetupSpotLight(LightComponent* light) {
light->SetLightType(LightType::Spot);
light->SetSpotAngle(45.0f); // 45度锥角
}
```
## 相关文档
- [LightComponent](./light-component.md) - 光源组件
- [GetSpotAngle](./get-spot-angle.md) - 获取聚光灯角度

View File

@@ -22,7 +22,7 @@
|------|--------|------| |------|--------|------|
| [AudioLoader](constructor.md) | - | 构造函数 | | [AudioLoader](constructor.md) | - | 构造函数 |
| [~AudioLoader](destructor.md) | - | 析构函数 | | [~AudioLoader](destructor.md) | - | 析构函数 |
| [GetResourceType](methods/get-resource-type.md) | `ResourceType` | 返回资源类型 `AudioClip` | | `GetResourceType()` | `ResourceType` | 返回资源类型 `AudioClip`(继承自 IResourceLoader |
| [GetSupportedExtensions](get-supported-extensions.md) | `Array<String>` | 获取支持的扩展名列表 | | [GetSupportedExtensions](get-supported-extensions.md) | `Array<String>` | 获取支持的扩展名列表 |
| [CanLoad](can-load.md) | `bool` | 检查是否能够加载指定路径的资源 | | [CanLoad](can-load.md) | `bool` | 检查是否能够加载指定路径的资源 |
| [Load](load.md) | `LoadResult` | 加载音频资源 | | [Load](load.md) | `LoadResult` | 加载音频资源 |

View File

@@ -25,5 +25,5 @@ size_t dataSize = data.Size();
## 相关文档 ## 相关文档
- [AudioClip 总览](audio-clip.md) - 返回类总览 - [AudioClip 总览](audioclip.md) - 返回类总览
- [SetAudioData](setaudiodata.md) - 设置音频数据 - [SetAudioData](setaudiodata.md) - 设置音频数据

View File

@@ -47,7 +47,7 @@
## 使用示例 ## 使用示例
```cpp ```cpp
#include "Resources/ResourceFileSystem.h" #include <XCEngine/Core/IO/ResourceFileSystem.h>
using namespace XCEngine; using namespace XCEngine;
using namespace XCEngine::Resources; using namespace XCEngine::Resources;

View File

@@ -8,38 +8,16 @@
`OpenGLFence` 提供基于 OpenGL 同步对象(`GLsync`)的栅栏实现,用于 CPU-GPU 同步。当 GPU 完成特定操作后,栅栏会被设置为 signaled 状态CPU 可以通过 `Wait` 方法等待该状态。 `OpenGLFence` 提供基于 OpenGL 同步对象(`GLsync`)的栅栏实现,用于 CPU-GPU 同步。当 GPU 完成特定操作后,栅栏会被设置为 signaled 状态CPU 可以通过 `Wait` 方法等待该状态。
### FenceStatus 枚举
```cpp
enum class FenceStatus {
Signaled, // 栅栏已signaled操作已完成
Unsignaled, // 栅栏未signaled操作未完成
Error // 发生错误
};
```
### 私有成员
| 成员 | 类型 | 描述 |
|------|------|------|
| `m_sync` | `void*` | OpenGL GLsync 句柄 |
| `m_fenceValue` | `uint64_t` | 当前栅栏值 |
| `m_completedValue` | `uint64_t` | 已完成的栅栏值 |
| `m_signaled` | `bool` | 软件层面的signaled状态标志 |
## 公共方法 ## 公共方法
| 方法 | 描述 | | 方法 | 描述 |
|------|------| |------|------|
| [`Initialize`](initialize.md) | 初始化栅栏,设置初始值和状态 | | [`OpenGLFence`](constructor.md) | 构造函数 |
| [`Initialize`](initialize.md) | 初始化栅栏,设置初始值 |
| [`Shutdown`](shutdown.md) | 关闭栅栏,释放 GLsync 资源 | | [`Shutdown`](shutdown.md) | 关闭栅栏,释放 GLsync 资源 |
| [`Signal`](signal.md) | 信号栅栏,创建/更新同步对象 | | [`Signal`](signal.md) | 信号栅栏(重载:有无参数版本) |
| [`Wait`](wait.md) | 等待栅栏达到 signaled 状态 | | [`Wait`](wait.md) | 等待栅栏达到指定值 |
| [`Reset`](reset.md) | 重置栅栏,删除同步对象 |
| [`IsSignaled`](is-signaled.md) | 检查软件层面的signaled状态 |
| [`GetStatus`](get-status.md) | 获取 OpenGL 层面的同步状态 |
| [`GetCompletedValue`](get-completed-value.md) | 获取已完成的栅栏值 | | [`GetCompletedValue`](get-completed-value.md) | 获取已完成的栅栏值 |
| [`GetCurrentValue`](get-current-value.md) | 获取当前栅栏值 |
| [`GetNativeHandle`](get-native-handle.md) | 获取原生 GLsync 句柄 | | [`GetNativeHandle`](get-native-handle.md) | 获取原生 GLsync 句柄 |
## 使用示例 ## 使用示例
@@ -51,21 +29,13 @@ using namespace XCEngine::RHI;
// 创建并初始化栅栏 // 创建并初始化栅栏
OpenGLFence fence; OpenGLFence fence;
fence.Initialize(false); fence.Initialize(0);
// 执行 GPU 操作后信号栅栏 // 执行 GPU 操作后信号栅栏
fence.Signal(); fence.Signal();
// 等待栅栏,最多等待 1 秒 // 等待栅栏,最多等待 1 秒
fence.Wait(1000000000); fence.Wait(1);
// 检查状态
if (fence.IsSignaled()) {
// 操作已完成
}
// 重置并复用
fence.Reset();
``` ```
## 相关文档 ## 相关文档