Using a depth function based on a constant

Is it possible to set a depth function like equal C with C being a constant when rendering a mesh?

I would like to render a skybox at the end of my scene but only where nothing has already been drawn to the frame buffer. So, the easiest thing would be to set the depth function for the skybox to be equal 1.

It must be possible to do this with a stencil buffer, but it seems overkill to me.


where xxx can be the value of the gl constant: eg : 0x0202 from WebGL constants - Web APIs | MDN

The function allows to change the comparison to use when testing the current fragment depth with the current value in the depth buffer, but what I would like to achieve is telling the engine not to use the current fragment depth to do the check but instead base the checking on the current value in the depth buffer and a constant value: the checks is ok if the current depth value is 1.

So, I would do engine.setDepthFunction(EQUAL), but I would need another function call to tell openGL to perform the check by taking the current z value in the depth buffer and test it against 1 instead of the current fragment z value.