depreciated framerate limiting

This commit is contained in:
James Turk 2003-12-14 22:35:35 +00:00
parent ff89f6786c
commit 5aaca5ef01
10 changed files with 36 additions and 30 deletions

View File

@ -13,7 +13,7 @@
\brief Definition file for core ZEngine class. \brief Definition file for core ZEngine class.
ZEngine Game Engine core Engine definition. ZEngine Game Engine core Engine definition.
<br>$Id: ZE_ZEngine.h,v 1.55 2003/11/23 19:30:26 cozman Exp $<br> <br>$Id: ZE_ZEngine.h,v 1.56 2003/12/14 22:36:09 cozman Exp $<br>
\author James Turk \author James Turk
**/ **/
@ -86,8 +86,12 @@ class ZEngine
bool mPaused; bool mPaused;
//! Keep track of if ZEngine should unpause on active event. //! Keep track of if ZEngine should unpause on active event.
bool mUnpauseOnActive; bool mUnpauseOnActive;
#ifdef DEPRECIATED
//! Value framerate strives to be at, set by SetDesiredFramerate. //! Value framerate strives to be at, set by SetDesiredFramerate.
Uint8 mDesiredFramerate; Uint8 mDesiredFramerate;
#endif //DEPRECIATED
//! Time scheduled for next update (used for framerate locked movement). //! Time scheduled for next update (used for framerate locked movement).
Uint32 mNextUpdate; Uint32 mNextUpdate;
//! Keep track of time game was last paused. //! Keep track of time game was last paused.
@ -304,6 +308,7 @@ class ZEngine
**/ **/
double GetFramerate(); double GetFramerate();
#ifdef DEPRECIATED
/*! /*!
\brief Set Desired Framerate. \brief Set Desired Framerate.
@ -323,6 +328,7 @@ class ZEngine
\return Current setting for desired framerate. \return Current setting for desired framerate.
**/ **/
Uint8 GetDesiredFramerate(); Uint8 GetDesiredFramerate();
#endif //DEPRECIATED
/*! /*!
\brief Check Engine Paused State. \brief Check Engine Paused State.

View File

@ -13,7 +13,7 @@
\brief Central source file for ZEngine. \brief Central source file for ZEngine.
Actual implementation of ZEngine singleton class, the core of ZEngine. Actual implementation of ZEngine singleton class, the core of ZEngine.
<br>$Id: ZE_ZEngine.cpp,v 1.65 2003/11/24 02:21:20 cozman Exp $<br> <br>$Id: ZE_ZEngine.cpp,v 1.66 2003/12/14 22:36:50 cozman Exp $<br>
\author James Turk \author James Turk
**/ **/
@ -29,7 +29,10 @@ ZEngine *ZEngine::sInstance=NULL;
ZEngine::ZEngine() : ZEngine::ZEngine() :
mScreen(NULL), mFullscreen(true), mInitialized(false), mScreen(NULL), mFullscreen(true), mInitialized(false),
mPaused(false), mUnpauseOnActive(false), mPaused(false), mUnpauseOnActive(false),
mDesiredFramerate(0), mNextUpdate(0), mLastPause(0), mPausedTime(0), mLastTime(0), #ifdef DEPRECIATED
mDesiredFramerate(0),
#endif DEPRECIATED
mNextUpdate(0), mLastPause(0), mPausedTime(0), mLastTime(0),
mSecPerFrame(0.0), mSecPerFrame(0.0),
mNeedReload(false), mActive(false), mQuit(false), mKeyIsPressed(NULL), mNeedReload(false), mActive(false), mQuit(false), mKeyIsPressed(NULL),
mMouseX(0), mMouseY(0), mMouseB(0), mMouseX(0), mMouseY(0), mMouseB(0),
@ -281,6 +284,7 @@ void ZEngine::Update()
mSecPerFrame = (GetTime()-mLastTime)/1000.0; mSecPerFrame = (GetTime()-mLastTime)/1000.0;
mLastTime = GetTime(); mLastTime = GetTime();
#ifdef DEPRECIATED
//framerate limiting// //framerate limiting//
if(mDesiredFramerate) if(mDesiredFramerate)
{ {
@ -288,6 +292,7 @@ void ZEngine::Update()
SDL_Delay(mNextUpdate-mLastTime); SDL_Delay(mNextUpdate-mLastTime);
mNextUpdate = GetTime()+(1000/mDesiredFramerate); mNextUpdate = GetTime()+(1000/mDesiredFramerate);
} }
#endif //DEPRECIATED
} }
#if (GFX_BACKEND == ZE_OGL) #if (GFX_BACKEND == ZE_OGL)
@ -377,6 +382,8 @@ double ZEngine::GetFramerate()
return mSecPerFrame ? 1/mSecPerFrame : 0; //avoid /0 return mSecPerFrame ? 1/mSecPerFrame : 0; //avoid /0
} }
#ifdef DEPRECIATED
void ZEngine::SetDesiredFramerate(Uint8 rate) void ZEngine::SetDesiredFramerate(Uint8 rate)
{ {
mDesiredFramerate = rate; mDesiredFramerate = rate;
@ -387,6 +394,8 @@ Uint8 ZEngine::GetDesiredFramerate()
return mDesiredFramerate; return mDesiredFramerate;
} }
#endif //DEPRECIATED
bool ZEngine::IsPaused() bool ZEngine::IsPaused()
{ {
return mPaused; return mPaused;

View File

@ -9,7 +9,7 @@ This example file is in the public domain, it may be used with no restrictions.
and the home of this Library is http://www.zengine.sourceforge.net and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/ *******************************************************************************/
/*$Id: ZFontTest.cpp,v 1.18 2003/11/24 22:59:18 cozman Exp $*/ /*$Id: ZFontTest.cpp,v 1.19 2003/12/14 22:35:35 cozman Exp $*/
#include <ZEngine.h> #include <ZEngine.h>
#include <string> #include <string>
@ -20,7 +20,7 @@ bool Initialize()
{ {
ZEngine *engine = ZEngine::GetInstance(); ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf"); ZConfigFile cfg("tests.zcf");
int w,h,bpp,rate; int w,h,bpp;
bool fs; bool fs;
string title; string title;
@ -29,7 +29,6 @@ bool Initialize()
bpp = cfg.GetInt("ZFontTest","bpp",32); bpp = cfg.GetInt("ZFontTest","bpp",32);
fs = cfg.GetBool("ZFontTest","fullscreen",false); fs = cfg.GetBool("ZFontTest","fullscreen",false);
title = cfg.GetString("ZFontTest","title","ZFont Test"); title = cfg.GetString("ZFontTest","title","ZFont Test");
rate = cfg.GetInt("ZFontTest","framerate",60);
return engine->CreateDisplay(w,h,bpp,fs,title); return engine->CreateDisplay(w,h,bpp,fs,title);
} }

View File

@ -9,7 +9,7 @@ This example file is in the public domain, it may be used with no restrictions.
and the home of this Library is http://www.zengine.sourceforge.net and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/ *******************************************************************************/
/*$Id: ZImageTest.cpp,v 1.28 2003/11/24 22:59:18 cozman Exp $*/ /*$Id: ZImageTest.cpp,v 1.29 2003/12/14 22:35:35 cozman Exp $*/
#include <ZEngine.h> #include <ZEngine.h>
#include <string> #include <string>
@ -20,7 +20,7 @@ bool Initialize()
{ {
ZEngine *engine = ZEngine::GetInstance(); ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf"); ZConfigFile cfg("tests.zcf");
int w,h,bpp,rate; int w,h,bpp;
bool fs; bool fs;
std::string title; std::string title;
@ -29,9 +29,7 @@ bool Initialize()
bpp = cfg.GetInt("ZImageTest","bpp",32); bpp = cfg.GetInt("ZImageTest","bpp",32);
fs = cfg.GetBool("ZImageTest","fullscreen",true); fs = cfg.GetBool("ZImageTest","fullscreen",true);
title = cfg.GetString("ZImageTest","title","ZImage Test"); title = cfg.GetString("ZImageTest","title","ZImage Test");
rate = cfg.GetInt("ZImageTest","framerate",60);
engine->SetDesiredFramerate(rate);
return engine->CreateDisplay(w,h,bpp,fs,title); return engine->CreateDisplay(w,h,bpp,fs,title);
} }
@ -109,7 +107,7 @@ void Test()
engine->Clear(); //clear screen engine->Clear(); //clear screen
//draw the images// //draw the images//
alpha += alphaDelta*engine->GetFrameTime(); alpha += static_cast<float>(alphaDelta*engine->GetFrameTime());
if(alpha >= 255 || alpha <= 0) if(alpha >= 255 || alpha <= 0)
alphaDelta *= -1.0f; alphaDelta *= -1.0f;
image1.SetAlpha(static_cast<Uint8>(alpha)); image1.SetAlpha(static_cast<Uint8>(alpha));
@ -117,7 +115,7 @@ void Test()
#if (GFX_BACKEND == ZE_OGL) #if (GFX_BACKEND == ZE_OGL)
image2.DrawRotated(100,0,angle); image2.DrawRotated(100,0,angle);
angle+=(150*engine->GetFrameTime()); angle += static_cast<float>(150*engine->GetFrameTime());
if(angle > 360) if(angle > 360)
angle = 0.0f; angle = 0.0f;
#elif (GFX_BACKEND == ZE_SDL) #elif (GFX_BACKEND == ZE_SDL)

View File

@ -9,7 +9,7 @@ This example file is in the public domain, it may be used with no restrictions.
and the home of this Library is http://www.zengine.sourceforge.net and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/ *******************************************************************************/
/*$Id: ZMouseTest.cpp,v 1.20 2003/11/24 22:59:18 cozman Exp $*/ /*$Id: ZMouseTest.cpp,v 1.21 2003/12/14 22:35:35 cozman Exp $*/
#include <ZEngine.h> #include <ZEngine.h>
#include <string> #include <string>
@ -20,7 +20,7 @@ bool Initialize()
{ {
ZEngine *engine = ZEngine::GetInstance(); ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf"); ZConfigFile cfg("tests.zcf");
int w,h,bpp,rate; int w,h,bpp;
bool fs; bool fs;
std::string title; std::string title;
@ -29,7 +29,6 @@ bool Initialize()
bpp = cfg.GetInt("ZMouseTest","bpp",32); bpp = cfg.GetInt("ZMouseTest","bpp",32);
fs = cfg.GetBool("ZMouseTest","fullscreen",false); fs = cfg.GetBool("ZMouseTest","fullscreen",false);
title = cfg.GetString("ZMouseTest","title","ZMouse Test"); title = cfg.GetString("ZMouseTest","title","ZMouse Test");
rate = cfg.GetInt("ZMouseTest","framerate",60);
return engine->CreateDisplay(w,h,bpp,fs,title); return engine->CreateDisplay(w,h,bpp,fs,title);
} }

View File

@ -9,7 +9,7 @@ This example file is in the public domain, it may be used with no restrictions.
and the home of this Library is http://www.zengine.sourceforge.net and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/ *******************************************************************************/
/*$Id: ZMusicTest.cpp,v 1.20 2003/11/24 22:59:18 cozman Exp $*/ /*$Id: ZMusicTest.cpp,v 1.21 2003/12/14 22:35:35 cozman Exp $*/
#include <ZEngine.h> #include <ZEngine.h>
#include <string> #include <string>
@ -20,7 +20,7 @@ bool Initialize()
{ {
ZEngine *engine = ZEngine::GetInstance(); ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf"); ZConfigFile cfg("tests.zcf");
int w,h,bpp,rate; int w,h,bpp;
bool fs; bool fs;
std::string title; std::string title;
@ -29,7 +29,6 @@ bool Initialize()
bpp = cfg.GetInt("ZMusicTest","bpp",32); bpp = cfg.GetInt("ZMusicTest","bpp",32);
fs = cfg.GetBool("ZMusicTest","fullscreen",false); fs = cfg.GetBool("ZMusicTest","fullscreen",false);
title = cfg.GetString("ZMusicTest","title","ZMusic Test"); title = cfg.GetString("ZMusicTest","title","ZMusic Test");
rate = cfg.GetInt("ZMusicTest","framerate",60);
return engine->CreateDisplay(w,h,bpp,fs,title); return engine->CreateDisplay(w,h,bpp,fs,title);
} }

View File

@ -9,7 +9,7 @@ This example file is in the public domain, it may be used with no restrictions.
and the home of this Library is http://www.zengine.sourceforge.net and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/ *******************************************************************************/
/*$Id: ZParticleTest.cpp,v 1.8 2003/11/24 01:58:23 cozman Exp $*/ /*$Id: ZParticleTest.cpp,v 1.9 2003/12/14 22:35:35 cozman Exp $*/
#include <ZEngine.h> #include <ZEngine.h>
#include <string> #include <string>
@ -20,7 +20,7 @@ bool Initialize()
{ {
ZEngine *engine = ZEngine::GetInstance(); ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf"); ZConfigFile cfg("tests.zcf");
int w,h,bpp,rate; int w,h,bpp;
bool fs; bool fs;
std::string title; std::string title;
@ -29,7 +29,6 @@ bool Initialize()
bpp = cfg.GetInt("ZParticleTest","bpp",32); bpp = cfg.GetInt("ZParticleTest","bpp",32);
fs = cfg.GetBool("ZParticleTest","fullscreen",false); fs = cfg.GetBool("ZParticleTest","fullscreen",false);
title = cfg.GetString("ZParticleTest","title","ZParticle Test"); title = cfg.GetString("ZParticleTest","title","ZParticle Test");
rate = cfg.GetInt("ZParticleTest","framerate",60);
return engine->CreateDisplay(w,h,bpp,fs,title); return engine->CreateDisplay(w,h,bpp,fs,title);
} }

View File

@ -9,7 +9,7 @@ This example file is in the public domain, it may be used with no restrictions.
and the home of this Library is http://www.zengine.sourceforge.net and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/ *******************************************************************************/
/*$Id: ZRectTest.cpp,v 1.21 2003/11/24 22:59:18 cozman Exp $*/ /*$Id: ZRectTest.cpp,v 1.22 2003/12/14 22:35:35 cozman Exp $*/
#include <ZEngine.h> #include <ZEngine.h>
#include <string> #include <string>
@ -20,7 +20,7 @@ bool Initialize()
{ {
ZEngine *engine = ZEngine::GetInstance(); ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf"); ZConfigFile cfg("tests.zcf");
int w,h,bpp,rate; int w,h,bpp;
bool fs; bool fs;
std::string title; std::string title;
@ -29,7 +29,6 @@ bool Initialize()
bpp = cfg.GetInt("ZRectTest","bpp",32); bpp = cfg.GetInt("ZRectTest","bpp",32);
fs = cfg.GetBool("ZRectTest","fullscreen",false); fs = cfg.GetBool("ZRectTest","fullscreen",false);
title = cfg.GetString("ZRectTest","title","ZRect Test"); title = cfg.GetString("ZRectTest","title","ZRect Test");
rate = cfg.GetInt("ZRectTest","framerate",60);
return engine->CreateDisplay(w,h,bpp,fs,title); return engine->CreateDisplay(w,h,bpp,fs,title);
} }

View File

@ -9,7 +9,7 @@ This example file is in the public domain, it may be used with no restrictions.
and the home of this Library is http://www.zengine.sourceforge.net and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/ *******************************************************************************/
/*$Id: ZSoundTest.cpp,v 1.20 2003/11/24 22:59:18 cozman Exp $*/ /*$Id: ZSoundTest.cpp,v 1.21 2003/12/14 22:35:35 cozman Exp $*/
#include <ZEngine.h> #include <ZEngine.h>
#include <string> #include <string>
@ -20,7 +20,7 @@ bool Initialize()
{ {
ZEngine *engine = ZEngine::GetInstance(); ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf"); ZConfigFile cfg("tests.zcf");
int w,h,bpp,rate; int w,h,bpp;
bool fs; bool fs;
std::string title; std::string title;
@ -29,7 +29,6 @@ bool Initialize()
bpp = cfg.GetInt("ZSoundTest","bpp",32); bpp = cfg.GetInt("ZSoundTest","bpp",32);
fs = cfg.GetBool("ZSoundTest","fullscreen",false); fs = cfg.GetBool("ZSoundTest","fullscreen",false);
title = cfg.GetString("ZSoundTest","title","ZSound Test"); title = cfg.GetString("ZSoundTest","title","ZSound Test");
rate = cfg.GetInt("ZSoundTest","framerate",60);
return engine->CreateDisplay(w,h,bpp,fs,title); return engine->CreateDisplay(w,h,bpp,fs,title);
} }

View File

@ -9,7 +9,7 @@ This example file is in the public domain, it may be used with no restrictions.
and the home of this Library is http://www.zengine.sourceforge.net and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/ *******************************************************************************/
/*$Id: ZTimerTest.cpp,v 1.19 2003/11/24 02:17:32 cozman Exp $*/ /*$Id: ZTimerTest.cpp,v 1.20 2003/12/14 22:35:35 cozman Exp $*/
#include <ZEngine.h> #include <ZEngine.h>
#include <string> #include <string>
@ -20,7 +20,7 @@ bool Initialize()
{ {
ZEngine *engine = ZEngine::GetInstance(); ZEngine *engine = ZEngine::GetInstance();
ZConfigFile cfg("tests.zcf"); ZConfigFile cfg("tests.zcf");
int w,h,bpp,rate; int w,h,bpp;
bool fs; bool fs;
std::string title; std::string title;
@ -29,7 +29,6 @@ bool Initialize()
bpp = cfg.GetInt("ZTimerTest","bpp",32); bpp = cfg.GetInt("ZTimerTest","bpp",32);
fs = cfg.GetBool("ZTimerTest","fullscreen",false); fs = cfg.GetBool("ZTimerTest","fullscreen",false);
title = cfg.GetString("ZTimerTest","title","ZTimer Test"); title = cfg.GetString("ZTimerTest","title","ZTimer Test");
rate = cfg.GetInt("ZTimerTest","framerate",60);
return engine->CreateDisplay(w,h,bpp,fs,title); return engine->CreateDisplay(w,h,bpp,fs,title);
} }