32 lines
977 B
Markdown
32 lines
977 B
Markdown
|
|
# OpenGLTexture::Initialize
|
|||
|
|
|
|||
|
|
```cpp
|
|||
|
|
bool Initialize(OpenGLTextureType type, int width, int height, int depth, int mipLevels, OpenGLFormat format, const void* data = nullptr)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
初始化通用纹理。
|
|||
|
|
|
|||
|
|
**参数:**
|
|||
|
|
- `type` - 纹理类型(`OpenGLTextureType::Texture1D`、`Texture2D`、`Texture3D` 等)
|
|||
|
|
- `width` - 纹理宽度
|
|||
|
|
- `height` - 纹理高度
|
|||
|
|
- `depth` - 纹理深度(1D/2D 纹理为 1)
|
|||
|
|
- `mipLevels` - mipmap 级别数量
|
|||
|
|
- `format` - 纹理格式(`OpenGLFormat` 枚举值)
|
|||
|
|
- `data` - 纹理数据指针(可以为 nullptr 创建空纹理)
|
|||
|
|
|
|||
|
|
**返回:** `bool` - 成功返回 true,失败返回 false
|
|||
|
|
|
|||
|
|
**示例:**
|
|||
|
|
|
|||
|
|
```cpp
|
|||
|
|
OpenGLTexture texture;
|
|||
|
|
texture.Initialize(OpenGLTextureType::Texture2D, 1024, 1024, 1, 1, OpenGLFormat::RGBA8, nullptr);
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 相关文档
|
|||
|
|
|
|||
|
|
- [OpenGLTexture](texture.md) - 返回类总览
|
|||
|
|
- [Initialize2D](initialize-2d.md) - 2D 纹理初始化
|
|||
|
|
- [InitializeCubeMap](initialize-cube-map.md) - 立方体贴图初始化
|