[Glxtreem-commits] GLXtreem/Source GLXTimer.pas,1.2,1.3
Brought to you by:
andreaz
|
From: <dan...@us...> - 2004-03-11 02:18:48
|
Update of /cvsroot/glxtreem/GLXtreem/Source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27469/Source Modified Files: GLXTimer.pas Log Message: Changed the timer so that it uses the PerformanceCounter Index: GLXTimer.pas =================================================================== RCS file: /cvsroot/glxtreem/GLXtreem/Source/GLXTimer.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GLXTimer.pas 11 Mar 2004 01:16:00 -0000 1.2 --- GLXTimer.pas 11 Mar 2004 02:00:25 -0000 1.3 *************** *** 59,76 **** FInitialized : Boolean; FEventList : TList; // Time ! FAppStart : DWord; ! FLastTime : DWord; ! FSuspendTime: DWord; // Frame information FFrameTimes : Single; FFrameCount : Int64; ! FFrameRate : Integer; FFrameRateCounter: Integer; ! FFrameRateTime : DWord; ! function GetElapsedTime: DWord; function AppProc(var Message: TMessage): Boolean; procedure AppIdle(Sender: TObject; var Done: Boolean); --- 59,78 ---- FInitialized : Boolean; FEventList : TList; + FFrequency : Int64; // Time ! FAppStart : Single; ! FLastTime : Single; ! FSuspendTime : Single; // Frame information FFrameTimes : Single; FFrameCount : Int64; ! FFrameRate : Single; FFrameRateCounter: Integer; ! FFrameRateTime : Single; ! function GetCount:Single; ! function GetElapsedTime:Single; function AppProc(var Message: TMessage): Boolean; procedure AppIdle(Sender: TObject; var Done: Boolean); *************** *** 103,111 **** { The current framerate, is weighted over the last 500 ms. } ! property FrameRate : Integer read FFrameRate; { The number of frames rendered since program start. } property FrameCount : Int64 read FFrameCount; { The time elapsed since program start, in milliseconds. } ! property ElapsedTime: DWord read GetElapsedTime; published { Determines if the timer shall be active or not. } --- 105,113 ---- { The current framerate, is weighted over the last 500 ms. } ! property FrameRate : Single read FFrameRate; { The number of frames rendered since program start. } property FrameCount : Int64 read FFrameCount; { The time elapsed since program start, in milliseconds. } ! property ElapsedTime: Single read GetElapsedTime; published { Determines if the timer shall be active or not. } *************** *** 134,138 **** Application.HookMainWindow(AppProc); ! FAppStart :=GetTickCount; FFramerateTime :=FAppStart; FLastTime :=FAppStart; --- 136,141 ---- Application.HookMainWindow(AppProc); ! QueryPerformanceFrequency(FFrequency); ! FAppStart :=GetCount; FFramerateTime :=FAppStart; FLastTime :=FAppStart; *************** *** 184,197 **** procedure TGLXTimer.AppIdle(Sender: TObject; var Done: Boolean); var ! FrameTime, FrameRateTime: DWord; ! Compensate: DWord; i: Integer; Event : TGLXTimerEvent; begin ! Done := False; ! FrameTime:=(GetTickCount - FLastTime); IF (FrameTime >= FInterval) then begin ! ! FLastTime:=GetTickCount; Inc(FFramerateCounter); --- 187,198 ---- procedure TGLXTimer.AppIdle(Sender: TObject; var Done: Boolean); var ! FrameTime, FrameRateTime: Single; i: Integer; Event : TGLXTimerEvent; begin ! Done := False; ! FrameTime := (GetCount - FLastTime); IF (FrameTime >= FInterval) then begin ! FLastTime:=GetCount; Inc(FFramerateCounter); *************** *** 200,221 **** IF FrameRateTime > 500 then begin IF FFramerateCounter = 0 then FFramerateCounter:=1; ! FFrameRate:=Round(1000 / ((FLastTime - FFramerateTime) / FFramerateCounter)); ! ! FFramerateCounter:=0; ! FFramerateTime :=GetTickCount(); ! end; for i:=0 to FEventList.Count-1 do begin Event:=PGLXTimerEvent(FEventList.Items[i])^; ! if Assigned(Event) then Event(Self, (FFrameTimes + FrameTime) / 2); end; FFrameTimes:=FrameTime; - Compensate:=FrameTime - FInterval; - - IF Compensate > FInterval then Compensate:=FInterval; - - IF (FInterval <> 0) then FLastTime:=FLastTime - Compensate; - Inc(FFrameCount); end; --- 201,215 ---- IF FrameRateTime > 500 then begin IF FFramerateCounter = 0 then FFramerateCounter:=1; ! FFrameRate := Round(1000/(FrameRateTime/FFramerateCounter)); ! FFramerateCounter := 0; ! FFramerateTime := GetCount(); ! end; for i:=0 to FEventList.Count-1 do begin Event:=PGLXTimerEvent(FEventList.Items[i])^; ! if Assigned(Event) then Event(Self,FrameTime); end; FFrameTimes:=FrameTime; Inc(FFrameCount); end; *************** *** 266,270 **** procedure TGLXTimer.Resume; begin ! FLastTime:=GetTickCount; // FAppStart:=FAppStart+ (FLastTime-FSuspendTime); --- 260,264 ---- procedure TGLXTimer.Resume; begin ! FLastTime:=GetCount; // FAppStart:=FAppStart+ (FLastTime-FSuspendTime); *************** *** 275,279 **** procedure TGLXTimer.Suspend; begin ! FSuspendTime:=GetTickCount; Application.OnIdle:= nil; end; --- 269,273 ---- procedure TGLXTimer.Suspend; begin ! FSuspendTime:=GetCount; Application.OnIdle:= nil; end; *************** *** 309,315 **** //------------------------------------------------------------------------------ ! function TGLXTimer.GetElapsedTime: DWord; begin ! Result:=GetTickCount() - FAppStart; end; --- 303,318 ---- //------------------------------------------------------------------------------ ! function TGLXTimer.GetCount:Single; ! var ! t : Int64; begin ! QueryPerformanceCounter(t); ! result:=1000*t/FFrequency; ! end; ! ! //------------------------------------------------------------------------------ ! function TGLXTimer.GetElapsedTime:Single; ! begin ! Result:=GetCount() - FAppStart; end; |