docs: update resources API docs
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
**命名空间**: `XCEngine::Resources`
|
||||
|
||||
**类型**: `class`
|
||||
**类型**: `class` (inherits from `IResource`)
|
||||
|
||||
**头文件**: `XCEngine/Resources/Texture.h`
|
||||
|
||||
**描述**: 纹理资源类,管理 2D/3D 纹理和立方体贴图的像素数据。
|
||||
|
||||
@@ -79,74 +81,74 @@
|
||||
|
||||
## 公共方法
|
||||
|
||||
### 基础属性
|
||||
### 构造与析构
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `ResourceType GetType() const` | 返回 `ResourceType::Texture` |
|
||||
| `const Containers::String& GetName() const` | 获取纹理名称 |
|
||||
| `const Containers::String& GetPath() const` | 获取纹理路径 |
|
||||
| `ResourceGUID GetGUID() const` | 获取全局唯一标识符 |
|
||||
| `bool IsValid() const` | 检查纹理是否有效 |
|
||||
| `size_t GetMemorySize() const` | 获取内存大小 |
|
||||
| `void Release()` | 释放纹理引用 |
|
||||
| [`Texture`](texture_constructor.md) | 默认构造函数 |
|
||||
| [`~Texture`](texture_destructor.md) | 析构函数 |
|
||||
|
||||
### IResource 实现
|
||||
|
||||
继承自 `IResource` 接口。
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| [`GetType`](../iresource/gettype.md) | 返回 `ResourceType::Texture` |
|
||||
| [`GetName`](../iresource/getname.md) | 获取纹理名称 |
|
||||
| [`GetPath`](../iresource/getpath.md) | 获取纹理路径 |
|
||||
| [`GetGUID`](../iresource/getguid.md) | 获取全局唯一标识符 |
|
||||
| [`IsValid`](../iresource/isvalid.md) | 检查纹理是否有效 |
|
||||
| [`GetMemorySize`](../iresource/getmemorysize.md) | 获取内存大小 |
|
||||
| [`Release`](../iresource/release.md) | 释放纹理引用 |
|
||||
|
||||
### 纹理属性
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `Core::uint32 GetWidth() const` | 获取纹理宽度(像素) |
|
||||
| `Core::uint32 GetHeight() const` | 获取纹理高度(像素) |
|
||||
| `Core::uint32 GetDepth() const` | 获取纹理深度(3D 纹理) |
|
||||
| `Core::uint32 GetMipLevels() const` | 获取 Mipmap 级别数 |
|
||||
| `Core::uint32 GetArraySize() const` | 获取数组大小 |
|
||||
| `TextureType GetTextureType() const` | 获取纹理类型 |
|
||||
| `TextureFormat GetFormat() const` | 获取纹理格式 |
|
||||
| `TextureUsage GetUsage() const` | 获取纹理用途标志 |
|
||||
| [`GetWidth`](getwidth.md) | 获取纹理宽度(像素) |
|
||||
| [`GetHeight`](getheight.md) | 获取纹理高度(像素) |
|
||||
| [`GetDepth`](getdepth.md) | 获取纹理深度(3D 纹理) |
|
||||
| [`GetMipLevels`](getmiplevels.md) | 获取 Mipmap 级别数 |
|
||||
| [`GetArraySize`](getarraysize.md) | 获取数组大小 |
|
||||
| [`GetTextureType`](gettexturetype.md) | 获取纹理类型 |
|
||||
| [`GetFormat`](getformat.md) | 获取纹理格式 |
|
||||
| [`GetUsage`](getusage.md) | 获取纹理用途标志 |
|
||||
|
||||
### 像素数据
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `const void* GetPixelData() const` | 获取像素数据指针 |
|
||||
| `size_t GetPixelDataSize() const` | 获取像素数据大小 |
|
||||
| [`GetPixelData`](getpixeldata.md) | 获取像素数据指针 |
|
||||
| [`GetPixelDataSize`](getpixeldatasize.md) | 获取像素数据大小 |
|
||||
|
||||
### 创建与操作
|
||||
|
||||
| 方法 | 描述 |
|
||||
|------|------|
|
||||
| `bool Create(Core::uint32 width, Core::uint32 height, Core::uint32 depth, Core::uint32 mipLevels, TextureType type, TextureFormat format, const void* data, size_t dataSize)` | 创建纹理 |
|
||||
| `bool GenerateMipmaps()` | 生成 Mipmap(当前返回 false - stub) |
|
||||
|
||||
## 实现说明
|
||||
|
||||
**注意**: `Create()` 方法中 `mipLevels` 参数为 0 时不会自动计算所有级别。`GenerateMipmaps()` 当前返回 false,为 stub 实现。
|
||||
| [`Create`](create.md) | 创建纹理 |
|
||||
| [`GenerateMipmaps`](generatemipmaps.md) | 生成 Mipmap 链 |
|
||||
|
||||
## 使用示例
|
||||
|
||||
```cpp
|
||||
// 加载纹理
|
||||
ResourceHandle<Texture> tex = ResourceManager::Get().Load<Texture>("textures/player.png");
|
||||
|
||||
// 手动创建纹理
|
||||
Texture tex;
|
||||
bool created = tex.Create(
|
||||
1024, // 宽度
|
||||
1024, // 高度
|
||||
1, // 深度
|
||||
0, // Mipmap 级别(0=全部)
|
||||
TextureType::Texture2D, // 类型
|
||||
TextureFormat::RGBA8_UNORM, // 格式
|
||||
1, // Mipmap 级别数
|
||||
TextureType::Texture2D, // 类型
|
||||
TextureFormat::RGBA8_UNORM, // 格式
|
||||
pixelData, // 像素数据
|
||||
pixelDataSize // 数据大小
|
||||
);
|
||||
|
||||
// 生成 Mipmap
|
||||
tex.GenerateMipmaps();
|
||||
|
||||
// 访问纹理属性
|
||||
uint32_t w = tex.GetWidth();
|
||||
uint32_t h = tex.GetHeight();
|
||||
auto format = tex.GetFormat();
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
@@ -154,8 +156,4 @@ uint32_t h = tex.GetHeight();
|
||||
- [IResource](../iresource/iresource.md) - 资源基类
|
||||
- [ResourceManager](../resourcemanager/resourcemanager.md) - 资源管理器
|
||||
- [RHITexture](../../rhi/texture/texture.md) - RHI 纹理接口
|
||||
- [Resources 总览](../resources.md) - 返回模块总览
|
||||
|
||||
## 实现说明
|
||||
|
||||
**注意**: `TextureLoader::Load()` 仅为示例实现,不解析 PNG/JPG 等格式的实际图像数据,仅创建空纹理对象。
|
||||
- [Resources 总览](../resources.md) - 返回模块总览
|
||||
Reference in New Issue
Block a user