leif icon indicating copy to clipboard operation
leif copied to clipboard

glClearColor in the documentation

Open robindegen opened this issue 6 months ago • 0 comments

The documentation mentions the following code:

while(!glfwWindowShouldClose(window)) { glClear(GL_COLOR_BUFFER_BIT); glClearColor(0.1f, 0.1f, 0.1f, 1.0f);

}

glClear clears the color buffer to the color configured with glClearColor, so constantly setting it after clearing is incorrect.

It means your very first frame will actually be just black. After that every frame after you're changing the color value to the same value, which basically only costs time and does nothing. glClearColor should be called only once outside of the loop.

robindegen avatar Jun 06 '25 08:06 robindegen