![]() TGE Version 1.5.2 | |
| |
Platform layerOverviewThe platform layer is the foundation of Torque. Running at the lowest level, it provides a common cross platform, cross architecture interface to the system for the game. The platform layer is responsible for handling the details of file and network IO, graphics initialization, device initialization and input, and time event generation. Standard library calls are proxied through the platform layer, so that the game code can be safe from platform specific ideosyncracies.System header files are (pretty much) only included from the platform library. The platform layer is broken up into several sections - the cross-platform interface exposed to the game (engine/platform), and the platform specific libraries (engine/platformWin32, engine/platformMacOS, engine/platformX86UNIX). Event ModelThe game is driven by a stream of events from the platform library. By journaling the stream of events from the platform layer, the game portion of the simulation session can be deterministically replayed for debugging purposes.The events used by the platform layer are all subclasses of Event:
Platform UtilitiesTorque has a number of powerful utility libraries in the platform layer:
Network FunctionalityThe platform library has a common interface for opening and closing network ports, connecting to other hosts, translating network addresses and sending and receiving network data. TCP and UDP are supported.GameInterfaceThe GameInterface class, defined in engine/platform/gameInterface.h, is the interface through which the platform and libraries communicate with the game, as well as the main handler for journaling. All platform events are passed through GameInterface::processEvent(), which in turn feeds them to separate virtual event handlers. One and only one instance of this class (or a subclass) should exist in the program. A single global pointer named Game points to it. |