I’ve been working a bit with WebGL but it seems I can’t manage to display textures any more. The output of the fragment shader is always black (the silhouette is visible).
I know this problem may occur with textures that aren’t a power of two. Unfortunately mine are (256×256). Besides, I did get them working before at some point (but I changed too much to backtrack the problem).
EDIT:
I’ve greatly simplified my program and as suggested by gman used WebGL Inspector (great tip btw).
Textures look fine from WebGL Inspector.
I was just about to post the whole code when I noticed that while
var textureUniformLocation = gl.getUniformLocation(shaderProgram, "uSampler");
console.log(textureUniformLocation);
gl.activeTexture(gl.TEXTURE0);
gl.bindTexture(gl.TEXTURE_2D, neheTexture);
gl.uniform1i(textureUniformLocation, 0);
does not work, adding alert(textureUniformLocation); after console.log(...) makes the texture appear…
What I now want to know is: Is my graphics card doing drugs?
EDIT2: It will work if I put a simple string in the alert as well.
The only reason I can think of this would occur is either bad memory management or multiple execution threads. Neither of them are the case here afaik. What kind of thing could even cause such a problem in javascript?
Any help would be greatly appreciated.
If the inspector sees the textures, then… they are probably loading. Is the behavior consistent in both Chrome and Firefox? The reported behavior about alert() makes me think that perhaps the render happened before the texture load and the alert() causes a refresh (after the texture load).
Also make sure that this isn’t a problem with vertex attributes like vertex color or degenerate UV coordinates.