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 
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     //Singleton + Memory Management//
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     //Initialization//
00091 
00092     private:
00094         int mWidth;
00096         int mHeight;
00098         int mBPP;
00100         bool mFullscreen;
00101 
00102 #ifdef USE_SDL_MIXER 
00103 
00104         int mRate;
00106         bool mStereo;
00107 #endif 
00108 
00109 
00110     public:
00111         //add initialization
00112 
00123         void SetupDisplay(int width, int height, int bpp, bool fullscreen);
00124 
00125 #ifdef USE_SDL_MIXER
00126 
00134         void SetupSound(int rate, bool stereo);
00135 #endif 
00136 
00148         bool CreateDisplay(string title, string icon="");
00149 
00155         void CloseDisplay();
00156 
00158     //Screen Access//
00160 
00161     private:
00163         SDL_Surface *mScreen;
00164 
00165     public:
00172         SDL_Surface *Display();
00173 
00180         void Update();
00181 
00191         void Clear(float red=0.0f, float green=0.0f, float blue=0.0f, float alpha=1.0f);
00192 
00194     //OpenGL Specific Functions//
00196     public:
00197 
00204         void SetGL2D();
00205 
00207     //Timer and Framerate Independent Movement//
00209     
00210     private:
00212         bool mPaused;
00214         bool mUnpauseOnActive;
00216         Uint8 mDesiredFramerate;
00218         Uint32 mNextUpdate;
00220         Uint32 mLastPause;
00222         Uint32 mPausedTime;
00224         Uint32 mLastTime;
00226         double mSecPerFrame;
00227 
00228     public:
00235         void Delay(Uint32 milliseconds);
00236 
00243         Uint32 GetTime();
00244 
00250         void PauseTimer();
00251 
00257         void UnpauseTimer();
00258 
00265         double GetFrameTime();
00266 
00274         double GetFramerate();
00275 
00285         void SetDesiredFramerate(Uint8 rate);
00286 
00294         Uint8 GetDesiredFramerate();
00295 
00302         bool IsPaused();
00303 
00305     //Event and Input Handling//
00307     private:
00309         bool mNeedReload;
00311         bool mActive;
00313         bool mQuit;
00315         Uint8 *mKeyIsPressed;
00317         bool mKeyPress[SDLK_LAST];
00319         int mMouseX;
00321         int mMouseY;
00323         Uint8 mMouseB;
00324 
00325     public:
00332         bool IsActive();
00333 
00340         void RequestQuit();
00341 
00349         bool QuitRequested();
00350 
00355         void SetReloadNeed(bool state);
00356 
00364         bool ImagesNeedReload();
00365         
00375         void SetKeyRepeatRate(int rate);
00376 
00384         bool KeyIsPressed(SDLKey key);
00385 
00393         bool KeyPress(SDLKey key);
00394 
00400         void HideCursor();
00401 
00407         void ShowCursor();
00408 
00415         int MouseX();
00416 
00423         int MouseY();
00424 
00431         bool LButtonPressed();
00432 
00439         bool RButtonPressed();
00440 
00448         bool MouseInRect(SDL_Rect *rect);
00449 
00455         void CheckEvents();
00456 
00457 #ifdef USE_PHYSFS
00458 
00459     //Physfs Utilities//
00461     public:
00468         void InitPhysFS(string argv);
00469 
00476         void AddPhysFSDir(string dir);
00477 
00478 #endif    //USE_PHYSFS
00479 
00481     //Error Logging//
00483     private:
00485         queue<ZError> mErrorQueue;
00487         ZError mCurError;
00489         bool mLogAllErrors;
00491         FILE *mErrlog;
00492 
00500         void LogError(ZError error);
00501 
00502     public:
00513         void SetErrorLog(bool logAll, string logFile="");
00514 
00525         void ReportError(ZErrorCode code, string desc="", string file="", unsigned int line=0);
00526 
00534         ZErrorCode GetLastError();
00535 
00543         void WriteLog(string str);
00544 
00551         void FlushErrors();
00552 
00553 
00555     //Data Loading + Unloading//
00557     public:
00565         SDL_Surface* LoadImage(string filename);
00566 
00567 #ifdef USE_SDL_MIXER
00568 
00575         Mix_Chunk* LoadSound(string filename);
00576 
00584         Mix_Music* LoadMusic(string filename);
00585 #endif
00586 
00587 #ifdef USE_SDL_TTF
00588 
00596         TTF_Font* LoadFont(string filename, int size);
00597 #endif 
00598 
00600     //Accessors//
00602 
00603     public:    
00610         int Width();
00611 
00618         int Height();
00619 
00626         int BPP();
00627 
00634         bool IsFullscreen();
00635 };
00636 
00637 }
00638 
00639 #endif //__ze_zengine_h__

Generated on Sat Jan 18 17:14:22 2003 for ZEngine by doxygen1.3-rc2