Jump to content

  • Log In with Google      Sign In   
  • Create Account


Different speeds on different pc's all using Windows


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Rotti   Members   -  Reputation: 100

Like
0Likes
Like

Posted 12 September 2011 - 02:45 PM

Hi

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:
http://www.userotti....ngl/planets.zip

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" );
glutEnterGameMode();

Please. Go easy on me.

Thanks.

Sponsor:

#2 HNikolas   Members   -  Reputation: 192

Like
0Likes
Like

Posted 12 September 2011 - 02:59 PM

There are many ways of archieving what you are after, the easiest one being simple fps/frame capping/limiting.


// Found a topic for you - http://stackoverflow.com/questions/6707475/how-can-i-implement-an-accurate-but-variable-fps-limit-cap-in-my-opengl-applica
Ruby on Rails, ASP.NET MVC, jQuery and everything else web.. now also trying my hand on games.

#3 Dunge   Members   -  Reputation: 405

Like
1Likes
Like

Posted 12 September 2011 - 03:37 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS