Files
XCEngine/docs/api/rhi/opengl/depth-stencil-view/initialize.md
2026-03-20 02:35:45 +08:00

63 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# OpenGLDepthStencilView::Initialize
初始化深度模板视图。
## 重载 1
```cpp
bool Initialize(unsigned int texture, const OpenGLDepthStencilViewDesc& desc);
```
使用描述结构体初始化深度模板视图,将指定的 OpenGL 纹理创建为深度模板帧缓冲对象。
**参数:**
- `texture` - OpenGL 纹理 ID
- `desc` - 深度模板视图描述结构体
**返回:** 成功返回 `true`,失败返回 `false`。失败时帧缓冲不会被创建。
**示例:**
```cpp
OpenGLDepthStencilView dsv;
OpenGLDepthStencilViewDesc desc;
desc.type = DepthStencilType::Texture2D;
desc.mipLevel = 0;
desc.baseArraySlice = 0;
desc.arraySize = 1;
dsv.Initialize(textureID, desc);
```
## 重载 2
```cpp
bool Initialize(unsigned int texture, int mipLevel = 0);
```
使用简单参数初始化深度模板视图。
**参数:**
- `texture` - OpenGL 纹理 ID
- `mipLevel` - mipmap 级别(默认为 0
**返回:** 成功返回 true失败返回 false
**示例:**
```cpp
// 使用描述结构体初始化
OpenGLDepthStencilViewDesc desc;
desc.type = DepthStencilType::Texture2D;
desc.mipLevel = 0;
desc.baseArraySlice = 0;
desc.arraySize = 1;
dsv.Initialize(textureID, desc);
// 使用简单参数初始化
dsv.Initialize(textureID, 0);
```
## 相关文档
- [OpenGLDepthStencilView 总览](depth-stencil-view.md) - 返回类总览