<- previous index next ->
Suppose you want to update the display at a uniform rate, independent of the speed of the computer. Assuming the computer you are using is reasonably fast. initialize your program loop start = get_the_time cause_display_update repaint(); in Java glFlush(); glutSwapBuffers(); in OpenGL do your calculations that will be used by your paint or display routine. (Physics, motion, etc.) loop now = get_the_time if ( now > start + your_update_time ) break end loop end loop The above allows for a reasonable variation in the time to do your calculations. Double buffering is desirable for smooth motion. To get the time in "C", unfortunately may be coarse. time_cpu.c To get the time in Java, milliseconds. time_of_day.java For a simple delay in Java, see "sleep" in thread at end. body3.java
<- previous index next ->