环境 Ubuntu 17.04、Chrome 60。
在本地运行此示例,不会出现警告/错误:https://github.com/mdn/webgl-examples/tree/gh-pages/tutorial/sample6 https://github.com/mdn/webgl-examples/tree/gh-pages/tutorial/sample6
然后更换cubetexture.png
与non-power-of-2
图片在这里:https://github.com/mdn/webgl-examples/blob/gh-pages/tutorial/sample6/webgl-demo.js#L220 https://github.com/mdn/webgl-examples/blob/gh-pages/tutorial/sample6/webgl-demo.js#L220
得到预期的警告/错误:
[.Offscreen-For-WebGL-0x13d050ba2c00]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.
[.Offscreen-For-WebGL-0x13d050ba2c00]GL ERROR :GL_INVALID_OPERATION : glGenerateMipmap: Can not generate mips
接下来添加参数:
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
然后运行正常,没有警告,但仍然意外出现错误:
[.Offscreen-For-WebGL-0x13d050fb4000]GL ERROR :GL_INVALID_OPERATION : glGenerateMipmap: Can not generate mips
除了错误消息之外non-power-of-2
图像在立方体上渲染正常。 Firefox 54 中也有同样的行为。关于这里发生的情况有什么提示吗?