Sign in to follow this  
Simagery

[SDL] No vsync in windowed mode?

Recommended Posts

Another newbie SDL question that Google doesn't seem to help with... when running in fullscreen, my SDL_Flip is definitely waiting for vsync. In windowed mode, though, it's definitely *not* waiting for vsync. According to the SDL docs, SDL_Flip should always wait for vsync. Any ideas? I saw mention somewhere that if you're using OpenGL with SDL then it will always wait for vsync regardless of fullscreen or not... can anyone comment on that as I do plan on eventually throwing OpenGL on top of SDL. Thanks.

Share this post


Link to post
Share on other sites
I don't think vsync is a consideration in windowed mode. In Windowed mode you don't have direct access to or control over the screen, and any actual buffer flipping is handled by the OS, not by SDL. So there's little point SDL_Flip waiting for vsync, if it's even possible. You see where the SDL_Flip docs say, "On hardware that doesn't support double-buffering, this is equivalent to calling SDL_UpdateRect(screen, 0, 0, 0, 0)"? That generally applies to windowed mode. There's a big difference between the modes which comes down to more than just how large your window is, you see. I don't think it should ever be a problem though.

Share this post


Link to post
Share on other sites
It's definitely a problem, though, due to tearing. Vsync acts as a nice, natural maximum for rendering that simply capping framerate doesn't give you. But it's really down to the tearing.

Hmm... I'm hoping I can change this (it's certainly not a limitation of the underlying API, DirectDraw).

Share this post


Link to post
Share on other sites
Actually, I'm pretty sure that buffer flipping in DirectDraw only works in exclusive mode (ie. fullscreen), and I think that is the only function that explicitly waits for Vsync.

EDIT: There is "IDirectDraw::WaitForVerticalBlank" but I don't think that was available in DirectX 6.

Share this post


Link to post
Share on other sites
Well, that's fairly disappointing. You're right, non-fullscreen DirectDraw would by default be using blitting instead of flipping, and thus does not automatically wait for vsync.

Does anyone know if when I switch to an OpenGL context (still using SDL) if I'll be able to control vsync in windowed mode?

Share this post


Link to post
Share on other sites
Yeah, that's part of it, but the real deal is the tearing. My desire is for a polished display, and eliminating tearing is a big part of that. Capping the framerate, particularly if you can cap it below the refresh rate, is a good way to prevent evil tearing artifacts like things not being completely visible (what I have now in windowed mode).

Share this post


Link to post
Share on other sites
Quote:
Original post by Simagery
Yeah, that's part of it, but the real deal is the tearing. My desire is for a polished display, and eliminating tearing is a big part of that. Capping the framerate, particularly if you can cap it below the refresh rate, is a good way to prevent evil tearing artifacts like things not being completely visible (what I have now in windowed mode).


Hello!
I am using SDL as well and would like to eliminate tearing. Is there anyone who can give us some hints to get a smooth scroll in a window or in full screen in a Windows program? How can we check when there is a vertical retrace with SDL? SDL_Flip doesn't seem to do this job on my machine.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this