Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » 60 FPS limit in linux?

This thread is locked; no one can reply to it. rss feed Print
60 FPS limit in linux?
Frank Drebin
Member #2,987
December 2002
avatar

I noticed that when running any Allegro 5 program in linux, I can't get more than 60 FPS - even though al_clear_to_color(al_map_rgb(0,0,0)) only is called and nothing is drawn. How does that come?

BTW: I am using the Allegro 5 version that can be found in the Ubuntu PPAs

Eric Johnson
Member #14,841
January 2013
avatar

1. Are you using a timer? If so, what is it set to?

2. How are you measuring FPS?

3. Is v-sync enabled?

4. Can you post the code?

Frank Drebin
Member #2,987
December 2002
avatar

3. I don't know. At least I didn't enable it myself...
1., 2., and 4.:

#SelectExpand
1#include <stdio.h> 2#include <allegro5/allegro.h> 3 4#define duration 5 5 6int frames=0; 7bool quit=0; 8 9int main(int argc,char** argv) 10{ 11 if (!al_init()) return -1; 12 13 ALLEGRO_DISPLAY* display=al_create_display(640,480); 14 if (!display) return -1; 15 16 ALLEGRO_EVENT event; 17 ALLEGRO_EVENT_QUEUE* queue=al_create_event_queue(); 18 ALLEGRO_TIMER* timer=al_create_timer(duration); 19 al_start_timer(timer); 20 al_register_event_source(queue,al_get_timer_event_source(timer)); 21 22 while (!quit) 23 { 24 if (al_wait_for_event_timed(queue,&event,0)) quit=1; 25 26 if (al_is_event_queue_empty(queue)) 27 { 28 al_clear_to_color(al_map_rgb(0,0,0)); 29 al_flip_display(); 30 frames++; 31 } 32 } 33 34 printf("FPS: %i\n",frames/duration); 35 36 al_destroy_display(display); 37 al_destroy_event_queue(queue); 38 al_destroy_timer(timer); 39 40 return 0; 41}

Edgar Reynaldo
Member #8,592
May 2007
avatar

ALLEGRO_VSYNC
Set to 1 to tell the driver to wait for vsync in al_flip_display, or to 2 to force vsync off. The default of 0 means that Allegro does not try to modify the vsync behavior so it may be on or off. Note that even in the case of 1 or 2 it is possible to override the vsync behavior in the graphics driver so you should not rely on it.

Frank Drebin
Member #2,987
December 2002
avatar

Thanks - didn't know that vsync was enabled...

Chris Katko
Member #1,881
January 2002
avatar

You can also configure VSYNC on the driver level.

There's at least two ways, google it. I've posted before in these forums but I don't recall the command line arguments. nVidia has one set. And there's one universal set too. It's like VSYNC=1/2/3/4. With 4 maybe being adaptive vsync.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Go to: