Allegro timer bug?

You can talk about almost anything that you want to on this board.

Moderator: Moderators

Post Reply
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Allegro timer bug?

Post by Zepper »

- It works perfectly for 50, 55... but not with 60 or a bit less. The number of frames per second isn't constant, but around 62~63. I wonder why...

Code: Select all

install_int_ex(gfx_timer_proc,BPS_TO_TIMER(60));
- Yes, I need 60 FPS, but it doesn't work, keeps displaying 62~63 FPS.
User avatar
hap
Posts: 355
Joined: Thu Mar 24, 2005 3:17 pm
Contact:

Post by hap »

Maybe its timer runs at cycles of 1ms?
What does BPS_TO_TIMER(x) do?
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

Code: Select all

      SECS_TO_TIMER(secs)  - give the number of seconds between
                             each tick
      MSEC_TO_TIMER(msec)  - give the number of milliseconds
                             between ticks
      BPS_TO_TIMER(bps)    - give the number of ticks each second
      BPM_TO_TIMER(bpm)    - give the number of ticks per minute
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Allegro timer bug?

Post by tepples »

Fx3 wrote:- It works perfectly for 50, 55... but not with 60 or a bit less. The number of frames per second isn't constant, but around 62~63. I wonder why...

Code: Select all

install_int_ex(gfx_timer_proc,BPS_TO_TIMER(60));
- Yes, I need 60 FPS, but it doesn't work, keeps displaying 62~63 FPS.
Under what operating system?

60.0 Hz is 16.67 milliseconds per cycle. 16.0 milliseconds per cycle is 62.5 Hz. Not all operating systems make microsecond resolution timers available to processes running as a limited user. If you make a limited test case and send it to the Allegro team, someone with more knowledge of the program's insides might be able to make a more detailed diagnosis.
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

Windows XP.
User avatar
kyuusaku
Posts: 1665
Joined: Mon Sep 27, 2004 2:13 pm

Post by kyuusaku »

Do you need to use Allegro or can you use Windows' timer(s)?

I find QueryPerformanceCounter() + Sleep() to work very well.
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

I think the point of using only Allegro is to be cross-platform.
randilyn
Posts: 16
Joined: Tue Mar 28, 2006 6:22 am

Post by randilyn »

High-resolution timers don't work on some laptops and whatnot. Don't use them unless you have some sort of fallback timing solution, such as threads (which is how Allegro does timing in all versions up to and including 4.2).

Allegro 4.3 and onward is a completely separate codebase with a completely different API and much better design goals.
<3
User avatar
Zepper
Formerly Fx3
Posts: 3264
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

Yes, and...?
Post Reply