Usually , the glClear is the first function call in your display function. Before any pixel is write to the screen, the screen has to be prepared, for example set the background color. Actually, glClear will use a color specified by glClearColor() to clear the screen, its like set the background color of the canvas.

The prototype of glClear

void glClear(GLbitfield mask); 
Clears the specified buffers to their current clearing values.

The parameter is a bit wise mask specifies which buffer needs to be cleared. Just like glClearColor, other buffers can be cleared with a specified value by calling glClearDepth, glClearAccum, glClearStencil.

GL_COLOR_BUFFER_BIT: Clears the color buffer. If you don't clear the color buffer, all pixels drew in every frame will stay on the screen.

opengl color buffer

GL_DEPTH_BUFFER_BIT: Clears the depth buffer. The depth buffer stores a depth value for each pixel. Depth buffer also called z-buffer.

GL_ACCUM_BUFFER_BIT:Accumulation Buffer used to perform antialiasing, motion blur. A series of drawing accumulating in accumulation buffer, and write back to color buffer when the process finished.

GL_STENCIL_BUFFER_BIT: The stencil buffer, like a cardboard stencil, makes the drawing only effect portion of the entire screen. Its very useful when only part of the screen needs redraw, for example, a window of a car. When the car move, only the pixels inside the window needs changes, other pixels needs to be protected.