glClear and framebuffers

In webgl, does gl.clear only clear the currently bound framebuffer? Also, does gl.clearColor/gl.clearDepth set the clear color/depth for the currently bound framebuffer, or does it simply affect the next call to gl.clear?

I’m asking because I can’t figure it out by reading the opengl es 2.0 reference, and I think buffer clearing issues might be why my deferred shading system is not working properly.

Yes. Which buffers within that framebuffer are cleared is dictated by the buffer writemasks. And which parts of each enabled buffer are cleared is a function of the scissor test, dithering, and the pixel ownership test.

Also, does gl.clearColor/gl.clearDepth set the clear color/depth for the currently bound framebuffer, or does it simply affect the next call to gl.clear?

These aren’t per-framebuffer state. These are global state. So the latter. It’s not completely obvious, but you can see this by looking in the state tables at the back of the spec. COLOR_CLEAR_VALUE, DEPTH_CLEAR_VALUE, and STENCIL_CLEAR_VALUE are in the framebuffer control section, not the per-framebuffer state section. The Get call isn’t a framebuffer query, but a global query.

I’m asking because I can’t figure it out by reading the opengl es 2.0 reference, and I think buffer clearing issues might be why my deferred shading system is not working properly.

Thanks a lot man