|
static void | createSystems (GameState **outGraphicsGameState, GraphicsSystem **outGraphicsSystem, GameState **outLogicGameState, LogicSystem **outLogicSystem) |
| Creates the system for the helper functions in Common framework to use in mainAppVarible & co. More...
|
|
static void | destroySystems (GameState *graphicsGameState, GraphicsSystem *graphicsSystem, GameState *logicGameState, LogicSystem *logicSystem) |
| Destroys the systems created via createSystems. Implementation should check for null pointers. More...
|
|
static const char * | getWindowTitle (void) |
|
static INT WINAPI | mainAppSingleThreaded (HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR strCmdLine, INT nCmdShow) |
|
static INT WINAPI | mainAppMultiThreaded (HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR strCmdLine, INT nCmdShow) |
|
Most of our demos use the same basic setup for game loop.
If you want to understand how it works in depth, see Tutorial01_Initialization through Tutorial06_Multithreading
- We believe the developer should be in charge of their entry points. Problem is, not all platforms are the same: On Linux you should use int main( int argc, const char *argv[] ); On Windows you should use WinMain (windows apps) or int main like in Linux (console) On iOS you must declare int main, but Apple really want you to use an AppDelegate. On Android you the entry point is loaded then executed from your Java code.
Some frameworks address this problem by forcing you to derive from some arbitrary class, or using macros. We don't force you to do anything, but we provide utility functions if you don't want to deal with issue.
- If you are a beginner or just want to go straight to coding an Ogre app: Follow exactly what most samples do (e.g. StereoRendering, DynamicGeometry, CustomRenderable):
- #include "MainEntryPointHelper.h"
- #include "System/MainEntryPoints.h"
- Define createSystems (& destroySystems) where you allocate the systems this framework needs. You can subclass these systems to override functionality. GraphicsSystem::update and GameState::update get called every frame.
- Declare int mainApp (or INT WINAPI WinMainApp) where you either choose to delegate to: MainEntryPoints::mainAppSingleThreaded This entry point will behave exactly the same as Tutorial04_InterpolationLoop. If you just want variable framerate, you could just avoid allocating LogicSystem. MainEntryPoints::mainAppMultiThreaded This entry point will behave exactly the same as Tutorial06_Multithreading. You must allocate LogicSystem if you use this one.
- Overload GraphicsSystem, LogicSystem (optional), GameState (for graphics) and GameState (for Logic, optional) to do your work. If in doubt, just copy-paste a simple sample like StereoRendering or CustomRenderable and work from there. Or ShadowMapDebugging/PbsMaterials if you like more advanced samples but still easy to grasp.
- If you're a power user and want full control: The header "MainEntryPointHelper.h" declares the actual main/WinMain on desktop OSes We will do some minor maintenance work there, then call mainApp. You can either avoid including MainEntryPointHelper.h entirely and define the entry point yourself, or work on mainApp instead. Or you can modify the code MainEntryPointHelper.h, it's not an integral part of Ogre. The choice is up to you.
The members createSystems, destroySystems, getWindowTitle & Frametime are used by the functionality provided in mainAppSingleThreaded & mainAppMultiThreaded. If you decide to not use one of these two functions, then the mentioned members (createSystems & co.) are useless to you.
On iOS, we provide an AppDelegate and our main() implementation will try to instantiate it. These two (AppDelegate + main) are located in Samples/2.0/Common/src/System/iOS. If you need a different AppDelegate, change those sources. The files Info.plist & Main.storyboard under the folder Samples/2.0/Common/src/System/iOS/Resources are configured to load GameViewController which is also declared in one of our .mm files. If you wish to use your own controller, tweak the plist and storyboard files. Or just modify GameViewController.mm instead.