View Full Version : Sleep in openGL
enigmatic
11-11-2008, 10: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-11-2008, 11:56 PM
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, 11:40 AM
yes double buffering is enabled.
I am using glut
enigmatic
11-12-2008, 01:10 PM
I tried it with single buffering also. I get the same problem
dletozeun
11-13-2008, 07: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, 04: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??
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.