Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: am i doing this right??

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2004
    Location
    mexico
    Posts
    127

    am i doing this right??

    Hi!, im making a demo, and i want it to work at the same speed on almost all computers, i have a speed variable called vel (with an initial value of 100.0f) and i divide it by the current frames per second that giving me the value of sync_vel:
    sync_vel = vel / fps;
    the logic behind this is that if i get 40fps on computer A sync_vel will be 2.5f and on computer B i get 20fps sync_vel will be 5.0f, on a slower pc the speed will be bigger to compensate, and on a faster pc, speed will be slower. so am i doing it correctly and will this work?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,142

    Re: am i doing this right??

    It is better to use the time between two frames rather than the FPS, because that can be measured more accurately. If your object moves with velocity v and the time between the last frame and this frame is t, you have to move it by v*t.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jun 2004
    Location
    Minneapolis, USA
    Posts
    100

    Re: am i doing this right??

    Search the forums for "clamping the framerate" and
    "framerate" because we have answered this question
    at least ten times this year.

    Use a timer indipendent of the frame rate. I had
    suggested in the past that you simulate with an
    entirely different thread than the one that renders.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Jun 2004
    Location
    mexico
    Posts
    127

    Re: am i doing this right??

    thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •