【发布时间】:2021-02-05 18:59:45
【问题描述】:
当我在 dartium 中运行我的网络应用程序时,我收到了错误 [.WebGLRenderingContext]RENDER WARNING: 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'。这两天我一直在尝试解决这个问题,包括完全重写代码,但我无法隔离这个问题。
我认为问题在于这段代码。
void main() {
...
var texture = gl.createTexture();
var image = new ImageElement();
image.onLoad.listen((e) {
gl.bindTexture(webGL.TEXTURE_2D, texture);
gl.texImage2DImage(webGL.TEXTURE_2D, 0, webGL.RGBA, webGL.RGBA,
webGL.UNSIGNED_BYTE, image);
gl.texParameteri(webGL.TEXTURE_2D, webGL.TEXTURE_MAG_FILTER, webGL.NEAREST);
gl.texParameteri(webGL.TEXTURE_2D, webGL.TEXTURE_MIN_FILTER, webGL.NEAREST);
gl.bindTexture(webGL.TEXTURE_2D, null);
});
image.src = "tex.png";
...
}
tex.png 是 32x32
关于问题所在有什么想法吗?
【问题讨论】:
-
gl.generateMipmap(gl.TEXTURE_2D);帮你?
-
@Fox32 它没有。不是只有在设置 mipmap 参数时才需要吗?