No Texture Bound To The Unit 0
I am currently facing an error that I cannot seem to figure out. In chrome I am receiving: GL ERROR :GL_INVALID_VALUE : glTexImage2D: invalid internal_format GL_FALSE RENDER WARNI
Solution 1:
internal_format
is the 3rd argument to gl.texImage2D
. The error mesages says you are passing either 0
or undefined
or null
. All of those become 0
which is the same as GL_FALSE
.
You need to pass a valid internal format like gl.RGBA
, gl.RGB
, etc...
The second error is because of the first.
Solution 2:
So I found the answer after fiddling around with my code a little, turns out its a simple fix (maybe stupidity on my part) but what I used to have was this:
var boxTexture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, boxTexture);
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);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE,document.getElementById('crate-image'));
gl.bindTexture(gl.TEXTURE_2D, null);
All that needed changing was the order, so now it looks like this:
var boxTexture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, boxTexture);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_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);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE,document.getElementById('crate-image'));
gl.bindTexture(gl.TEXTURE_2D, null);
Post a Comment for "No Texture Bound To The Unit 0"