且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

glGenerateMipmap - 非 2 次幂

更新时间:2023-11-30 19:05:16

您不能在 WebGL1 中为非 2 次幂的纹理生成 mipmap.这就是重点,在 WebGL1 时期不支持 mipmapped 非 2 次幂纹理.所以你设置了过滤,让它只使用级别 0

You can not generate a mipmap for a non-power-of-2 texture in WebGL1. That's kind of the point, mipmapped non-power-of-2 textures are not supported in WebGL1 period. So you set the filtering so it uses only level 0

gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);

这意味着没有理由生成 mips,因为它们永远不会被使用.请参阅这篇文章.

Which means there's no reason to generate mips since they'll never be used. See this article.