- Online Community Forums » Programming Questions » al_flip_display() forces 60fps?

This thread is locked; no one can reply to it. rss feed Print
al_flip_display() forces 60fps?
Member #12,503
January 2011

So when I ran the piece of code below I noticed that the fps is locked at 60.
And I tried forcing vsync off, but it still remained at 60. I know there's no point in having an fps higher than your refresh rate, but I'm still curious why this happens.

1#include <iostream> 2#include <allegro5/allegro.h> 3#include <allegro5/allegro_primitives.h>> 4 5int main(int argc, char **argv) 6{ 7 int frames; 8 double fps, startTime, elapsedTime; 9 10 al_init(); 11 al_init_primitives_addon(); 12 13 ALLEGRO_DISPLAY *display = al_create_display(800, 600); 14 ALLEGRO_COLOR black = al_map_rgb(0,0,0); 15 16 startTime = elapsedTime = al_get_time(); 17 fps = 0; 18 frames = 0; 19 20 while(true) 21 { 22 al_clear_to_color(black); 23 al_flip_display(); 24 25 frames++; 26 elapsedTime = al_get_time() - startTime; 27 28 fps = frames/elapsedTime; 29 std::cout << "FPS: " << fps << "\n"; 30 } 31 return 0; 32}

Chris Katko
Member #1,881
January 2002

1) Where do you set ALLEGRO_VSYNC?


void al_set_new_display_option(int option, int value, int importance)

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.

2) Is your videocard driver set to force vsync?

“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

Member #12,503
January 2011

I set al_set_new_display_option(ALLEGRO_VSYNC, 2, ALLEGRO_REQUIRE) before creating the display.

I'm on kubuntu, I haven't installed any drivers yet so I'm using "X.Org X server -- Nouveau display driver" whatever that is, and I have no idea how to check if it's forcing vsync.

Member #2,229
April 2002

According to the source code you just showed us, you are not setting the vsync at all.

I have used Allegro 5 in my own game and gotten much higher than 60FPS. Things that have effected it are the event timer settings (or any timer settings which effect speed), and system driver default settings.

Personally, I usually have my event timer set to 60FPS so it never goes higher, but I have experimented and gotten much more, so in answer to your question, no, al_flip_display() does not force 60FPS.

Arthur Kalliokoski
Second in Command
February 2005

I was just googling it, and it looks like you can enable/disable vsync on nouveau by editing your xorg.conf file.

Section "Device"
    Identifier "nvidia card"
    Driver "nouveau"
    Option "GLXVBlank" "true"

AFAICS, set the fourth line to say

Option "GLXVBlank" "false"

(or possibly "off").

This xorg.conf file is found in various places, in slackware it's /etc/X11/xorg.conf, Debian (and possibly xubuntu) has it in


BTW, could you try the build/examples/ex_gldepth to see if A5 works correctly with the depth buffer yet? It was messing up a few years ago.


“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Member #12,503
January 2011

Sorry for the slow reply, I had surgery today and had my gallbladder removed because of gallstones. (I had 9 of them :O)

I know I'm not forcing vsync in the piece of code I showed. But like I said earlier I have tried forcing it with al_set_new_display_option(ALLEGRO_VSYNC, 2, ALLEGRO_REQUIRE)

@Arthur Kalliokoski

Sure thing, I'll try to run it a bit later today.

edit: I ran ex_gldepth and here's the result:

Go to: