Game Development Reference
In-Depth Information
Tip
Inheriting from the
SandboxApplication
class also allows you to override other
functions such as
Update
and
Cleanup
. Any special C++ code can be injected into the
main application through these function hooks.
You should always call the
SandboxApplication
class' original implementation of
these functions if you override them, as they are responsible for cleaning, initializing, and
updating the sandbox.
Creating the source file for the sandbox simply sets the resource location to find our sand-
box Lua scripts and calls the parent class's initialization function.
MySandbox.cpp
:
#include "my_sandbox/include/MySandbox.h"
MySandbox:: MySandbox ()
: SandboxApplication("My Sandbox") {}
MySandbox::~ MySandbox () {}
void MySandbox::Initialize() {
SandboxApplication::Initialize();
// Relative location from the bin/x32/release/ or
// bin/x32/debug folders
AddResourceLocation("../../../src/my_sandbox/script");
}
Finally, you can add the small runner code to kick off your application from
main.cpp
:
main.cpp
:
#include "my_sandbox/include/MySandbox.h"
#include "ogre3d/include/OgreException.h"
#define WIN32_LEAN_AND_MEAN
#include "windows.h"