Engine - JayhawkZombie/EECS581Project GitHub Wiki
SFEngine
class SFEngine
in SFEngine > Source > Headers > Engine > Engine.h
This the main Engine class.
The Engine class contains the main logic to handle control flow, timing, window management, and thread execution.
Construction
The engine can only be constructed using a default constructor
SFEngine();
The copy constructors are explicitly deleted.
ONLY ONE INSTANCE OF THE ENGINE SHOULD EXIST. MULTIPLE INSTANCES HAS NOT BEEN TESTED AND THE BEHAVIOR IS UNDEFINED
Methods
UINT32 Go(int argc, char **argv);
- This function is called from within
main
to instruct the engine to begin its startup process. - You should treat this function as if you relinquish complete control of the program to the engine by calling this, as control will not return to main until the engine has completed its shutdown process
- Param(s):
int argc
- the number of command line arguments passed to the program,char **argv
- the actual command line arguments passed to the program. These can simply be forwarded from main - Effects:
- Sets up global
std::terminate
function asEngine::TerminateHandler
, inSFEngine > Source > Definitions > Engine > Go.cpp
- Attempts to call
SFEngine::Init(...);
, and will catch exceptions thrown that prevent a proper startup. The engine will attempt to unwind the exception trace, as instd::string err_string = err.UnwindTrace();
and report the error, then complete shutting down.
- Sets up global
UINT32 Init(int argc, char **argv);
- This function is called from within
SFEngine::Go(...)
and initializes the engine's resources. Currently, it only creates the render window and then callsSFEngine::Startup();
- Effects: For a very short duration, a small 400 x 400 splash screen is created
UINT32 Startup();
- This function is called from within
SFEngine::Init(...);
and is used to officially start up the engine and all of its managers. - Effects
- Engine event handler callbacks are bound
- Engine configuration is read in from
SFEngine > Config > Engine.ini
- A new render window is created with the proper window dimensions as defined in
Engine.ini
- The chaiscript scripting engine is initialized and functions are bound to the scripting engine
- The default level is loaded
- The function calls
SFEngine::GameLoop()
and returns the value returned from the game loop
private UINT32 GameLoop();
- This function is called after all initialization is complete. It is inside
GameLoop
that all game processing is done and where the actual game loop resides (hence the function name). See Main Game Loop for a detailed explanation of the operations occurring within.
private UINT32 Shutdown();
- This function is called at the end of game loop, and it is here that the engine releases all of its resources. It is also from within here that your class's
OnShutDown
function can be called (if your object is still alive at this point).