The depth-buffer test discards a fragment if a depth comparison fails; glDepthFunc specifies the comparison function. If stenciling is enabled, the result of the depth comparison also affects the stencil buffer update value.