Black and white mask

I’m learning OpenGL for a new project. I need to create a completely black and white mask created by clipping the view at a specified distance. What’s the best way to do that? Where should I focus my reading and training to hit the ground running?

Basically, I’m trying to create multiple masks at set clipping distances, and subtracting the masks from one another. Each mask will represent a thick slice of visible surface between two clipping distances. When stacked, they should all form a complete mask of all visible surfaces. Make sense?

It sound like it would be a good use of stencil system.
Clear stencil to 0, set your projection with desired clipping, render while writing stencil=1.
You have you first mask.
Then setup the second slice, writing stencil=2. Etc for each slice.
Then to make the mask appear as black and white, clear color with white (keep stencil), use stencil test so that only stencil=1 passes.
Draw a big black quad.
And voilà your first mask, minus all the others.