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.
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 … ?
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:
draw your square
swap and and refresh screen:
glutSwapBuffers();
glutPostRedisplay();
wait and draw nothing
draw your triangle
swap and and refresh screen:
glutSwapBuffers();
glutPostRedisplay();