Hello
After switching from Allegro 5.1 to Allegro 5.2.4
And using binaries in this distribution for Visual C/C++
https://www.nuget.org/packages/Allegro/
I discovered a problem in the (Timer) !
Where the timer event is always fired without waiting for the time to pass.
I'm using the timer to control the drawing at (60 FPS)
With Allegro 5.1 (No Problem) - I get the expected behavior (60 FPS)
While with Allegro 5.2.4 - I get over 350 FPS !
The code looks like this (In Ring programming language - Just normal calls to Allegro)
Greetings,
Mahmoud
You mean you set FPS to 60, and measured the actual frames per second, and it was 350? Please create a simple test in C that demonstrates your problem. We need a Minimal, Complete, Verifiable Example.
]]>I haven't compiled the code but my guess is: ALLEGRO_TIMEOUT is an absolute time so the first call to al_wait_for_event_until will wait 60ms but the ones after will be zero. Probably al_wait_for_event_timed is what you want
Hope that helps
Pete
Hello Edgar
Yes, This is what I mean, and I will attach a C program
Hello Peter
Yes, the problem is related to ALLEGRO_TIMEOUT
(1) The Ring code uses a pointer for the ALLEGRO_TIMEOUT and doing the initialize operation just one time! ---> (I fixed that to avoid the problem, Thanks )
(2) It was also a change in behavior between Allegro 5.1.11 and Allegro 5.2.4 where the problem doesn't exist in Allegro 5.1.11
Attached the C source code, written just for testing to demonstrate the change.
Greetings,
Mahmoud
ALLEGRO_TIMEOUT timeout ; // We can ignore the next line in Allegro 5.1.11 (But we can't do that for Allegro 5.2.4) // al_init_timeout(&timeout, 0.06); al_wait_for_event_until(event_queue, &ev, &timeout);
Take notice that 'timeout' is UNINITIALIZED if you don't call al_init_timeout.
Now if you call al_init_timeout, and wait until the timeout returns, it SHOULD remain the same as far as timeout value goes. If it changes before the next call to al_wait_for_event_until, that's a bug in Allegro, or at the least its undocumented behavior.
The fact that it works in 5.1.11 makes no difference. 5.1 is VERY old as far as versions go. You should be using 5.2.4 if you can.
]]>This is probably due to this bug being fixed:
https://github.com/liballeg/allegro5/issues/593
Before it was fixed, even though your timeout was effectively 0 (being set in the past), al_wait_for_event_until would still wait for an event to show up.
]]>But, if you've got a timer firing every 60ms, you don't need a timeout at all because the timer event do the same thing (or am I missing something?)
And, if you do want to use al_wait_for_event_until you should check the return value; if it returns due to the timeout, the event will be invalid.
]]>