Autor Beitrag
CyTe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Do 27.02.03 22:22 
ich verwende delphix.

mit einem timer, der alle 20 ms läuft, wird das bild aktualsisert.

wie kann ich jetzt während der laufzeit die jeweils aktuellen fps ausrechnen?
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Fr 28.02.03 09:20 
Du brauchst eine OnIdle-Prozedur deiner Anwendung (Application.OnIdle).
Dort steht dann drin:
ausblenden Quelltext
1:
FPS := FPS+1;					


Und in deiner Timer-Prozedur steht dann sowas:
ausblenden Quelltext
1:
2:
Form1.Caption := IntToStr(FPS*50)+' FPS';   // Ist aber sehr ungenau
FPS := 0;


Um es genauer zu machen, kannst du auch in deinem OnTimer-Ereignis
einen Zähler einbauen und dann jedes 50.Mal (50*20ms = 1s)
ausblenden Quelltext
1:
2:
Form1.Caption := IntToStr(FPS)+' FPS';
FPS := 0;

ausführen.

_________________
If accidentally read, induce vomitting.
Da_Knuddelbaer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 485



BeitragVerfasst: Fr 28.02.03 09:48 
Titel: DelphiX
Mit DelphiX kannst du einfacher die aktuellen FPS anzeigen lassen. Der Befehl den Du suchst ist DXTimer.FrameRate. Ich denke mal trotz Timer müsste das gut funktionieren:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
    with DXDraw.Surface.Canvas do
    begin
      Brush.Style := bsClear;
      Font.Color := clWhite;
      Font.Size := 12;
      Textout(0, 0, 'FPS: '+inttostr(DXTimer.FrameRate));
      Release;
    end;
OregonGhost
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 215



BeitragVerfasst: Fr 28.02.03 12:29 
Du kannst auch QueryPerformanceFrequency und QueryPerformanceCounter verwenden, um direkt die Zeit zu messen. Die FPS sind ja nur 1 / Framezeit.

Allerdings solltest du den Durchschnitt bilden, wenigstens aus den letzten paar Messungen, um starke Schwankungen auszugleichen.

_________________
Oregon Ghost
---
Wenn NULL besonders groß ist, ist es fast schon wie ein bisschen eins.
Da_Knuddelbaer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 485



BeitragVerfasst: Fr 28.02.03 13:20 
Titel: Probleme mit Query
OregonGhost,
ja, wäre auch eine Möglichkeit. Nur ich meine mich zu erinnern dass die Query-Befehle bei mir oft Probleme gemacht haben :D na ja, ist bei mir ja nichts neues.

Knuddelbaer
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Fr 28.02.03 15:11 
@QueryPerformanceCounter: nicht wenn man ihn richtig initialisiert und prüft, ob er überhaupt da ist!

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
var CounterAvailable : boolean = false;
    Frequency        : int64;
    LastTime         : int64;
    CurrentTime      : int64;
    TimeScale        : double;
    TimeDelta        : double;
    FrameRate        : single;
    SpeedRelation    : single;

    LastFPSTime      : int64;
    FrameRateString  : String;
    TempFrameCount   : Word;
...

procedure initPerformanceTimer;
begin
  CounterAvailable := false;
  if QueryPerformanceFrequency(frequency) = false then
  begin
    LastTime := timeGetTime;
    TimeScale := 0.001;
  end else begin
    CounterAvailable := true;
    TimeScale := 1.0 / frequency;
    QueryPerformanceCounter(LastTime);
  end;
  FrameRate        := 0;
  FrameRateString  := 'FPS: 0';
  TempFrameCount   := 100-1;
end;

procedure CountPerformance;
begin
  // high resolution performance counter
  if CounterAvailable then queryPerformanceCounter(CurrentTime)
  else CurrentTime := timeGetTime;
  TimeDelta        := (CurrentTime - LastTime) * TimeScale;
  LastTime         := CurrentTime;
  SpeedRelation    := TimeDelta * TimeSpeed;
  //-------------------------------------------
  inc(TempFrameCount);
  if TempFrameCount = 100 then
  begin
    FrameRate        := 100 / ((CurrentTime-LastFPSTime)* TimeScale);
    FrameRateString  := 'FPS: '+IntToStr(trunc(FrameRate));
    LastFPSTime      := CurrentTime;
    TempFrameCount   := 0;
  end;
end;


... TempFrameCount benutz ich, um die FPS zu glätten.

mfg maximus.
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 04.03.03 21:28 
*LOL*
ausblenden Quelltext
1:
DXTimer1.FrameRate					

so einfach geht das ;)

_________________
MFG
Michael Springwald, "kann kein englisch...."
maximus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 896

Win XP, Suse 8.1
Delphi 4/7/8 alles prof
BeitragVerfasst: Di 04.03.03 23:07 
*ROFL*

Wenn man immer den weg des geringsten widerstandes gehen will!
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Di 04.03.03 23:14 
HÄ ?

PS:
ich hatte nach dem ich gepostet hatte gesehen das meine idee schonmal gepostet wurde ist !!!

_________________
MFG
Michael Springwald, "kann kein englisch...."
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 08.03.03 23:18 
oder mit gettickcount :P
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
 Inc(Frames);
  if GetTickCount - StartTick >=500 then
  begin
    Framespersecond:= round(Frames/(GetTickCount - StartTick)*1000);
    StartTick := GetTickCount;
     Frames := 0;
  end;


wobei du hier:GetTickCount - StartTick >=500
das Intervall frei wählen kannst, nach welcher Zeit die FPS aktualisiert werden...
Starttick ist z.B. Cardinal...
Framespersecond auch
Frames auch*gg*
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Sa 08.03.03 23:19 
> Warum einfach, wenns auch kompliziert geht???
genau :)

_________________
MFG
Michael Springwald, "kann kein englisch...."
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Sa 08.03.03 23:22 
wobei das wahrscheinlich noch eine der einfachsten Methoden ist, wenn man nicht DelphiX verwendet...
siehtr aber trotzdem intelligenter aus, wenn man einem andren den Quellcode zeigt *lol*
wahrscheinlich macht aber DelphiX auch nichts andres :?:
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: Sa 08.03.03 23:29 
kann sein, aber warum denn das rad neu erfinden(wenn mann drauf ist ?)

_________________
MFG
Michael Springwald, "kann kein englisch...."
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: So 09.03.03 00:07 
ich bin auch nicht dafür das Rad neu zu erfinden, es schadet aber auch nicht, wenn man weiss, was man programmiert...
deshalb benutze ich auch keine Fremd-Units oder -Komponenten...
das ist aber natürlich jedem freigestellt ;)
mimi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 3458

Ubuntu, Win XP
Lazarus
BeitragVerfasst: So 09.03.03 00:11 
für bestimmte aufgaben kann man ja das rad neu erfinden !
Aber wir weichen vom thema ab;)

_________________
MFG
Michael Springwald, "kann kein englisch...."