Changeset 448 for GraphicTest


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.
Location:
GraphicTest
Files:
3 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
  • GraphicTest/UMainForm.lfm

    r447 r448  
    544544        end     
    545545        item
    546           Caption = 'Step draw duration [ms]'
     546          Caption = 'FPS'
     547        end     
     548        item
     549          Caption = 'Duration custom draw [ms]'
    547550          Width = 80
    548551        end     
    549552        item
    550           Caption = 'FPS'
     553          Caption = 'Draw FPS'
    551554          Width = 75
    552555        end     
    553556        item
    554           Caption = 'Total step duration [ms]'
     557          Caption = 'Duration step [ms]'
    555558          Width = 80
    556559        end     
  • GraphicTest/UMainForm.pas

    r447 r448  
    130130      StepStartTime := NowPrecise;
    131131      DrawFrameTiming(TFastBitmap(Scenes[SceneIndex]));
    132       SceneIndex := (SceneIndex + 1) mod Scenes.Count;
    133132      Application.ProcessMessages;
    134133      StepDuration := NowPrecise - StepStartTime;
     134      SceneIndex := (SceneIndex + 1) mod Scenes.Count;
     135      Inc(FrameCounter);
    135136    until TestTerminated or
    136137      ((TestTimeout > 0) and ((NowPrecise - StartTime) > OneSecond * TestTimeout));
     
    221222  with TDrawMethod(DrawMethods[Item.Index]) do begin
    222223    Item.Caption := Caption;
     224    Item.SubItems.Add(FloatToStr(RoundTo(FPS, -3)));
    223225    Item.SubItems.Add(FloatToStr(RoundTo(FrameDuration / OneMillisecond, -3)));
    224226    if FrameDuration > 0 then
Note: See TracChangeset for help on using the changeset viewer.