Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » vsync with OpenGL

This thread is locked; no one can reply to it. rss feed Print
vsync with OpenGL
ph03nix
Member #15,028
April 2013
avatar

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
Member #1,424
July 2001

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

--- Kris Asick (Gemini)
--- http://www.pixelships.com

ph03nix
Member #15,028
April 2013
avatar

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
Member #7,827
October 2006
avatar

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.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

ph03nix
Member #15,028
April 2013
avatar

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

Kris Asick
Member #1,424
July 2001

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.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

SiegeLord
Member #7,827
October 2006
avatar

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).

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

ph03nix
Member #15,028
April 2013
avatar

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
Member #476
June 2000
avatar

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.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Elias
Member #358
May 2000

ph03nix said:

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

Indeed. Luckily this is only with WGL.

--
"Either help out or stop whining" - Evert

Kris Asick
Member #1,424
July 2001

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.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

SiegeLord
Member #7,827
October 2006
avatar

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.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Elias
Member #358
May 2000

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.

--
"Either help out or stop whining" - Evert

Go to: