vsync with OpenGL
ph03nix

I want to have vsync and OpenGL enabled in my allegro game.

With vsync set to require, if I set the display flag to ALLEGRO_OPENGL_3_0 or ALLEGRO_DIRECT3D it works fine, but if I set it to ALLEGRO_OPENGL vsync is always disabled. Why is this?

Without vsync enabled, my game stutters periodically, even though it runs well within 60 fps.

I'm using Allegro 5.0.10 on Windows 7

Kris Asick

Check your video card driver settings. Chances are they're overriding Allegro's attempts to vsync. If that's not it, it could be you simply need to update your drivers. :P

ph03nix

My video card settings are all default, and the drivers are up to date. It only effects opengl, not even opengl 3.0 (I'm not entirely sure what the difference is) ???

SiegeLord

It's a bug in Allegro. Needs effort to be put into it, but nobody has as of yet. The workabout is to manually call al_wait_for_vsync.

ph03nix

al_wait_for_vsync returns false and does nothing. Is this the only way I can achieve vsync with ALLEGRO_OPENGL?

Kris Asick

I haven't actually tried this yet but are there any drawbacks to going with OpenGL 3.0 in Allegro 5? I mean, not a lot of people anymore are going to be running video cards that can't support it and you could always just run a check ahead of time to see if it's supported by the end user's video card and go with the regular OpenGL interface if it's not.

SiegeLord

I don't think there are any as long as you don't choose forward compatible option. If you do, some things will break (e.g. the primitives addon).

ph03nix

I was curious about the GL versions, so I printed them under ALLEGRO_OPENGL and ALLEGRO_OPENGL_3_0. In ALLEGRO_OPENGL it's 3.1.0, in ALLEGRO_OPENGL_3_0 it has no version, it doesn't seem to be using openGL at all!

So is it impossible to have vsync with openGL? That seems like a terrible flaw to me, it makes openGL unusable...

Thomas Fjellstrom

Hm, don't you have to specify ALLEGRO_OPENGL AND ALLEGRO_OPENGL_3_0 ? For some reason I'm thinking the 3_0 one is a modifier for ALLEGRO_OPENGL.

Elias
ph03nix said:

That seems like a terrible flaw to me, it makes openGL unusable...

Indeed. Luckily this is only with WGL.

Kris Asick

Mind you, vSync in OpenGL mode should work fine without calling al_wait_for_vsync() if the graphics drivers themselves are set to force vSyncing on.

Though I am confused somewhat as every system I've tested my current project on vSynced perfectly fine in OpenGL mode, mind you the last major testing I did with it was with Allegro 5.0.8. Now I'm curious if the bug Siege is referring to is something that recently ended up getting introduced or if it's related to specific hardware.

SiegeLord

It has never worked for me without al_wait_for_vsync, Linux or Windows. It's probably a hardware issue, but that's not an excuse.

Elias

al_wait_for_vsync should not be used though (except for special purposes) because in most cases you will wait twice then and half frame rate.

Thread #613500. Printed from Allegro.cc