![]() TGE Version 1.5.2 | |
| |
Basic Control FlowIntroductionBecause different platforms can have different main() entry points for applications, the Torque Engine main() function resides in the target OS platform library. In the case of Windows, this is in file engine/platformWin32/winWindow.cc, where both main() (for console apps) and WinMain() are defined. These in turn call run() which calls Game->main(int argc, const char **argv). Game is a global object pointer referencing an instance of the GameInterface class that can be overridden for specific game behavior.The Torque example program's main initialization occurs in engine/game/main.cc in DemoGame::main(). This function initializes libraries, initializes game functions and then cycles in the main game loop until the program is terminated. The main loop basically calls platform library functions (engine/platform/platform.h) to produce platform events, which then drive the main simulation. The main.cc file also has DemoGame function overrides for some of the basic event procession functions: processMouseMoveEvent (which dispatches Windows mouse movements to the GUI), processInputEvent (which processes other input related events), and processTimeEvent which computes an elapsed time value based on the time scale setting of the simulation and then:
Incoming UDP network packets are processed in DemoGame::processPacketReceiveEvent (defined in engine/game/netDispatch.cc), and incoming TCP connection data or information is processed in DemoGame::processConnected*Event (defined in engine/game/TCPObject.cc). |