SHARE
TWEET

renderloop

a guest Dec 21st, 2014 154 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. procedure TEVApplication.MainLoop;
  3. var
  4.   st: Single; //sleep time
  5.   t: NativeUInt; //rendertime
  6. begin
  7.   fRunning := true;
  8.   st := 0;
  9.   repeat
  10.     t := SDL_GetTicks;
  11.     HandleEvents;
  12.     //of course only if there's a fps-limit
  13.     if fMaxFPS > 0 then
  14.     begin
  15.       //calculate sleeptime
  16.       st := (1000 / fMaxFPS - (SDL_GetTicks - t)) + st;
  17.       if st > 0 then
  18.       begin
  19.         SDL_Delay(Trunc(st));
  20.         //added correction
  21.         //minimizes rounding-faults
  22.         st := st - Trunc(st);
  23.       end;
  24.     end;
  25.     //calculate fps
  26.     t := SDL_GetTicks - t;
  27.     if t > 0 then
  28.       fFPS := Round(1000 / t);
  29.   until not fRunning;
  30. end;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top