- 重组文档目录结构: 每个模块的概述页移动到模块子目录 - 重命名 index.md 为 main.md - 修正所有模块文档中的错误: - math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式 - containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节 - core: 修复 types 链接错误 - debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI - memory: 修复头文件路径, malloc vs operator new, 新增方法文档 - resources: 修复 Shader/Texture 链接错误 - threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接 - 验证: fix_links.py 确认 0 个断裂引用
40 lines
968 B
Markdown
40 lines
968 B
Markdown
# Texture::Create
|
||
|
||
```cpp
|
||
bool Create(Core::uint32 width, Core::uint32 height, Core::uint32 depth,
|
||
Core::uint32 mipLevels, TextureType type, TextureFormat format,
|
||
const void* data, size_t dataSize)
|
||
```
|
||
|
||
创建纹理资源。设置纹理的尺寸、格式和像素数据,并分配 GPU 资源。
|
||
|
||
**参数:**
|
||
- `width` - 纹理宽度(像素)
|
||
- `height` - 纹理高度(像素)
|
||
- `depth` - 纹理深度(3D 纹理设为 1)
|
||
- `mipLevels` - Mipmap 级别数(0 表示自动生成所有级别)
|
||
- `type` - 纹理类型
|
||
- `format` - 纹理格式
|
||
- `data` - 像素数据指针
|
||
- `dataSize` - 像素数据大小
|
||
|
||
**返回:** 创建成功返回 true
|
||
|
||
**复杂度:** O(n),n 为像素数量
|
||
|
||
**示例:**
|
||
|
||
```cpp
|
||
Texture tex;
|
||
bool ok = tex.Create(
|
||
1024, 1024, 1, 0,
|
||
TextureType::Texture2D,
|
||
TextureFormat::RGBA8_UNORM,
|
||
pixelData, pixelDataSize
|
||
);
|
||
```
|
||
|
||
## 相关文档
|
||
|
||
- [Texture 总览](texture.md) - 返回类总览
|