opengl-es - OpenGL ES 2.x : Bind both `GL_TEXTURE_2D` and `GL_TEXTURE_CUBE_MAP` in the same texture image unit?

标签 opengl-es opengl-es-2.0

如果将(不同的纹理)绑定(bind)到这两个 GL_TEXTURE_2D 会发生什么?和 GL_TEXTURE_CUBE_MAP在同一个纹理图像单元中?

例如,假设我将一个纹理绑定(bind)到 GL_TEXTURE0GL_TEXTURE_2D目标和另一个纹理到同一纹理单元的GL_TEXTURE_CUBE_MAP目标。然后我可以有两个统一变量,一个是 sampler2D另一个是 samplerCube并将两者都设置为 0(引用 GL_TEXTURE0 )?

我怀疑答案是“否”(或者结果未定义),但我没有在规范中找到任何明确禁止在同一纹理图像单元中使用多个纹理目标的内容。

最佳答案

对于 Chrome,我在尝试执行此类操作时遇到错误。

var gl = document.getElementById("canv00").getContext("webgl");
const texture = gl.createTexture()
gl.bindTexture(gl.TEXTURE_2D, texture)
gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture)
gl.getParameter(gl.TEXTURE_BINDING_2D) // texture
gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP) // null
gl.getError()  // returns 1282 error
var gl = document.getElementById("canv00").getContext("webgl");
const texture = gl.createTexture()
gl.bindTexture(gl.TEXTURE_2D, texture)
// gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture)
gl.getParameter(gl.TEXTURE_BINDING_2D) // texture
gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP) // null
gl.getError()  // no error
var gl = document.getElementById("canv00").getContext("webgl");
const texture = gl.createTexture()
// gl.bindTexture(gl.TEXTURE_2D, texture)
gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture)
gl.getParameter(gl.TEXTURE_BINDING_2D) // null
gl.getParameter(gl.TEXTURE_BINDING_CUBE_MAP) // texture
gl.getError()  // no error

关于opengl-es - OpenGL ES 2.x : Bind both `GL_TEXTURE_2D` and `GL_TEXTURE_CUBE_MAP` in the same texture image unit?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9951792/

相关文章:

iphone - 对于具有不同上下文的多个线程,OpenGL 线程安全吗?

java - XYZ 旋转后计算对象 XYZ 方向

ios - 如何处理由 "squaring"纹理引起的纹理失真,以及与 mipmapping 的交互?

android - GLSL错误: No vertex attrib is enabled in a draw call

iphone - 使用 `CVImageBufferRef` 将 `glTexImage2D` 转换为 OpenGL ES 纹理时如何消除伪影?

android - 将硬件加速标志与 Canvas.clipPath 一起使用

ios - OpenGL - 计算着色器 - iOS - 选项?

android - 将自定义属性传递给自定义 fragment 着色器

android - 使用 OpenGL for Android 绘制三角形的纹理问题

opengl-es - 什么时候应该在 OpenGL ES 2 中使用 glDeleteBuffers、glDeleteShader 和 glDeleteProgram?