I got flickering even I swapped the buffers and enabled depth test, what else could be the problem? I drew two object s, one is flickering , the other is not, why ? I appreciate any help.

try to use glFlush()/glFinish() before swapping buffer …

It still doesn’t work. What should I do next?

Are you sure you’re not clearing the color buffer or the depth buffer before drawing the second object? Alternatively, are you sure you’ve got double buffering enabled properly? Did you remember to clear both the color and the depth buffers between frames?

If you are on windows and not using glut then it could be the WM_ERASEBACKGROUND message. I think you had to return TRUE to tell windows not to erase your background!