Results 1 to 3 of 3

Thread: how calculate the FPS?

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,575

    how calculate the FPS?

    how calculate the FPS?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,575

    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
    VB6 2D Sprite control

    To live is difficult, but we do it.

  3. #3
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,537

    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
  •  



Click Here to Expand Forum to Full Width