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

42 lines
907 B
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.
# OpenGLFence::Initialize
```cpp
bool Initialize(bool signaled = false);
```
初始化 OpenGLFence 实例,设置栅栏的初始值和状态。
## 详细描述
此方法不创建 OpenGL 同步对象(`GLsync`),仅初始化内部状态。`GLsync` 对象在首次调用 `Signal()` 时才被创建。
## 参数
| 参数 | 类型 | 描述 |
|------|------|------|
| `signaled` | `bool` | 初始是否为 signaled 状态。默认为 `false`Unsignaled |
## 返回值
| 类型 | 描述 |
|------|------|
| `bool` | 始终返回 `true`。初始化成功 |
## 示例
```cpp
OpenGLFence fence;
// 创建为 unsignaled 状态
fence.Initialize(false);
// 或创建为 already signaled 状态
OpenGLFence fence2;
fence2.Initialize(true);
```
## 相关文档
- [OpenGLFence 总览](fence.md) - 返回类总览
- [Signal](signal.md) - 创建 GLsync 对象
- [Shutdown](shutdown.md) - 释放资源