K3dTimer.h

Go to the documentation of this file.
00001 
00012 /***************************************************************************
00013  *   Copyright (C) 2007 by Jan Koci   *
00014  *   honza.koci@email.cz   *
00015  *   http://kengine.sourceforge.net/tutorial/
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  *   This program is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00025  *   GNU General Public License for more details.                          *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU General Public License     *
00028  *   along with this program; if not, write to the                         *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00031  ***************************************************************************/
00032 
00033 #pragma once
00034 
00035 #include <SDL/SDL.h>
00036 #include <SDL/SDL_opengl.h>
00037 #include <SDL/SDL_image.h>
00038 #include "GameData/K3dGameData.h"
00039 
00040 #define K_DEFAULT_SPEED 10
00041 #define K_DEFAULT_FPS 25
00042 
00043 class K3dTimer
00044 {
00045                 K3dGameData *m_pGameData;       
00046                 float m_fFps;                   
00047                 unsigned int m_uiLastTime;      
00048                 unsigned int m_uiNumFrames;     
00049                 unsigned int m_uiWaitingTime;   
00050         public:
00051                 K3dTimer ( K3dGameData *_pGameData );
00052                 ~K3dTimer();
00053 
00054                 void CalculateFPS();
00055                 bool Wait ( const int _iMsec );
00056 
00057                 float GetFPS()
00058                 {
00059                         return m_fFps;
00060                 }
00061 
00062                 unsigned int GetNumFrames()
00063                 {
00064                         return m_uiNumFrames;
00065                 }
00066 
00068                 void SynchronizeSpeed ( float &_fSpeed )
00069                 {
00070                         if ( m_fFps > K_DEFAULT_FPS )
00071                         {
00072                                 _fSpeed /= m_fFps;
00073                         }
00074                         else
00075                         {
00076                                 _fSpeed = K_DEFAULT_SPEED;
00077                         }
00078                 }
00079 
00080 };
00081 

Generated on Thu Aug 16 23:53:28 2007 for K3dEngine by  doxygen 1.5.0