-
Oct 6th, 2022, 02:50 PM
#1
Thread Starter
PowerPoster
-
Oct 6th, 2022, 04:20 PM
#2
Thread Starter
PowerPoster
Re: how calculate the FPS?
i have these code:
Code:
if (TempTime <= GetTickCount())
{
TempTime = GetTickCount() + 10;
for(int i=0, y=0; i<img.ImageHeight; i++, y++)
{
if( y>=imgTexture.ImageHeight) y=0;
img.DrawLine(0,i,500,i,0, imgTexture,0,y);
}
img.Draw(HDCConsole, 100,100);
FrameCount = FrameCount + 1;
if (Fps + 1000 <= GetTickCount())
{
Fps = GetTickCount();
FrameCount = 0;
cout << to_string(Fps) << "\n";
}
}
(forget been in C++)
i need to ask: it's normal been printed '5875468'?
ok... only print several lines for print an image using DIB's
-
Oct 11th, 2022, 12:09 PM
#3
Re: how calculate the FPS?
Try swapping the two lines, and printing framecount instead of fps. You're using fps to hold the starting tick count and counting frames until the tickcount is a second away from fps.
Code:
cout << to_string(FrameCount) << "\n";
FrameCount = 0;
That is the obvious error. There are probably other logic errors, and misnamed variables.
p.s. GetTickCount is not particularly accurate. I think in most cases it increments by 15.625 millisecond increments (i.e. at 64 hz).
You are checking for a 10ms trigger for your drawing, which means ideally you would draw at a limit of 100hz , i.e. 100 fps max, but assuming your drawing is fast enough to do 100 fps, the GetTickCount call will probably limit it to 64 fps.
Last edited by passel; Oct 11th, 2022 at 12:14 PM.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|