Sleep in openGL

I having trouble in sleep or delay operation in openGL. What am i trying to do is draw a square wait or sleep for a second then draw a triangle. How should i accomplish this task?

I tried the sleep function but what happens is that it sleeps first for 1 second then it draw the square and triangle simultaenously.

I am using the visual c++ environment to build openGL.

thanks

With double buffering (with you should use), everything you draw is on the back buffer, it is then shown on the front buffer after a swap.
Do you use glut, or pure win32/wgl, of GLFW … ?

yes double buffering is enabled.
I am using glut

I tried it with single buffering also. I get the same problem

enigmatic> This is not related to buffering mode. What Zbuffer said is that “everything you draw is on the back buffer, it is then shown on the front buffer after a swap.”

So you need to:

  1. draw your square
  2. swap and and refresh screen:
    glutSwapBuffers();
    glutPostRedisplay();
  3. wait and draw nothing
  4. draw your triangle
  5. swap and and refresh screen:
    glutSwapBuffers();
    glutPostRedisplay();

It works now, thanks for the help Zbuffer and dletozeun. Appreciate it.

you mentioned

3) wait and draw nothing

how can i wait for a specific time (i mean define that time) and draw nothing??