al_flip_display() forces 60fps?

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

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?


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.


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

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.



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:

Thread #614545. Printed from