OpenGL and Vsync

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: OpenGL and Vsync

Post by qpHalcy0n »

Have you cut SDL out of the loop? Have you tried any of the things I said to try?
N64vSNES
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Thu Aug 12, 2010 11:25 am

Re: OpenGL and Vsync

Post by N64vSNES »

qpHalcy0n wrote:Have you cut SDL out of the loop? Have you tried any of the things I said to try?
Dude I've been crawling through the internet since I started developing EQ, I've tried most of the things you said before this thread.

I've tried a few other libaries such as GLUT and I'm not having issues with that, but am I really going to rewrite half of my engine just because of this one little issue?
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: OpenGL and Vsync

Post by qpHalcy0n »

Heh, you're right. The issue IS NOT glut. You've missed the point of my post then :P

The issue is not glut because glut is horrendously outdated and has never handled vsync correctly to begin with. Like I said, if you're writing an engine around these frameworks, be it glut, SDL, or SFML you just MUST be prepared to encounter little issues like this for which there appear to be no answers. If you're still using SDL your best bet is to frequent their forums and be a part of that community and there may indeed be some new answer for the vsync issue. However, so far that I'm aware they have not correctly implemented this yet.

So what OS is this under? Who is your video driver vendor? Are you still using SDL?
You must understand that OpenGL has absolutely ZERO concept of vsync, it does not know what that is. VSYNC is exposed as an EXTENSION to the API which must be fetched from the video driver. This is why all of these questions are pertinent because for example, under Win7, the WDM actually already has vsync enabled by default. You have to force it off in your app. In X11 (Linux) it's off by default and you force it on w/ glxSwapIntervalSGI. Secondly, if you're on nVidia, they've had numerous problems w/ their Vsync functionality on the driver w/ OpenGL. You also need to be sure that you dont have it forced on in your driver.

What am I saying? I'm saying that Vsync w/ OpenGL is a MASSIVE mess simply because it's not really part of the spec at all. Some OS's force it on, some don't. Some drivers handle the extensions correctly, some don't. Sometimes you can force it on, sometimes you can't. This is only made worse by SDL because their implementation has always been pretty bad.

Can you do vsync yourself?? Yes! Absolutely you can. You need to time your app and run the main loop off a timer. If you're stuck on a frame boundary then you need to wait until you actually call finish and flush the pipeline. Is this the best way? Perhaps, perhaps not. Either way, you shouldn't have to rewrite your entire engine to do this. If you do, then you will want to look at the design concept.
N64vSNES
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Thu Aug 12, 2010 11:25 am

Re: OpenGL and Vsync

Post by N64vSNES »

Yes its still SDL and what I meant was I wrote a test application in glut to test the Vsync and its forced on with GLUT.

My issue is that I know damn well the is a way to force Vsync on in windowed mode and fullscreen, as far as I know the only way you can force Vsync in SDL is with the

Code: Select all

SDL_GL_SetArtibute(SDL_GL_SWAP_CONTROL,1)
flag.

Surely the is a flag that I've missed or some external libary that I don't know of that will allow SDL to force VSync?
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: OpenGL and Vsync

Post by qpHalcy0n »

You're terrible at answering questions :]

nVidia, ati, intel?

windows? Linux?
N64vSNES
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Thu Aug 12, 2010 11:25 am

Re: OpenGL and Vsync

Post by N64vSNES »

qpHalcy0n wrote: You're terrible at answering questions :]
Why thankyou! =] nothing more motavational than some appreciation ;)
qpHalcy0n wrote: nVidia, ati, intel?
Intel
qpHalcy0n wrote: windows? Linux?
Windows
houston
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 17
Joined: Sat Nov 27, 2010 7:44 pm
Current Project: SDL_xhtml engine
Favorite Gaming Platforms: PC, MacOS, Linux, iPhone
Programming Language of Choice: Assembly, C, C++
Location: Belfast N/Ireland
Contact:

Re: OpenGL and Vsync

Post by houston »

Hi; you do realize that using VSync will make your program run at different speeds on different monitors! If somebody is using say a monitor that can only handle 800x600 @ 60Hz the program will seem slower than yours if yours runs at 85Hz on 800x600..
You should just setup timing for display rendering at a fixed amount for best results if you want consistent speed on different setups, it's what we used to do back in the early 90's...

houston
N64vSNES
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Thu Aug 12, 2010 11:25 am

Re: OpenGL and Vsync

Post by N64vSNES »

houston wrote:Hi; you do realize that using VSync will make your program run at different speeds on different monitors! If somebody is using say a monitor that can only handle 800x600 @ 60Hz the program will seem slower than yours if yours runs at 85Hz on 800x600..
You should just setup timing for display rendering at a fixed amount for best results if you want consistent speed on different setups, it's what we used to do back in the early 90's...

