Advertisement Jump to content
Sign in to follow this  

OpenGL Different speeds on different pc's all using Windows

This topic is 2690 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I made a program that has some moving objects, It seemed that they were moving a bit slow in the beginning since their moving vectors where quite big in relation to their positions, but I thought it was some openGL limiter or something. When I started mailing my friends(windows users) the link to the zipped file (which contains the .exe and the glut32.dll and a readme.txt) some of them said the it looks cool, and others said that the balls where spinning VERY fast.

I then thought it can't be because there pc's are that much faster, it had to be some setting. I've been reading about "vsync" and the "wgl" functions that can be used to set vsync, but some guys on these forums say that you should not change "vsync" unless you really need to. I this a good enough reason? to have my program run at the same speed on all windows computers, is very important to me, and I don't want to ask everbody to go change some setting in the control panel or graphics card options. I want to tell the program exactly how to look and how fast the objects must move in the code in a legit way.

If I do understand vsync and it is not to taboo to set it to "0", I would like to turn it of, so that the program draws as fast as it possibly can, and I can decrease my movement vectors, for even smaller position changes more often. Is this the right way of reasoning?

Here is the link I was forwarding to my friends:

The program code is very basic, maths, vectors, matrix stuff, trig. It uses double buffering, and glSwapbuffers at the end of my display function. I also use the following functions:
glutGameModeString( "1280×1024:32@75" );

Please. Go easy on me.


Share this post

Link to post
Share on other sites
For beginner projects, you should simply update your object positions/rotation passing the time difference (deltaT) since last frame and calculate all movement accordingly, then render after every update. It will allow you to go as fast as you can, while keeping the same speed everywhere.

Problem is, in complex physic libraries (PhysX, Box2D, Bullet, etc), you can't do that. Since the deltaT between frames will be highly variable depending on the computer power, it's called "variable timesteps", and you could happens to lose some precision. As an example, the player might be able to jump slightly higher on one machine than the other. People might even take advantage of that and create lag spikes to get hard to reach secrets.

Physics engine recommend to fix your timestep to a certain number (let's say 60hz, so 60 frames per second, fixed). Problem with implementing this method directly is that your rendering will be fixed too, and if the computer is fast enough it will render the 60 frames in a few milliseconds, then wait the whole second before starting the new batch, hence a jerking effect.

The real solution is fix the physic, and allow rendering as fast you can. To do it, you use an accumulator (see lot of threads about that, I got to agree none are very clear to understand). If the physic is not calculated fast enough, you can skip rendering frames between physic updates, if the physics is fast enough you have spare time to render multiple frames between physic update. To allow smoother movement between physic updates, you need a position/rotation interpolation between the two physic steps.

Hope I did not make the matter more complicated than it was :)

edit: As for the vsync, it should be an user option more than anything, you don't force it on or off, it's always over-writable in the graphic card drivers anyway. If you render faster than the vsync rate and it's enabled, it will work (cap the frames, remove tearing) without the programmer needing to do anything.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!