In my C++ graphics application using OpenGL and GLUT, I want to enable depth testing via
glEnable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
However, these two lines of code clear my screen, which is now just the clear color. I was wondering why.
I am just supposed to have a few primitive solid spheres and cubes.
Sounds like you’ve forgotten to clear the depth buffer and are thus failing the depth test due to whatever preexisting garbage is in the depth buffer memory. Try to add GL_DEPTH_BUFFER_BIT to your glClear() call, like so:
Good luck!