Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does gl.glClearColor do?

gl.glClearColor(0f, 0f, 0f, 1.0f);

How do I read it? As:

set clear color

or

clear the color

?

like image 875
riant09 Avatar asked Jun 26 '11 19:06

riant09


People also ask

What is the difference between glColor () and glClearColor ()?

3.7 Color. We use glColor function to set the foreground color, and glClearColor function to set the background (or clearing) color.

What is Alpha in glClearColor?

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.

What is the significance of 4th parameter in glClearColor?

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.

What is Gl_color_buffer_bit?

GL_COLOR_BUFFER_BIT. Indicates the buffers currently enabled for color writing. GL_DEPTH_BUFFER_BIT. Indicates the depth buffer.


1 Answers

@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.

like image 147
Jerry Coffin Avatar answered Nov 06 '22 09:11

Jerry Coffin