houston
houston wrote: Hi; you do realize that using VSync will make your program run at different speeds on different monitors!
No shit? :nono:
houston wrote: You should just setup timing for display rendering at a fixed amount for best results if you want consistent speed on different setups
I have done, the framerate is capped to 60 FPS, however this dosen't eliminate the fact its not going to be synced with the monitor and will result in a fuckload of tearing
houston wrote: it's what we used to do back in the early 90's...
...
.....
.......
Welcome to 2010!
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: OpenGL and Vsync

Post by qpHalcy0n »

Don't wear your heart on your sleeve ;) Nobody's making fun, but if anyone's going to help you need to pay attention and make an attempt to answer what we're asking. Secondly, don't "No shit" people who are trying to help you, kid. Chill out and show some courtesy or you'll get no help at all!

Houston's hit on one of the solutions I was getting at. A good game loop should be metered, period. It makes the most sense for efficiency not only for the display but for your application as well.

Now, I want to be clear that when I lumped Intel in with ATI and nVIDIA that I was referring to GRAPHICS processors, please confirm that you have an intel GRAPHICS processor?
N64vSNES
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Thu Aug 12, 2010 11:25 am

Re: OpenGL and Vsync

Post by N64vSNES »

qpHalcy0n wrote:Don't wear your heart on your sleeve ;) Nobody's making fun, but if anyone's going to help you need to pay attention and make an attempt to answer what we're asking. Secondly, don't "No shit" people who are trying to help you, kid. Chill out and show some courtesy or you'll get no help at all!

Houston's hit on one of the solutions I was getting at. A good game loop should be metered, period. It makes the most sense for efficiency not only for the display but for your application as well.

Now, I want to be clear that when I lumped Intel in with ATI and nVIDIA that I was referring to GRAPHICS processors, please confirm that you have an intel GRAPHICS processor?
qpHalcy0n wrote: Don't wear your heart on your sleeve ;)
...ok...
qpHalcy0n wrote: Secondly, don't "No shit" people who are trying to help you, kid.
Thats just me =]
qpHalcy0n wrote: Houston's hit on one of the solutions I was getting at. A good game loop should be metered, period. It makes the most sense for efficiency not only for the display but for your application as well.
Like I said, its limited to 60 FPS but this dosen't confirm that the monitors Vsync has completed yet so it will result in tearing and nobody wants that.
qpHalcy0n wrote: Now, I want to be clear that when I lumped Intel in with ATI and nVIDIA that I was referring to GRAPHICS processors, please confirm that you have an intel GRAPHICS
Correct.
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: OpenGL and Vsync

Post by qpHalcy0n »

Well, with an attitude like that you're CERTAINLY not getting anymore help from me.

Intel video drivers are notoriously terrible. I'm going to be 99% certain the swap extensions do not work on the intel chips, which is how the SDL swap interval is exposed. Sorry.
N64vSNES
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Thu Aug 12, 2010 11:25 am

Re: OpenGL and Vsync

Post by N64vSNES »

qpHalcy0n wrote:Well, with an attitude like that you're CERTAINLY not getting anymore help from me.

Intel video drivers are notoriously terrible. I'm going to be 99% certain the swap extensions do not work on the intel chips, which is how the SDL swap interval is exposed. Sorry.
qpHalcy0n wrote:Well, with an attitude like that you're CERTAINLY not getting anymore help from me.
I'm sorry if you took it the wrong way but I didn't mean anything offensive of it.
qpHalcy0n wrote: Intel video drivers are notoriously terrible. I'm going to be 99% certain the swap extensions do not work on the intel chips, which is how the SDL swap interval is exposed. Sorry.
So your sure its my shitty GPU? perhaps I should test it on a diffrent PC?
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: OpenGL and Vsync

Post by qpHalcy0n »

I'd definitely test it on a couple systems if you can. The last time I monkeyed with the Intel GPU driver I was unable to retrieve a working implementation of the swap interval routine, so give it a whirl and see what happens.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: OpenGL and Vsync

Post by Ginto8 »

I have to agree there, I had an intel gfx card for a while and either the actual card or the drivers (or both) were so shitty I could barely achieve anything even mildly graphics intensive. Then I got an MSI/nVidia card and I haven't really had a single issue with graphics performance.
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
N64vSNES
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Thu Aug 12, 2010 11:25 am

Re: OpenGL and Vsync

Post by N64vSNES »

Ginto8 wrote:I have to agree there, I had an intel gfx card for a while and either the actual card or the drivers (or both) were so shitty I could barely achieve anything even mildly graphics intensive. Then I got an MSI/nVidia card and I haven't really had a single issue with graphics performance.
Well performance hasn't been a problem for me to be honest, I admit I don't play WoW or Oblivion but it can EQ over 120 FPS easily. =]
Post Reply