Ignore:
Timestamp:
Nov 22, 2012, 2:45:14 PM (12 years ago)
Author:
chronos
Message:
  • Added: Column which show real FPS calculated using frames counter and elapsed time.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/UDrawMethod.pas

    r447 r448  
    77uses
    88  Classes, SysUtils, ExtCtrls, UPlatform, UFastBitmap, Graphics, Controls,
    9   LCLType, IntfGraphics, fpImage, GraphType,
     9  LCLType, IntfGraphics, fpImage, GraphType, DateUtils,
    1010  LclIntf{$IFDEF opengl}, GL, GLExt, OpenGLContext{$ENDIF};
    1111
     
    1919  private
    2020    FControl: TControl;
     21    function GetFPS: Real;
    2122  public
    2223    Caption: string;
     
    2728    PaintObject: TPaintObject;
    2829    TempBitmap: TBitmap;
     30    FrameCounter: Integer;
     31    FrameCounterStart: TDateTime;
     32    property FPS: Real read GetFPS;
    2933    procedure Init(Parent: TWinControl; Size: TPoint); virtual;
    3034    procedure Done; virtual;
     
    173177{ TDrawMethod }
    174178
     179function TDrawMethod.GetFPS: Real;
     180begin
     181  Result := FrameCounter / ((NowPrecise - FrameCounterStart) / OneSecond);
     182  FrameCounter := 0;
     183  FrameCounterStart := NowPrecise;
     184end;
     185
    175186procedure TDrawMethod.Init(Parent: TWinControl; Size: TPoint);
    176187begin
Note: See TracChangeset for help on using the changeset viewer.