Files
XCEngine/docs/api/XCEngine/RHI/OpenGL/OpenGLTexture/Bind.md

575 B

OpenGLTexture::Bind()

void Bind(int slot = 0) const;

作用

把当前纹理绑定到指定 texture unit。

参数

  • slot: 目标 texture unit 索引。

当前实现行为

函数会:

  1. 根据 m_type 解析 OpenGL target
  2. 调用 glActiveTexture(GL_TEXTURE0 + slot)
  3. 调用 glBindTexture(target, m_texture)

需要注意

  • 它会修改当前 active texture unit。
  • 不会恢复调用前的 active unit。
  • 不会检查 slot 是否超出硬件支持范围。

相关文档