Hello guys,
I hope you're all doing well.
I was wondering what's the utility of using glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT).
I read about glClear(GL_COLOR_BUFFER_BIT) and how it cleans the color of the window and sets it to the value specified by glClear().
But I don't really get what does glClear(GL_COLOR_BUFFER_BIT) do. I read that for example GL Less test passes if the incoming pixels depth value is less than the stored z value. Does that mean if I write glClearDepth(1.0) the test passes only if all the incoming pixels depth values are less than 1 and the objects are then rendered ? Thing is I commented glClearDepth(1.0) in my code and nothing changed, the scene was rendered perfectly and nothing was missing.
But before drawing, I enabled the depth test of course.
Another thing is that I tried to comment glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) in my code and ran it, everything seemed to work fine, the scene didn't disappear so why use that line when it doesn't really influence the scene. ?
SO to sum up why do I have to use glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) and glClearDepth(1.0) when rendering a scene ?
Thank you all.