WebGL oddities

Hi all,

The last view weeks I’ve been working with WebGL en came across some strange behaviour. I was wondering if anyone noticed the same and maybe help to shed some light?

Depth buffer
If I disable depth testing with g_GL.disable(g_GL.DEPTH_TEST);
writing to the depthbuffer is turned off also. Just like calling g_GL.depthMask(false);

Shader variables
When declaring uniform or varying variables in a shader, you have to reference them in the shader otherwise getting it’s location will fail. It’s like vars not in the code path are removed by a preprocessor.
Normally no big deal, but pretty annoying when debugging. I’m currently misusing gl_FrontFacing to dodge this.

Vertex attributes
Say you loaded 2 shaders, shader-A with 3 vertex attributes and shader-B with 4 vertexattributes.
When I only use shader-A nothing will be rendered. I have to also call vertexAttribPointer at least once for shader-B (or some shader with 4 attributes) in the render loop. It doesn’t have to actually render something. Again, no big deal in most cases. But if I would want to show a progress screen while I give resources a few secs to load, i’m in trouble.
I currently do a stub call to vertexAttribPointer for the shader with the most attributes to circumvent this.

I’ve seen all these on multiple browsers (Firefox, Chrome, Opera, Safari).

Any thoughts?

Depth buffer
I think you can turn on/off read/write specifically using another command if that’s what you’re looking for.

Shader variables
Varying?! You can access Uniform and Attribute from javascript but varying is only passed from VSH to FSH.