gitsunekei1445 / GameEngineV.1

Main repository my team project .
1 stars 0 forks source link

Function Data : Show FPS #18

Open gitsunekei1445 opened 4 years ago

gitsunekei1445 commented 4 years ago

C++

  void showFPS()
{
     // Measure speed
     double currentTime = glfwGetTime();
     nbFrames++;
     if ( currentTime - lastTime >= 1.0 ){ // If last cout was more than 1 sec ago
         cout << 1000.0/double(nbFrames) << endl;
         nbFrames = 0;
         lastTime += 1.0;
     }
}
gitsunekei1445 commented 4 years ago

Python on module

timerAfter= 0
timerOn= False
timerStart = 0
fps=0
@staticmethod
    def gui_showFPS():
        Gui.fps += 1
        if not Gui.timerOn:
            Gui.timerOn = True
            Gui.timeStart = get_time()
        timeNow = get_time()
        if timeNow - Gui.timeStart >= 1.0:
            print('{} : {} - {}'.format(Gui.fps, timeNow, Gui.timeStart))
            Gui.fps = 0
            Gui.timeStart += 1.0

https://stackoverflow.com/questions/18412120/displaying-fps-in-glfw-window-title