Well, I recently looked in the OpenGL docs, and I realized that glClear(GL_COLOR_BUFFER_BIT) clears the color buffer using a color set by glClearColor. According to theCodingUniverse on YouTube, glClearColor should be called before glClear. Is this correct? I don't think it is, but why does it still work then? Will clearing the buffer and then setting the color produce any bad results?
1 Answers
1
votes
No difference really. If you set the clear color after you clear the color buffer then opengl remembers it and the next time the buffer is cleared (the next frame) it will be cleared to that color. So the first frame will have a different clear color, which doesn't really matter.
Although for the sake of practice I would put it before.
glClearColor (...). Like everything in OpenGL, the clear color has a default value (0, 0, 0, 0) in this case. Also, like everything else in OpenGL you only have to set the value once and it will remember it for you. Unrelated, but when did YouTube become a legitimate source of information? :P - Andon M. ColemanglClear (...). - Andon M. Coleman