Original Post
🔒 Locked
Show FPS
Advertisement
Put this
SetTimer(hWnd, 1, 1000, nil); // Timer fire''s every 1000
// milliseconds (1 second)
Inside of the WM_CREATE window message (inside the WndProc function so that the timer is created when the program starts, like this:
WM_CREATE:
begin
SetTimer(hWnd, 1, 1000, nil);
end;
Then create a variable called numFrames and increment it at the end of your DrawGLScene (or equivalent) function.
now every second your window will recieve a WM_TIMER message so you need to catch it and handle it like this:
WM_TIMER:
begin
// Display numFrames somewhere on screen then set it to
// zero
DrawFPS(); // Some function you create that displays the FPS
numFrames := 0;
end;
What this code does is every second it checks how many times you have redrawn your scene (number of times DrawGLScene was executed), displays this number then resets the frame counter and continually updates your FPS every second.
The only problem with this is that the window timer (WM_TIMER) isn''t very accurate but if you are just using this for a rough idea of the number of frames per second you are getting its a quick and easy way to do it.
Jason A.
---
I write code.
DelphiGL (members.home.com/jra101)
SetTimer(hWnd, 1, 1000, nil); // Timer fire''s every 1000
// milliseconds (1 second)
Inside of the WM_CREATE window message (inside the WndProc function so that the timer is created when the program starts, like this:
WM_CREATE:
begin
SetTimer(hWnd, 1, 1000, nil);
end;
Then create a variable called numFrames and increment it at the end of your DrawGLScene (or equivalent) function.
now every second your window will recieve a WM_TIMER message so you need to catch it and handle it like this:
WM_TIMER:
begin
// Display numFrames somewhere on screen then set it to
// zero
DrawFPS(); // Some function you create that displays the FPS
numFrames := 0;
end;
What this code does is every second it checks how many times you have redrawn your scene (number of times DrawGLScene was executed), displays this number then resets the frame counter and continually updates your FPS every second.
The only problem with this is that the window timer (WM_TIMER) isn''t very accurate but if you are just using this for a rough idea of the number of frames per second you are getting its a quick and easy way to do it.
Jason A.
---
I write code.
DelphiGL (members.home.com/jra101)
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement