gl.glClearColor(0f, 0f, 0f, 1.0f);
How do I read it? As:
set clear color
or
clear the color
?
3.7 Color. We use glColor function to set the foreground color, and glClearColor function to set the background (or clearing) color.
The question was about the alpha parameter in glClearColor and implicitly the meaning of a framebuffer's alpha channel I general. Alpha is a user-defined property which can mean transparency, opacity or something completely different, depending on which blend equations are chosen.
The fourth parameter indicates the trasparency. The alpha is opacity, not transparency. This means that when it is 0, you can't see it at all. When it is 1, you can see it completely.
GL_COLOR_BUFFER_BIT. Indicates the buffers currently enabled for color writing. GL_DEPTH_BUFFER_BIT. Indicates the depth buffer.
@Mikola's answer is correct, but I'll emphasize it a bit: calling glClearColor
does not clear anything. It usually takes the value you've specified, and writes it to a register on the graphics card. Only later when you call glClear
, with COLOR_BUFFER_BIT
, does the buffer actually get cleared to the color you specified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With