我正在尝试为反射设置立方体纹理,但我收到了这个错误:
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);
答案 0 :(得分:1)
尝试在
中添加这些内容 gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
答案 1 :(得分:0)
我说:
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);
在我的activeTexture和bindTexture调用之间,它对我有用。