【发布时间】:2017-08-05 01:23:19
【问题描述】:
我正在尝试为反射设置立方体纹理,但出现此错误:
WebGL: drawElements: texture bound to texture unit 0 is not renderable.
It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'.
Or the texture is Float or Half Float type with linear filtering while OES_float_linear or OES_half_float_linear extension is not enabled.
index.js:404 WebGL: too many errors, no more errors will be reported to the console for this context.
我确信图像 (PNG) 已正确加载,因为 console.log 打印了两个高度和宽度的正确幂...
当我尝试绘制任何东西时出现此错误,即使在另一个着色器程序中也是如此。
这是纹理加载的代码:
gl.useProgram(shaderProgram);
cubeMap = gl.createTexture();
gl.bindTexture(gl.TEXTURE_CUBE_MAP, cubeMap);
gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.RGBA,
gl.RGBA, gl.UNSIGNED_BYTE, image_pos_x);
//5 more times for different faces of the cube
gl.activeTexture( gl.TEXTURE0 );
gl.uniform1i(gl.getUniformLocation(shaderProgram, "texture"),0);
【问题讨论】:
-
请显示纹理加载代码。
-
我刚开始的时候也遇到过这类问题,我只能说,从最简单的例子开始,比如这里的“hello triangle”:khronos.org/assets/uploads/books/… 然后“二等分”你的代码和示例,直到您找到问题为止。
-
还要特别注意纹理过滤和“ST_clamp”等模式。在尝试更改之前,请确保您阅读了所有文档并将其配置为类似于工作示例