Как рассчитать FPS в OpenGL?

void CalculateFrameRate()
{    
    static float framesPerSecond    = 0.0f;       // This will store our fps
    static float lastTime   = 0.0f;       // This will hold the time from the last frame
    float currentTime = GetTickCount() * 0.001f;    
    ++framesPerSecond;
    if( currentTime - lastTime > 1.0f )
    {
        lastTime = currentTime;
        if(SHOW_FPS == 1) fprintf(stderr, "\nCurrent Frames Per Second: %d\n\n", (int)framesPerSecond);
        framesPerSecond = 0;
    }
}

Должен ли я вызывать эту функцию в void play (void) или void display (void) ?

Или это не имеет значения?

8
задан Ciro Santilli 新疆改造中心法轮功六四事件 17 March 2016 в 08:16
поделиться