37 lines
986 B
Markdown
37 lines
986 B
Markdown
# OpenGLRenderTargetView::Bind
|
||
|
||
```cpp
|
||
void Bind(unsigned int slot = 0);
|
||
void Bind(unsigned int count, const unsigned int* framebuffers, const int* drawBuffers);
|
||
```
|
||
|
||
绑定渲染目标视图作为当前渲染目标。
|
||
|
||
**重载 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) - 返回类总览
|