Results 1 to 3 of 3

Thread: Time stepping

  1. #1
    Member Contributor
    Join Date
    Jun 2001
    Posts
    74

    Time stepping

    Hi there,

    Where can i get info regarding time-stepping so a program doesnt run faster on more powerful machines?

    Cheers

  2. #2
    Junior Member Newbie
    Join Date
    Oct 2001
    Location
    South Africa
    Posts
    5

    Re: Time stepping

    If you are using sound, use your sound to time.

    Or you could use v-retrace (I'm new to openGL and dont know much about that)

    Else ... you can use the timeGetTime function
    (Check your neares msdn)

    And keep timing with that. And just erm .. I geuss wait for the next moment to display, and then display.

    But for your part, I hope someone else replies that has a better idea

    These are just my idea's (which could be terrible)

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Time stepping

    TrXtR is on the right track here. Use a time function.

    There are two ways most people do.

    #1: Lock the framerate at a certain speed. Easiest to implement, but is not a very good solution in my oppinion. On very powerfull machines, the application is waiting to continue most of the time = major waste of computer power. Undefined behaviour un computers that cannot keep the framerate you set as a minimum. Easy to code movements, since one frame is always a fixed timestep. If an object is supposed to move 30 units in one second, and you lock your program at 60 fps, the object will be moved 0.5 units each frame.

    #2: Let the program run as fast as it can, and update the scene according to the time spend in last frame. In my oppinion, the best compared to how easy it is to implement. A littel more difficult than #1, but utilizes the computer all the time. More power = higher framerate, but not faster game movements. Will work on slower computers aswell, without problems. A bit more difficult to code movements, since you don't know the timestep. You specify your movements in units per second, and multiply this movement with the number of seconds in last frame. Your object is moving at a speed of 30 units per second. Last frame took 0.02 seconds (~50 fps), the next frame will move the object 30*0.02=0.6 units forward.

    Time can be measured with timeGetTime, or with QueryPerformanceCounter (Win32 only).

Similar Threads

  1. Replies: 2
    Last Post: 10-14-2012, 09:41 AM
  2. clock time as the current time ??
    By John22 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-08-2009, 05:54 PM
  3. wglCreateContext failing from time to time
    By Janko Jerinic in forum OpenGL: Windows
    Replies: 3
    Last Post: 07-23-2009, 02:40 PM
  4. glDrawElements() crash from time to time
    By _NK47 in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-14-2008, 11:34 AM
  5. Small sprites - Favour fragment time over vertex time?
    By centipede in forum OpenGL: GLSL
    Replies: 4
    Last Post: 11-24-2005, 12:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean