Gl Graph
Gl Graph Source of glscenestat.h
#ifndef GL_SCENE_STAT_H #define GL_SCENE_STAT_H #include <time.h> #include <unistd.h> class GlSceneStat { private: double meanFrameComputationTime; double frameComputationTime; int nbFrameComputationTime; timespec starting_time; timespec endding_time; public: GlSceneStat() { this->nbFrameComputationTime=0; this->frameComputationTime=0; this->meanFrameComputationTime=0; } double getDeltaTime(timespec &starting_time,timespec &endding_time) { int64_t t1 = ((int64_t) starting_time.tv_sec)*1000000000 + starting_time.tv_nsec; int64_t t2 = ((int64_t) endding_time.tv_sec)*1000000000 + endding_time.tv_nsec; int64_t diff_time = t2 - t1; return diff_time/1.0e9; } void setTime(float delta) { if (nbFrameComputationTime <100) { this->frameComputationTime += delta; this->nbFrameComputationTime++; } else this->frameComputationTime=100*(100.0*frameComputationTime/nbFrameComputationTime +delta)/101.0; this->meanFrameComputationTime=frameComputationTime/nbFrameComputationTime; } void startScene() { clock_gettime(CLOCK_REALTIME, &starting_time); } void endScene() { clock_gettime(CLOCK_REALTIME, &endding_time); float delta=getDeltaTime(starting_time,endding_time); setTime(delta); } float getMeanTime() { return this->meanFrameComputationTime; } }; #endif