|
KGLLib
|
00001 /* 00002 * Copyright (C) 2008 Rivo Laks <rivolaks@hot.ee> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef KGLLIB_FPSCOUNTER_H 00019 #define KGLLIB_FPSCOUNTER_H 00020 00021 00022 #include "kgllib.h" 00023 00024 #include <QtCore/QTime> 00025 #include <QtCore/QString> 00026 00027 00028 namespace KGLLib 00029 { 00030 00054 class KGLLIB_EXPORT FPSCounter 00055 { 00056 public: 00061 FPSCounter(); 00062 00070 void nextFrame(); 00071 void resetTimeElapsed(); 00072 00080 float fps() const { return mFPS; } 00089 QString fpsString() const; 00100 // TODO: rename to timeSinceLastFrame()? change semantics? 00101 float timeElapsed() { return mTimeElapsed; } 00108 float totalTimeElapsed() { return mTotalTimeElapsed; } 00109 00110 protected: 00111 QTime mTime; 00112 int mFrames; 00113 float mFPS; 00114 00115 float mTimeElapsed; // in sec 00116 float mTotalTimeElapsed; // in sec 00117 QTime mLastTime; 00118 }; 00119 00120 } 00121 00122 #endif
1.7.4