Files
XCEngine/docs/api/rhi/opengl/render-target-view/bind.md

37 lines
986 B
Markdown
Raw Normal View History

# OpenGLRenderTargetView::Bind
```cpp
2026-03-20 02:35:45 +08:00
void Bind(unsigned int slot = 0);
void Bind(unsigned int count, const unsigned int* framebuffers, const int* drawBuffers);
```
2026-03-20 02:35:45 +08:00
绑定渲染目标视图作为当前渲染目标。
**重载 1 参数:**
- `slot` - 绑定槽位(预留参数,当前实现中未使用)
**重载 2 参数:**
- `count` - 帧缓冲区数量
- `framebuffers` - 帧缓冲区 ID 数组
- `drawBuffers` - 对应每个帧缓冲区的绘制缓冲附件
**行为说明:**
-`count` 为 1 时,直接绑定单个帧缓冲区
-`count` 大于 1 时启用多重渲染目标MRT依次绑定各帧缓冲区并设置绘制缓冲附件
**示例:**
```cpp
// 单帧缓冲绑定
rtv.Bind();
// 多帧缓冲绑定
unsigned int fbos[] = { fbo1, fbo2 };
int attachments[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
rtv.Bind(2, fbos, attachments);
```
## 相关文档
- [OpenGLRenderTargetView 总览](render-target-view.md) - 返回类总览