00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00024 #ifndef __ze_zengine_h__
00025 #define __ze_zengine_h__
00026
00027 #include "ZE_Defines.h"
00028 #include "ZE_Utility.h"
00029 #include "ZE_Includes.h"
00030 #include "ZE_ZError.h"
00031
00037 namespace ZE
00038 {
00039
00046 class ZEngine
00047 {
00049
00051
00052 private:
00054 static ZEngine *sInstance;
00055
00061 ZEngine();
00062
00063 public:
00064
00071 static ZEngine* GetInstance();
00072
00078 static void ReleaseInstance();
00079
00086 static string GetVersion();
00087
00089
00091
00092 private:
00094 int mWidth;
00096 int mHeight;
00098 int mBPP;
00100 bool mFullscreen;
00102 bool mInitialized;
00103
00104 #ifdef USE_SDL_MIXER
00105
00106 int mRate;
00108 bool mStereo;
00109 #endif
00110
00111
00112 public:
00113
00114
00125 void SetupDisplay(int width, int height, int bpp, bool fullscreen);
00126
00127 #ifdef USE_SDL_MIXER
00128
00136 void SetupSound(int rate, bool stereo);
00137 #endif
00138
00150 bool CreateDisplay(string title, string icon="");
00151
00157 void CloseDisplay();
00158
00166 void ToggleFullscreen();
00167
00175 bool Initialized();
00176
00178
00180
00181 private:
00183 SDL_Surface *mScreen;
00184
00185 public:
00192 SDL_Surface *Display();
00193
00200 void Update();
00201
00211 void Clear(float red=0.0f, float green=0.0f, float blue=0.0f, float alpha=1.0f);
00212
00214
00216
00217
00224 void SetGL2D();
00225
00227
00229
00230 private:
00232 bool mPaused;
00234 bool mUnpauseOnActive;
00236 Uint8 mDesiredFramerate;
00238 Uint32 mNextUpdate;
00240 Uint32 mLastPause;
00242 Uint32 mPausedTime;
00244 Uint32 mLastTime;
00246 double mSecPerFrame;
00247
00248 public:
00255 void Delay(Uint32 milliseconds);
00256
00263 Uint32 GetTime();
00264
00270 void PauseTimer();
00271
00277 void UnpauseTimer();
00278
00285 double GetFrameTime();
00286
00294 double GetFramerate();
00295
00305 void SetDesiredFramerate(Uint8 rate);
00306
00314 Uint8 GetDesiredFramerate();
00315
00322 bool IsPaused();
00323
00325
00327
00329
00331
00333
00335
00337
00339
00341
00343
00344
00345 public:
00352 bool IsActive();
00353
00360 void RequestQuit();
00361
00369 bool QuitRequested();
00370
00375 void SetReloadNeed(bool state);
00376
00384 bool ImagesNeedReload();
00385
00395 void SetKeyRepeatRate(int rate);
00396
00404 bool KeyIsPressed(SDLKey key);
00405
00413 bool KeyPress(SDLKey key);
00414
00420 void HideCursor();
00421
00427 void ShowCursor();
00428
00435 int MouseX();
00436
00443 int MouseY();
00444
00451 bool LButtonPressed();
00452
00459 bool RButtonPressed();
00460
00468 bool MouseInRect(SDL_Rect *rect);
00469
00475 void CheckEvents();
00476
00487 void SetEventFilter(SDL_EventFilter filter);
00488
00489 #ifdef USE_PHYSFS
00490
00491
00493
00500 void InitPhysFS(string argv);
00501
00508 void AddPhysFSDir(string dir);
00509
00510 #endif //USE_PHYSFS
00511
00513
00515
00517
00519
00521
00523
00524
00532 void LogError(ZError error);
00533
00534 public:
00545 void SetErrorLog(bool logAll, string logFile="");
00546
00557 void ReportError(ZErrorCode code, string desc="", string file="", unsigned int line=0);
00558
00566 ZErrorCode GetLastError();
00567
00575 void WriteLog(string str);
00576
00583 void FlushErrors();
00584
00585
00587
00589
00597 SDL_Surface* LoadImage(string filename);
00598
00599 #ifdef USE_SDL_MIXER
00600
00607 Mix_Chunk* LoadSound(string filename);
00608
00616 Mix_Music* LoadMusic(string filename);
00617 #endif
00618
00619 #ifdef USE_SDL_TTF
00620
00628 TTF_Font* LoadFont(string filename, int size);
00629 #endif
00630
00632
00634
00635 public:
00642 int Width();
00643
00650 int Height();
00651
00658 int BPP();
00659
00666 bool IsFullscreen();
00667 };
00668
00669 }
00670
00671 #endif //__ze_zengine_h__