Results 1 to 2 of 2

Thread: How to count frames?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Feb 2000

    How to count frames?

    I have got a "simple" question:

    How can I get the current framerate of my OpenGL programm.

    I count how often my drawing function is called in one second, but is this really the true framerate?

    What´s with buffer swapping / flipping and such things? Is there a better way to count fps?


  2. #2
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Stockholm, Sweden

    Re: How to count frames?

    Your method is correct. But you can also count the framerate by messuring the time it takes to render a frame, this will not be updating only once per second. The most accurate way to do this is to use this functions:

    __inline __int64 GetCycleNumber(){
    //RDTSC instruction
    __asm _emit 0x0F __asm _emit 0x31

    int GetMHz(){
    LARGE_INTEGER t1,t2,tf;
    __int64 c1,c2;

    c1 = GetCycleNumber();
    //Just wait a little
    for (int t = 0; t < 5000000; t++);
    c2 = GetCycleNumber();

    return (int) ((c2 - c1) * tf.QuadPart / (t2.QuadPart - t1.QuadPart) / 1000000);

    Time = (ThisCycleNumber - LastCycleNumber) / (1000000 * MHz);

Similar Threads

  1. Register Max count
    By bob87000 in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 04-20-2017, 08:33 AM
  2. Count the GL functions used
    By rlk in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-08-2007, 08:39 PM
  3. Count the no of Z fail
    By iris_raj in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 02-12-2007, 07:58 AM
  4. How to count objects I have...
    By Jinny in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 09-18-2002, 03:15 AM
  5. A Bit OT - Correct FPS Count
    By Aster in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 08-26-2001, 12:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean