Exhibit #4: Clearing the Screen
What We Did
- Let's get back to WebGL, which we hope to use throughout the semester.
- We clear the screen (i.e. our canvas) with the command
gl.clear(gl.COLOR_BUFFER_BIT)
.
- Here, we tell WebGL to clear the color buffer.
- The command also accepts other arguments, but we talk about them later in the course.
- Use
gl.clearColor(r, g, b, a)
to set the color use to clear the screen.
- The last argument is the alpha channel, which will have an effect when we deal with blending.
For now, it doesn't have any effect on the screen we see.
- All arguments range from 0 (darkest) to 1 (brightest).