It is currently Mon May 22, 2017 2:22 pm

All times are UTC - 5 hours




 Page 1 of 1 [ 7 posts ] 
Author Message
 Post subject: Physics VMK 1 - Vertical Synchronization
PostPosted: Thu Jan 10, 2008 8:42 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
In VMK 1A I explain the inner workings of the vertical synchronization feature built into a computer's video card and monitor. I then show you how to disable it so that we can get the game engine running at more than the standard 60 fps.

VMK 1B/C demonstrates how to add a check box to the Options Menu that will allow you to turn vertical synchronization on and off, while the game engine is running.


Offline
 Profile  
 
 Post subject:
PostPosted: Sun Sep 07, 2008 6:51 pm 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
Oh, the tutorial is spectacular. You certainly have a talent to explain the concepts. :)

Probably the only thing that also should be mentioned is a double buffering, which is a standard in 2D/3D graphics. It increases the smoothness of animation and reduces the flickering of the screen, allowing to switch vertical synchronization off with minimal detriment to user’s experience.

If somebody is interested to know more about WGL_EXT_swap_control extension, here is a link to official description:
http://www.opengl.org/registry/specs/EX ... ontrol.txt
In particular it gives more detailed explanation of the parameter to BOOL wglSwapIntervalEXT(int interval):
Quote:
The parameter <interval> specifies the minimum number of video frames that are displayed before a buffer swap will occur...


In addition to all that, it is rumored that you cannot disable V-Sync if it is prohibited in the options of video-driver.


Offline
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2010 11:21 pm 

Joined: Fri Sep 04, 2009 3:24 am
Posts: 30
I've watched the vid. and I understand how to turn off vsync, but I'm not sure why you would want the vid. card to work harder than it has too.

Does the program stop after completing the frame and has to wait 7ms before it continues or is it just the vid. card that stops for 7ms?

If the program stops, then I can understand turning vsync off. But if it's just the vid. card waiting to display the buffer, then whats the harm in waiting? You're writing data to a buffer which no one is seeing anyways. Or have I missed something?

thanks.


Offline
 Profile  
 
 Post subject: AFAIK - SwappBuffers() blocks the main thread
PostPosted: Tue Apr 20, 2010 3:18 am 

Joined: Wed Aug 06, 2008 7:53 pm
Posts: 182
Location: Russia
When the vertical synchronization is ON the function SwapBuffers() inside the main application loop blocks the execution thread of the application. So, as you said, the program stops and waiting.
The main reasons to turn V-Sync off are:
1) estimate the top performance of the hardware/software
2) if actual application's FPS is less than monitor's refresh rate it may in some circumstances increase the apps performance.
:roll:


Offline
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2010 10:12 am 

Joined: Fri Sep 04, 2009 3:24 am
Posts: 30
Thanks, was wondering about #2 also :)


Offline
 Profile  
 
 Post subject: Re: Physics VMK 1 - Vertical Synchronization
PostPosted: Fri Dec 23, 2011 6:54 am 
Site Admin

Joined: Sun Feb 11, 2007 8:59 am
Posts: 1094
Location: Ontario Canada
Here is an interesting short read about vertical sync that I just found: http://www.d-silence.com/feature.php?id=255


Offline
 Profile  
 
 Post subject: Re: Physics VMK 1 - Vertical Synchronization
PostPosted: Sat Jan 07, 2012 12:15 pm 

Joined: Sat Aug 16, 2008 7:58 am
Posts: 447
Im not certain, but I think I might have found a bug!

I don't think Marek noticed it since all his drawn objects were not moving. This is also a special case bug.
My fps difference is 64-on and about 380-off. The turning on/off and saving to config file and starting with the right user selection works fine. To see this bug, first you need to have a moving object, such as the rolling cylinder. Start a new game with the sync either on or off. Check your fps for either case. Next, go into the pause options and change the vsync's state. After you changed it, then you want to continue back to game, check your fps it has changed also keep an eye on your moving object. Ok where is the bug? Exit the application completely and run your debugger again. Start a new game, check your fps and the moving object then go into pause options and change its value. This time don't go back to your game, you want to exit from the pause menu to get back to the main menu, now you want to start a new game without stopping the debug. Check your fps it is ok, check your moving object somethings not right here! Atleast this is happening on my pc.

Changing the vsync from the pause options menu and continuing to the same game instance does change the fps and everything works fine. However, if you go into the pause menu select exit back to the main menu and select start new game without closing the application after changing the vsync, the moving object is no longer moving.
It is in the middle of the flatgrid and drawn half above and half below.

There is only two ways that I think this could be fixed. Either don't allow the user to change this option from the pause menu, or if the user applies this change in the pause menu options, warn the user that the affect won't take place until the application shuts down. Unless if I am missing something on why the objects are not moving after the vnsyc has been switched from one state or another, a new game was started without closing the application. I think this might be from the destroying of objects. I am at the stage of just finishing the OpenGL GameEngine series and just started the physics series. I have not reached the GhostToast series where we incorporated our destruction of objects by groups.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

cron