Re: [AD] X vsync emulation (timing)

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Peter Wang wrote:
Chris wrote:
True.. but I think the timer should be designed so it attempts to increment at the speed of the reported refresh rate, instead of a flat 100Hz.

How do you propose to do that?

Perhaps something along the lines of:

void x_retrace_proc(void)
{
   static u_int64_t x_vsync_hack = 0;
   static unsigned int last_retrace_count = 0;

   x_vsync_hack++;
retrace_count = (unsigned int)(x_vsync_hack * (u_int64_t)refresh_rate / 100LL);

   if(retrace_count != last_retrace_count)
   {
      last_retrace_count = retrace_count;
      if(retrace_proc)
         retrace_proc();
   }
}

? You'd need to install that as a bg_func and make sure the timer that updates retrace_count is never installed, but it should work.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/