Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

/include/ZE_ZEngine.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002         This file is Part of the ZEngine Library for 2D game development.
00003                    Copyright (C) 2002, 2003 James Turk
00004 
00005                      Licensed under a BSD-style license.
00006 
00007     The maintainer of this library is James Turk (james@conceptofzero.net) 
00008      and the home of this Library is http://www.zengine.sourceforge.net
00009 *******************************************************************************/
00010 
00020 #ifndef __ze_zengine_h__
00021 #define __ze_zengine_h__
00022 
00023 #include "ZE_Defines.h"
00024 #include "ZE_Utility.h"
00025 #include "ZE_Includes.h"
00026 #include "ZE_ZError.h"
00027 #include "ZE_ZRandGen.h"
00028 #include "VersionInfo.h"
00029 
00035 namespace ZE
00036 {
00037 
00038 class ZRect;
00039 
00046 class ZEngine
00047 {
00048     public:
00050         static VersionInfo Version;
00051 
00052     private:        
00054         static ZEngine *sInstance;
00056         int mWidth;
00058         int mHeight;
00060         int mBPP;
00062         bool mFullscreen;
00064         bool mInitialized;
00066         SDL_Surface *mScreen;
00068         bool mPaused;
00070         bool mUnpauseOnActive;
00072         Uint8 mDesiredFramerate;
00074         Uint32 mNextUpdate;
00076         Uint32 mLastPause;
00078         Uint32 mPausedTime;
00080         Uint32 mLastTime;
00082         double mSecPerFrame;
00084         bool mNeedReload;
00086         bool mActive;
00088         bool mQuit;
00090         Uint8 *mKeyIsPressed;
00092         bool mKeyPress[SDLK_LAST];
00094         int mMouseX;
00096         int mMouseY;
00098         Uint8 mMouseB;
00100         std::queue<ZError> mErrorQueue;
00102         ZError mCurError;
00104         bool mLogAllErrors;
00106         std::FILE *mErrlog;
00108         SDL_EventFilter mEventFilter;
00110         ZRandGen mRandGen;
00111 
00112 #ifdef USE_SDL_MIXER 
00113 
00114         int mRate;
00116         bool mStereo;
00117 #endif 
00118 
00120     //Singleton + Memory Management//
00122 
00123     private:
00129         ZEngine();
00130 
00131     public:
00132 
00139         static ZEngine* GetInstance();
00140 
00146         static void ReleaseInstance();
00147 
00149     //Initialization//
00151 
00162         void SetupDisplay(int width, int height, int bpp, bool fullscreen);
00163 
00164 #ifdef USE_SDL_MIXER
00165 
00173         void SetupSound(int rate, bool stereo);
00174 #endif 
00175 
00187         bool CreateDisplay(std::string title, std::string icon="");
00188 
00194         void CloseDisplay();
00195 
00203         void ToggleFullscreen();
00204 
00212         bool Initialized();
00213 
00215     //Screen Access//
00217 
00224         SDL_Surface *Display();
00225 
00232         void Update();
00233 
00243         void Clear(Uint8 red=0, Uint8 green=0, Uint8 blue=0, Uint8 alpha=255);
00244 
00245 #if (GFX_BACKEND == ZE_OGL)
00246 
00247     //OpenGL Specific Functions//
00249 
00256         void SetGL2D();
00257 #endif //GFX_BACKEND
00258 
00260     //Timer and Framerate Independent Movement//
00262 
00269         void Delay(Uint32 milliseconds);
00270 
00277         Uint32 GetTime();
00278 
00284         void PauseTimer();
00285 
00291         void UnpauseTimer();
00292 
00299         double GetFrameTime();
00300 
00308         double GetFramerate();
00309 
00319         void SetDesiredFramerate(Uint8 rate);
00320 
00328         Uint8 GetDesiredFramerate();
00329 
00336         bool IsPaused();
00337 
00339     //Event and Input Handling//
00341 
00348         bool IsActive();
00349 
00356         void RequestQuit();
00357 
00365         bool QuitRequested();
00366 
00371         void SetReloadNeed(bool state);
00372 
00380         bool ImagesNeedReload();
00381         
00390         void SetKeyRepeatRate(int rate);
00391 
00401         bool KeyIsPressed(SDLKey key);
00402 
00412         bool KeyPress(SDLKey key);
00413 
00419         void HideCursor();
00420 
00426         void ShowCursor();
00427 
00434         int MouseX();
00435 
00442         int MouseY();
00443 
00450         bool LButtonPressed();
00451 
00458         bool RButtonPressed();
00459 
00467         bool MButtonPressed();
00468 
00476         bool MouseInRect(SDL_Rect *rect);
00477 
00485         bool MouseInRect(ZRect rect);
00486 
00492         void CheckEvents();
00493 
00506         void SetEventFilter(SDL_EventFilter filter);
00507 
00509     //Error Logging//
00511     private:
00519         void LogError(ZError error);
00520 
00521     public:
00532         void SetErrorLog(bool logAll, std::string logFile="");
00533 
00544         void ReportError(ZErrorCode code, std::string desc="", std::string file="", unsigned int line=0);
00545 
00553         ZErrorCode GetLastError();
00554 
00562         void WriteLog(std::string str);
00563 
00570         void FlushErrors();
00571 
00573     //Random Number Generation//
00575 
00581         void SeedRandGen(unsigned long seed);
00582 
00590         unsigned int Rand(unsigned int max);
00591 
00599         unsigned long Rand(unsigned long max);
00600 
00609         int Rand(int min, int max);
00610 
00619         long Rand(long min, long max);
00620 
00629         float Rand(float min, float max);
00630 
00639         double Rand(double min, double max);
00640 
00647         double RandDouble();
00648 
00650     //Accessors//
00652 
00659         int DisplayWidth();
00660 
00667         int DisplayHeight();
00668 
00675         int DisplayDepth();
00676 
00677 #ifdef DEPRECIATED
00678 
00684         int Width();
00685 
00692         int Height();
00693 
00700         int BPP();
00701 #endif //DEPRECIATED
00702 
00709         bool IsFullscreen();
00710 };
00711 
00712 }
00713 
00714 #endif //__ze_zengine_h__

Generated on Sun Oct 5 19:34:45 2003 for ZEngine by doxygen1.3