【发布时间】:2015-09-11 07:47:37
【问题描述】:
我正在创作一个 WebGL 应用程序。一切都按预期工作,除了我在调试控制台中收到以下错误。
[.WebGLRenderingContext-0086F710]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.
让我们排除一些可能性
1- 这肯定不是纹理加载的问题,因为纹理在第一帧中正确显示。
2- 我知道使用二次幂纹理,这就是我所做的。在我真正拥有相关纹理之前,我一直在使用下面的填充纹理,除了一个是按比例放大的,使用的是 2x2。
2a- 我知道警告所指的incompatible texture filtering 是使用非二次幂纹理,但无论如何这里是相关的过滤代码。
// When creating the texture
var texture = gl.createTexture();
texture.image = new Image();
texture.image.onload = function() {
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.generateMipmap(gl.TEXTURE_2D);
gl.bindTexture(gl.TEXTURE_2D, null);
}
texture.image.src = src;
// At render time
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, item.texture);
gl.uniform1i(gl.getUniformLocation(shaderProgram, "uSampler"), 0);
我是否正确假设此错误对其发生原因的猜测是错误的?什么会满足(不仅仅是压制)它?
提前致谢。
【问题讨论】:
-
你的“填充”纹理在你运行渲染循环之前加载了吗?
-
是的。这就是为什么,在我的问题中,我说,
1- This is most certainly not a problem of texture loading as the textures show up correctly in the first frame.
标签: javascript textures webgl