Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Frame rate limiter.

  1. #1

    Frame rate limiter.

    Hi All

    I'm doing this to limit the frame rate, but the graphics are juddering a little, and not moving smoothly also, on two machines, I have a steady 65 fps, on my brothers machine however, he gets a startling 3 fps .. Its this right or am I missing something?.
    Code:
     // --- Setup timer ---
      Timer:= TPHXTimer.Create;
      Timer.Interval:= 1 / 30;
    
    // --- Main Loop ---
     Repeat
    
        Timer.Update;
        Input.Update; 
        Move_All;
        Timer.Wait;
        Draw_All;
    
      Until (GameOver = True) or (Screen.Visible = False);
    Check out my Delphi programs, music and writing.
    <br />http://digitalfunnybone.com/Programming.html

  2. #2

    Frame rate limiter.

    Usually when it comes to fps as low as 3, it is because drawing or physics takes so much frame time. What is yours and your brothers computer specs?

  3. #3

    Frame rate limiter.

    Hi,

    Maybe you should try frame-based timing. The idea is to let the game loop run as fast as your computer can run it thereby having the bast overall experience and you control the rate at which your simulation runs. Now you've decoupled your updating from rendering and have precise control over it.

    In this scenario, your game loop can be running at say 60 fps on one machine and maybe 45 or something different on another, but your simulation will always run at the precise specified rate between them.

    You game now is divided into two section, one to render your graphics and the other to updating your simulation. You set your desired simulation rate at game start and at the top of your game loop, you get the elapsed time. Note, this elapsed time is a time quantity based on your desired simulation rate. This value is then used as a multiplier against your game objects to keep them moving at/or very close to your desired simulation rate. For example, if you want your simulation to update at 30 fps and your game loop is currently running at 60 fps, the elapsed time value for this frame will be 0.5. When you multiply this by the speed of your moving objects it will cause them to move at 30 fps. Know that from frame to frame your game loop speed will vary greatly and frame base timing can keep your simulation running at a known and predictable rate. The result is silky smooth animation.

    Google for frame-based timing for more information. I can send you some sources if you like that you can drop in.

    Hope this helps.
    Jarrod Davis
    Technical Director @ Piradyne Games

  4. #4

    Frame rate limiter.

    Ah ..
    I see .. this is why int the demo's, the movement is being updated by an incement modified by the frame time.

    Code:
     if isLeft  in Input.States then X&#58;=X - FSpeed * FrameTime;
      if isRight in Input.States then X&#58;=X + FSpeed * FrameTime;
    I think I understand now.
    Check out my Delphi programs, music and writing.
    <br />http://digitalfunnybone.com/Programming.html

  5. #5

    Frame rate limiter.

    Correct.

    Also, one thing you need to be aware of with FBT is there can be a situation where if there is a lot of activity going on in the background, the elapsed time value can be extremely large as it will calculate a value to keep those objects moving at your simulation speed. This can occur if say there is lot of hard disk activity or maybe a heavy load during a frame. What I've done to help with this is to specify a maximum elapsed time the timer object will try to keep the simulation running at. For example if I specify two for max elapsed time, the timer will try and keep the simulation running at my specified rate if the overall rate drops by two times. After this point, it gives up and let the frame rate match the game loop rate. This will minimize the huge jumps that sometime can occur for reasons specified.
    Jarrod Davis
    Technical Director @ Piradyne Games

  6. #6

    Frame rate limiter.

    Thanks.

    I found out why my brothers machine was getting 3 fps btw, it turns out, he had switched to 16 bit color mode to run and older game and hadn't switched back, when he returned to 32 bit mode, his FPS rocketed up to 240..

    Any Idea why this should happen ?
    Check out my Delphi programs, music and writing.
    <br />http://digitalfunnybone.com/Programming.html

  7. #7

    Frame rate limiter.

    Not sure.

    My guess would be that your not getting acceleration in that mode for what ever reason.
    Jarrod Davis
    Technical Director @ Piradyne Games

  8. #8

    Frame rate limiter.

    Check if phnx timer are working correctly,
    using gettickcount and logging to a file for example.
    From brazil (:

    Pascal pownz!

  9. #9

    Frame rate limiter.

    Quote Originally Posted by Bones
    Thanks.

    I found out why my brothers machine was getting 3 fps btw, it turns out, he had switched to 16 bit color mode to run and older game and hadn't switched back, when he returned to 32 bit mode, his FPS rocketed up to 240..

    Any Idea why this should happen ?
    Probably some driver issue for his graphics card i could imageine....
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  10. #10

    Frame rate limiter.

    Quote Originally Posted by Andreaz
    Quote Originally Posted by Bones
    Thanks.

    I found out why my brothers machine was getting 3 fps btw, it turns out, he had switched to 16 bit color mode to run and older game and hadn't switched back, when he returned to 32 bit mode, his FPS rocketed up to 240..

    Any Idea why this should happen ?
    Probably some driver issue for his graphics card i could imageine....
    I tried it on my own machine too, sure enough, my frame rate dropped to 8 fps, is there maybe something I'm doing wrong when I set up the screen ?
    Check out my Delphi programs, music and writing.
    <br />http://digitalfunnybone.com/Programming.html

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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