|
Problem with timer - blocked to 64 FPS ?! |
anto80
Member #3,230
February 2003
|
Hello all, I have a problem with timers and i am sure i have done a basic mistake... I have a timer named 'wait_proc' for the game logic. I want my program to display the game as soon as possible, but I don't need to draw it if nothing in the game logic has changed. So normally the max FPS should be 120. I have another timer named 'fps_proc' for the fps count, called every second, and which store the number of frames that have been counted this second. The problem is that the display is 'blocked' to 64 FPS. However it doesnot come from the display performance because if I force the program to draw, even if nothing in the game logic has changed, i get something like 1000 FPS ! Thank you in advance ! My timer installation: allegro_init(); install_allegro_gl(); install_timer(); install_keyboard(); install_mouse(); // Install my timers /////////////////////////////////////////////////// LOCK_VARIABLE(fps); LOCK_VARIABLE(frame_count); LOCK_VARIABLE(actual_tic); LOCK_FUNCTION(fps_proc); LOCK_FUNCTION(wait_proc); install_int(fps_proc, 1000); install_int_ex(wait_proc, BPS_TO_TIMER(120)); Timer code:
The main loop:
___________ |
A J
Member #3,025
December 2002
|
vsync ? ___________________________ |
Frank Drebin
Member #2,987
December 2002
|
yes what the hell is this ? |
anto80
Member #3,230
February 2003
|
A J said: vsync ? A J: No, because like i said: Quote: if I force the program to draw, even if nothing in the game logic has changed, i get something like 1000 FPS !
Yes Frank, it seems that I'm getting the same problem. ___________ |
Neil Walker
Member #210
April 2000
|
two things that probably won't make a difference: 1. Maybe actual_tic has increased beyond nprevupdatetime during a draw loop and doesn't get caught until the next? I do it like this: And in the timer handler increment actual_tic 2. Maybe the keyboard_poll is doing something. Try removing it. I don't think there are any platforms at the minute that need keyboard polling. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Frank Drebin
Member #2,987
December 2002
|
as i pointed out in my post even this program won't get more than 64 fps and i don't see any errors here:
|
Kitty Cat
Member #2,815
October 2002
|
Allegro's timers are not accurate. If you want more accuracy, you'll have to find another method. I've posted my timer class before, which makes it rather simple to keep track in a method similar to Allegro's. It doesn't take any hit for having one or multiple timers since it runs off the system's timing stuff, and on the right platforms it'll use high-accuracy timing. If you want me to repost it, let me know. I'll even show you how to use it (which as I said, is simple and almost Allegro-like). -- |
Neil Walker
Member #210
April 2000
|
Assuming windows, what happens if you use the software directx driver or GDI, GFX_DIRECTX_SOFT/GFX_DIRECTX_GDI Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Epsi
Member #5,731
April 2005
|
I had this problem when I was coding scripts with "mIRC", a windows software. Basically it's because the default Windows timer (the one which returns "ticks") has a resolution which is limited to +- 15 ms, wich gives a result of max 65 times per second. So with my games I could not "loop" a logic with a timer more than 64 times per second. In this case I don't really understand why, but it seems that Allegro's timer suffers from the same problem... The solution for me was to use a high resolution timer (check http://www.unb.ca/metrics/software/HRtime.html) I hope that this can help... P.S: What this your OS, and what version is it ? ___________________________________ piccolo: "soon all new 2d alegro games will be better. after i finsh my MMRPG. my game will serve as a code reference. so you can understand and grab code from." |
Audric
Member #907
January 2001
|
KittyCat said: Allegro's timers are not accurate. If you want more accuracy, you'll have to find another method.
Aye, it's a sad world for coders... Last time I managed flawless scrolling (panning) was by using double buffer and vsync() for timer, on DOS, and it could run on anything... |
anto80
Member #3,230
February 2003
|
I'm running Win XP SP 2. KittyCat, I don't know what is the Timer class you are talking about. Could you please show me where it is and how to include it, and use it in my prog? ___________ |
Audric
Member #907
January 2001
|
Strangely enough, what you're asking is the first result of a search on the word "Timer", posted by "Kitty Cat". |
Frank Drebin
Member #2,987
December 2002
|
epsi, |
Epsi
Member #5,731
April 2005
|
Frank Drebin: no it's exactly the case: rest(1) will rest for 15ms istead of 1 (assuming it uses Windows basic timer), thus limiting you to 64 fps. If you remove it, you get rid of the timer effect and you get "no limit" fps. ___________________________________ piccolo: "soon all new 2d alegro games will be better. after i finsh my MMRPG. my game will serve as a code reference. so you can understand and grab code from." |
Vasco Freitas
Member #6,904
February 2006
|
I have the same problem. |
Frank Drebin
Member #2,987
December 2002
|
so does it mean that i can't run my timer accurate and give some cpu-cycles to the system at once? |
Neil Walker
Member #210
April 2000
|
Richard Phipps has set a link to the windows timer code he uses, haven't a clue what to search for in the site is though, may be if he reads this he might post the link Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
GullRaDriel
Member #3,861
September 2003
|
QPC,GTOD thread for HighRes Timer. Here is my wrapper, you can find the full Library Documentation in my sig: part of common.h
part of common.c:
"Code is like shit - it only smells if it is not yours" |
|