how to use timer with x window

I am using glx to develop opengl program, how can I add a timer to my opengl window so that I can implement an animation?

this is a cross post. see the same post in the other forum.

If you need a high resolution timer instead of gettimeofday do you find one here for Intel chips

If you are using Xt do you probably want to use XtAppAddTimeOut that works in a similar way as GLUT timeouts. Some more information is here

Standard C Library Functions                     gettimeofday(3C)

     gettimeofday, settimeofday - get or set the date and time

     #include <sys/time.h>

     int gettimeofday(struct timeval *tp, void *);

     int settimeofday(struct timeval *tp, void *);

     The gettimeofday()  function  gets  and  the  settimeofday()
     function  sets  the system's notion of the current time. [i]The
     current  time  is   expressed   in   elapsed   seconds   [b]and
     microseconds[/b][/i] since 00:00 Universal Coordinated Time, January
     1, 1970. The resolution of  the  system  clock  is  hardware
     dependent;  the time may be updated continuously or in clock

microseconds == 10^-6

[This message has been edited by john (edited 03-20-2002).]

Of course, using GLFW makes this much easier. The glfwGetTime() function returns the time in seconds as a doubple precision floating point value. It supports both X11 and Windows. Under Unix, the timer is implemented with gettimeofday or RDTSC (CPU cycle counter on x86 CPUs), and under Windows the timer is implemented with a “performance counter”, GetTickCount or RDTSC.

On the GLFW pages you can also find some tutorials, where you can find examples of how to use the timer for animation.

[This message has been edited by marcus256 (edited 03-21-2002).]

Yes, gettimeofday is giving the time in microseconds and that is not enough in all cases. For animations is it of course more than enough but not for everything else. The programmer that did the highres timer also explained why. Perhaps should someone post the man page to him and explain that microseconds== 10^-6.