PDA

View Full Version : Sleep in openGL



enigmatic
11-11-2008, 11:18 PM
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

ZbuffeR
11-12-2008, 12:56 AM
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
11-12-2008, 12:40 PM
yes double buffering is enabled.
I am using glut

enigmatic
11-12-2008, 02:10 PM
I tried it with single buffering also. I get the same problem

dletozeun
11-13-2008, 08:50 AM
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();

enigmatic
11-13-2008, 05:24 PM
It works now, thanks for the help Zbuffer and dletozeun. Appreciate it.

chign
05-13-2010, 04:51 PM
you mentioned
3) wait and draw nothing
how can i wait for a specific time (i mean define that time) and draw nothing??