1.3 KiB
1.3 KiB
OpenGLRenderTargetView::InitializeCubemap()
bool InitializeCubemap(unsigned int cubemap, int face, int mipLevel = 0);
作用
为 cubemap 的单个 face 创建颜色渲染目标 view。
参数
cubemap: cubemap 纹理对象 ID。face: 目标面索引。实现会直接映射到GL_TEXTURE_CUBE_MAP_POSITIVE_X + face。mipLevel: 目标 mip。
返回值
true: framebuffer 完整。false: framebuffer 不完整。
当前实现行为
- 把
m_texture设置为cubemap。 - 把
m_mipLevel设置为mipLevel。 - 把
m_type设置为RenderTargetType::TextureCube。 - 生成并绑定一个新的 FBO。
- 使用
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, cubemap, mipLevel)进行附着。 - 做完整性检查后解绑回
0。
需要注意
- 当前没有对
face做范围校验。 - 失败时不会回滚成员状态,也不会删除刚创建的 FBO。
- 这个接口只是便捷包装,并没有比 Initialize 提供更多能力。
适用场景
它适合环境贴图预处理、反射探针、立方体阴影贴图等“逐 face 渲染”的流程,因为那类场景天然就是一次只激活一个 cubemap 面。