#include <ZE_ZEngine.h>
Public Member Functions | |
void | SetupDisplay (int width, int height, int bpp, bool fullscreen) |
Setup Display for SDL. | |
void | SetupSound (int rate, bool stereo) |
Setup Sound for SDL. | |
bool | CreateDisplay (std::string title, std::string icon="") |
Create Display with predefined settings. | |
void | CloseDisplay () |
Quit SDL and any Subsystems. | |
void | ToggleFullscreen () |
Toggle fullscreen/windowed mode. | |
bool | Initialized () |
Check state of ZEngine. | |
SDL_Surface * | Display () |
Allow access to Screen Surface. | |
void | Update () |
Update display contents. | |
void | Clear (Uint8 red=0, Uint8 green=0, Uint8 blue=0, Uint8 alpha=255) |
Clear screen to a certain color (Black by default). | |
void | SetGL2D () |
Setup OpenGL ortho mode. | |
void | Delay (Uint32 milliseconds) |
Sleep for a certain amount of time. | |
Uint32 | GetTime () |
Get Global ZEngine time. | |
void | PauseTimer () |
Pause ZEngine. | |
void | UnpauseTimer () |
Unpause ZEngine. | |
double | GetFrameTime () |
Get Seconds Per Frame. | |
double | GetFramerate () |
Get Frames Per Second. | |
void | SetDesiredFramerate (Uint8 rate) |
Set Desired Framerate. | |
Uint8 | GetDesiredFramerate () |
Get Desired Framerate. | |
bool | IsPaused () |
Check Engine Paused State. | |
bool | IsActive () |
Find out if application is active. | |
void | RequestQuit () |
Request A Quit. | |
bool | QuitRequested () |
Find out if user has requested to quit. | |
void | SetReloadNeed (bool state) |
Set State of ImagesNeedReload. | |
bool | ImagesNeedReload () |
Find out if images should be reloaded. | |
void | SetKeyRepeatRate (int rate) |
Set Key repeat rate. | |
bool | KeyIsPressed (SDLKey key) |
Find the state of a key. | |
bool | KeyPress (SDLKey key) |
Find if key has been pressed since last check. | |
void | HideCursor () |
Hide mouse cursor. | |
void | ShowCursor () |
Show mouse cursor. | |
int | MouseX () |
Get X Position of Mouse. | |
int | MouseY () |
Get Y Position of Mouse. | |
bool | LButtonPressed () |
Get Status of Left Button. | |
bool | RButtonPressed () |
Get Status of Right Button. | |
bool | MButtonPressed () |
Get status of Middle Button. | |
bool | MouseInRect (SDL_Rect *rect) |
Check if mouse is in given rectangle. | |
bool | MouseInRect (ZRect rect) |
Check if mouse is in given rectangle. | |
void | CheckEvents () |
Check for Activation, Window Manager, and Quit Events. | |
void | SetEventFilter (SDL_EventFilter filter) |
Add a SDL Event Filter for user processing of events. | |
void | SetErrorLog (bool logAll, std::string logFile="") |
Modify Error Logging. | |
void | ReportError (ZErrorCode code, std::string desc="", std::string file="", unsigned int line=0) |
Report an error. | |
ZErrorCode | GetLastError () |
Get the last error. | |
void | WriteLog (std::string str) |
Write to the log. | |
void | FlushErrors () |
Flush Stack of Errors to file. | |
void | SeedRandGen (unsigned long seed) |
Seed random number generator. | |
unsigned int | Rand (unsigned int max) |
Obtain random integer [0,max). | |
unsigned long | Rand (unsigned long max) |
Obtain random integer [0,max). | |
int | Rand (int min, int max) |
Obtain random integer [min,max]. | |
long | Rand (long min, long max) |
Obtain random integer [min,max]. | |
float | Rand (float min, float max) |
Obtain random integer [min,max]. | |
double | Rand (double min, double max) |
Obtain random integer [min,max]. | |
double | RandDouble () |
Obtain random double [0,1). | |
int | DisplayWidth () |
Get Current Display Width. | |
int | DisplayHeight () |
Get Current Display Height. | |
int | DisplayDepth () |
Get Current Display BPP. | |
bool | IsFullscreen () |
Get Fullscreen setting. | |
Static Public Member Functions | |
ZEngine * | GetInstance () |
Get Instance. | |
void | ReleaseInstance () |
Release Instance. | |
Static Public Attributes | |
VersionInfo | Version |
Static version information. | |
Private Member Functions | |
ZEngine () | |
Constructor for ZEngine. | |
void | LogError (ZError error) |
Writes an error to file. | |
Private Attributes | |
int | mWidth |
Width of Display. | |
int | mHeight |
Height of Display. | |
int | mBPP |
BPP Setting of Display. | |
bool | mFullscreen |
Fullscreen setting of Display. | |
bool | mInitialized |
If ZEngine display has been setup. | |
SDL_Surface * | mScreen |
Pointer to Display. | |
bool | mPaused |
Keep track of paused state of game. | |
bool | mUnpauseOnActive |
Keep track of if ZEngine should unpause on active event. | |
Uint8 | mDesiredFramerate |
Value framerate strives to be at, set by SetDesiredFramerate. | |
Uint32 | mNextUpdate |
Time scheduled for next update (used for framerate locked movement). | |
Uint32 | mLastPause |
Keep track of time game was last paused. | |
Uint32 | mPausedTime |
Keep track of total globally paused time. | |
Uint32 | mLastTime |
Keep track of last screen update time. | |
double | mSecPerFrame |
Seconds per frame. | |
bool | mNeedReload |
bool which is only set to true if the engine thinks the images need to be reloaded (loss of focus in fullscreen). | |
bool | mActive |
bool describing Active or Inactive State of Game | |
bool | mQuit |
bool for checking if a Quit event has been detected | |
Uint8 * | mKeyIsPressed |
Pointer to array of Keys. | |
bool | mKeyPress [SDLK_LAST] |
Array of keys, used by KeyPress. | |
int | mMouseX |
X Position of Mouse. | |
int | mMouseY |
Y Position of Mouse. | |
Uint8 | mMouseB |
Mouse Button Information. | |
std::queue< ZError > | mErrorQueue |
Stack of Errors which have occured. | |
ZError | mCurError |
Current error. | |
bool | mLogAllErrors |
Option controlling how logfile is used. | |
std::FILE * | mErrlog |
C-style FILE* for error logging. | |
SDL_EventFilter | mEventFilter |
Event filter, for users who need to process their own events. | |
ZRandGen | mRandGen |
Random Generator for general use. | |
int | mRate |
Sound Bitrate. | |
bool | mStereo |
Stereo setting of Sound Subsystem. | |
Static Private Attributes | |
ZEngine * | sInstance = NULL |
Static Pointer to Instance of ZEngine for Singleton. |
|
Initialize ZEngine values to defaults. (Private so that only one instance may be created.) |
|
Static function, returns pointer to instance of ZEngine, creating an instance if none exist.
|
|
Release memory held by instance of engine and closes window. |
|
Sets display parameters to specified parameters. (called before CreateDisplay)
|
|
Set sound settings to specified parameters. (If not called before CreateDisplay rate will default to 22050+mono)
|
|
SetupDisplay and SetupSound should be called prior to this to change settings, settings from those do not go into effect until this function is called. Specify no icon file to use default icon for OS. Returns result of setting up ZEngine, and logs error if false is returned (Trys not to fail + returns bool in versions >= 0.8.2).
|
|
Shut down SDL (and SDL_ttf,SDL_mixer if necessary) You shouldn't ever have to call this, ReleaseInstance calls this for you. |
|
Safely toggles fullscreen/windowed mode, generally toggling modes will bring the need to reload images so it will set the ImagesNeedReload state to true.
|
|
Checks if ZEngine display has been properly setup.
|
|
Get pointer to screen SDL_Surface, allowing direct screen manipulation using SDL.
|
|
Swap OpenGL buffers, and update screen, if a desired framerate is set it will delay to stay under that rate. Must be called every frame. |
|
Clears a rectangle on screen to a color, defaults to solid black.
|
|
Sets the OpenGL scaled orthographic mode, called once at beginning, no need to call unless you change the OpenGL mode manually. |
|
Freeze everything for given number of milliseconds.
|
|
Get active time since ZEngine initialization in milliseconds, paused time doesn't count.
|
|
Pause ZEngine timer and all ZTimer objects that rely on ZEngine. |
|
Unpause ZEngine timer and all ZTimer objects that rely on ZEngine. |
|
Get double that describes the time passed between screen updates. (should be used for Framerate Independant Movement)
|
|
Get double representing current (approximate) FPS. This value is always the same as 1/GetFrameTime().
|
|
Sets desired framerate, if engine gets ahead of desired rate during a frame it will stall in Update until current framerate is closer to that desired. Acceptable values are 1-255, setting this value to 0 will disable this feature. (Desired framerate is disabled upon initialization of ZEngine.)
|
|
Get desired framerate set by SetDesiredFramerate.
|
|
Find out if engine timer is paused.
|
|
Function to find out if application currently has focus.
|
|
Tell the engine that it should behave as if a Quit was requested, does not call any shutdown functions. |
|
Function to find out if user or operating system has requested program cease execution, can be set by Alt-F4, SDL_Quit event or ZEngine::RequestQuit().
|
|
|
|
Function that is good to call every frame to check if images should be reloaded, usually only caused by loss of focus in fullscreen.
|
|
Calls SDL_EnableKeyRepeat(rate,rate) because usually this is the desired movement style for games. 0 to disable. If 2 different values are needed SDL_EnableKeyRepeat can be called separately: http://sdldoc.csn.ul.ie/sdlenablekeyrepeat.php.
|
|
Function returns true/false based on if key is currently pressed or not. This is used when using keys as buttons, and you need to check if the button/key is currently pressed (ex. arrow keys).
|
|
Function returns true/false based on if key has been pressed since last check. This is what is good to use if you are trying to get user input where a key is only counted once per press. (ex. typing in a name for a high scores list)
|
|
Hide the system mouse cursor. |
|
Show the system mouse cursor. |
|
Find X Position of Mouse on screen.
|
|
Find Y Position of Mouse on screen.
|
|
Get pressed status of left button of mouse.
|
|
Get pressed status of right button of mouse.
|
|
Get pressed status of middle button if available.
|
|
Return status of mouse in current rectangle (eg. GUI buttons).
|
|
Return status of mouse in current rectangle (eg. GUI buttons).
|
|
Cycle through event queue, processing events, updating all Event Related variables, should be called once per frame. |
|
This is only needed when you need tight control with ZEngine. The parameter processed as if it were passed to SDL_SetEventFilter, generally only those with a good amount of SDL experience should use this function or ZEngine's internal message state could be corrupted. For more information on SDL_SetEventFilter see http://sdldoc.csn.ul.ie/sdlseteventfilter.php. (FYI: The parameter is now actually processed in check events, not passed to the SDL function, this is done because of problems with singletons and event threading.)
|
|
Writes error to current error file.
|
|
Change the way errors are logged and the file they are logged to, before calling this errors are logged to stderr. (SDL may define stderr.txt on some platforms.)
|
|
Adds the error to the the error queue, and sets the current error to this error.
|
|
Get the last error reported.
|
|
Write a std::string to the log, allowing special usage of the error log.
|
|
Write the error stack to the error log.
|
|
Reseed Mersenne Twister random number generator. NOTE: Generator is initialized upon creation of object using time.
|
|
Obtain random int l where 0 <= l < max.
|
|
Obtain random long l where 0 <= l < max.
|
|
Obtain random int l where min <= l <= max.
|
|
Obtain random long l where min <= l <= max.
|
|
Obtain random float l where min <= l <= max.
|
|
Obtain random double l where min <= l <= max.
|
|
Obtain random double d where 0 <= d < 1.
|
|
Get Width of Window or Fullscreen mode.
|
|
Get Height of Window or Fullscreen mode.
|
|
Get color depth of Window or Fullscreen mode. BPP means bits per pixel.
|
|
Get Fullscreen setting of Display.
|