Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28

Thread: Serious problems getting LockFPS to work.

  1. #11

    Serious problems getting LockFPS to work.

    LOL.. we'd be doing them a favour by crashing... "Now get outside and get some sunshine!" :lol:

    For something like a dedicated server though it could be an issue, they can run for months at a time. (I'm guessing)

    And what do you mean, *unless* it's the best game ever :roll: :lol:

  2. #12

    Serious problems getting LockFPS to work.

    For a dedicated server, the solution is quite simple. Test for value b < value a and the calculate as appropriate. Of course this has already been stated and known .

    PS: The longest I've seen anyone ever play a game was 27 days before he fell asleep at the keyboard. Poor fool only had to play 3 more days to win the bet.

  3. #13

    Serious problems getting LockFPS to work.

    Quote Originally Posted by jasonf
    For something like a dedicated server though it could be an issue, they can run for months at a time. (I'm guessing)
    I'm not sure someone would write a dedicated server using SDL, but I suppose it's possible.

    PS. I'm having a mental block of how to work out FPS, without actually having an FPS counter variable. I'd like to get the GetFPS function working properly as well.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  4. #14

    Serious problems getting LockFPS to work.

    SlicesPerDeviation * FrameTime = FPS

    So standard: 1000 * FrameTime = ~FPS (due to rounding errors)

    Or maybe it was Slices/FrameTime can't remember whitch offhand but its one or the other.

  5. #15

    Serious problems getting LockFPS to work.

    The Current GetFPS interferes with the LockFPS as it resets the starting time.

    I think there should be a function at the beginning of the frame which sets the start time, then both GetFPS and LockFPS use this value as a basis for the calculations.

    Having the functions completely independant, whilst being a nice idea is flawed if they use the same variables. So they either need to use seperate variables or have the reset done elsewhere.

    I think the LockFPS is working at the moment, but I can't seem to get the GetFPS working properly. I'll take another look later. It would be nice to see a nice, unchanging 30 on the GetFPS function due to the LockFPS limiting to 30.

    Also, we are assuming 1000ms for each second.. can we guarantee this for SDL_GetTicks? (may sound like a stupid question, but why have a variable which we can set and not a constant if otherwise?)

  6. #16

    Serious problems getting LockFPS to work.

    OK.. I just played with some numbers and I'm fairly sure it is..

    fps = TicksPerSecond / ( CurrentTime - LastTime )

    Becuase if TicksPerSecond = 1000, LastTime = 12000 and CurrentTime = 13000

    1000 / ( 13000 - 12000 = 1000 ) = 1

    If the frame takes 1000 Ticks, then we are running at 1 frame per second.

  7. #17

    Serious problems getting LockFPS to work.

    Quote Originally Posted by jasonf
    OK.. I just played with some numbers and I'm fairly sure it is..

    fps = TicksPerSecond / ( CurrentTime - LastTime )

    Becuase if TicksPerSecond = 1000, LastTime = 12000 and CurrentTime = 13000

    1000 / ( 13000 - 12000 = 1000 ) = 1

    If the frame takes 1000 Ticks, then we are running at 1 frame per second.
    Will need to add a check for ( CurrentTime - LastTime ) = 0 other wise it will blow up. Ok I might give that a go.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  8. #18

    Serious problems getting LockFPS to work.

    Nah, leave the check out... as a punishment for those with really fast machines :twisted:

  9. #19

    Serious problems getting LockFPS to work.

    Quote Originally Posted by jasonf
    OK.. I just played with some numbers and I'm fairly sure it is..
    fps = TicksPerSecond / ( CurrentTime - LastTime )
    This is correct, the common function is: FPS = Slices/FrameTime whitch drops down to 1000 / (CurrentTime-LastTime) in most cases. Here is an implementation that we played with for our stuff:

    [pascal]var
    LastFrame : Cardinal;

    function SystemGetTickCount() : Cardinal;
    begin
    result := -1;
    {$IFDEF WIN32}
    result := Windows.GetTickCount();
    {$ENDIF}
    {$IFDEF UNIX}
    result := clock_gettime(CLOCK_MONOTONIC);
    {$ENDIF}
    end;

    function GetFPS() : Cardinal;
    var
    CurrTime, FrameTime : Cardinal;
    begin
    CurrTime := SystemGetTickCount;
    FrameTime := CurrTime-LastFrame;
    if FrameTime < 0 then
    FrameTime := (MaxCardinal-CurrTime)+LastFrame;
    GetFPS := 1000 / FrameTime;
    end;

    // The render loop
    begin
    LastFrame := SystemGetTickCount;
    // Setup stuff here
    while GameRunning do
    begin
    // Rendering code goes here.
    WriteLn('FPS: ', GetFPS);
    LastFrame := SystemGetTickCount;
    end;
    end.[/pascal]

    This seems to work fairly well, with the largest problem being that the first itteration is off, due to setup times and etc... Of course, I never left it up and running for the 49 days that it would take to find out if I screwed something up with the rollover stuff .

  10. #20

    Serious problems getting LockFPS to work.

    I've just spotted this mail from 1999 about GetTickCount and QueryPerformanceCounter

    http://www.libsdl.org/pipermail/sdl/...er/023531.html

Page 2 of 3 FirstFirst 123 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
  •