put value in the stencil buffer

So, I’ve got a FBO with a stencil buffer. How do I put values in the stencil buffer with modern openGL (just shaders).

Let’s say I have a trangle or quad I want to render to the stencil buffer with value V. How would I go about that? Do I need a specific shader? There’s no specific openGl command that lets you just write values without a shader? kind of like glScissors?

Use glStencilFunc(GL_ALWAYS, V, ~0U) to set the reference value to V, glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE) to cause the reference value to be copied to the stencil buffer when the depth and stencil tests pass, then draw the primitives.

It doesn’t matter whether shaders are used as a shader cannot directly affect stencil buffer updates.