Core¶
The core module features the main data structures representing an engine, as well as functions and utility tools to bootstrap them.
The heart is the abstract class REGoth::Engine, which already implements lots
of functionality to run the game.  An engine needs a configuration, which is represented by the
struct REGoth::EngineConfig.  In most cases, the configuration options covered by
REGoth::EngineConfig are enough, so the concrete class REGoth::EmptyGame
(extends REGoth::Engine) can be used.  A concrete example on how to use
REGoth::EmptyGame can be found here.
If the default configuration covered by REGoth::EngineConfig is not enough, it is
best practice to extend directly from REGoth::Engine and implement the function
REGoth::Engine::config().
Make sure that your specialised configuration object extends REGoth::EngineConfig.
For a code example on how employ a custom configuration, see
here.
To construct an REGoth::EngineConfig from command line parameters, the convenience
function REGoth::parseArguments() is provided.  It is best practice to surrender the
ownership of an engine configuration object to the engine by std::move-ing it into the
constructor call.
To run an engine, the convenience function REGoth::runEngine() is provided.
Reference¶
- 
group core
- REGoth core module, in - #include <core.hpp>.- Functions - 
template <class T>
 std::unique_ptr<const T>parseArguments(int argc, char **argv)¶
- Parses the given command line arguments in - argvand returns a newly constructed- EngineConfigof subtype- T.- The returned - EngineConfigcan be used to be- std::moved into an- Enginewhile construction.- Return
- Unique pointer to a newly constructed and valid EngineConfigof subtypeT.
- Note
- A static assertion ensures that Tis anEngineConfig.
- Parameters
- argc: Main’s- argc(argument count).
- argv: Main’s- argv(arguments vector).
 
 
 - 
class EmptyGame: public REGoth::Engine¶
- #include <core/EmptyGame.hpp>A concrete, yet empty REGoth engine which uses the default configuration object EngineConfig.This is a convenience class which can be extended and used if the default configuration object EngineConfigis sufficient, and no custom configuration is needed.If you wish to use a custom configuration, however, Engineshould be extended, andEngine::config()overridden to avoid confusion between different configuration members.Subclassed by REGoth::Gothic1Game, REGoth::Gothic2Game, REGothCharacterMovementTester, REGothCharacterMovementTester, REGothCharacterViewer, REGothFontViewer, REGothMobViewer, REGothScriptTester, REGothWaynetTester, REGothWorldCacheTest, REGothWorldMeshViewer Public Functions Private Members - 
std::unique_ptr<const EngineConfig> mConfig¶
- Engine base configuration. 
 
- 
std::unique_ptr<const EngineConfig> 
 - 
class Engine¶
- #include <core/Engine.hpp>The core class of REGoth, which offers a lot of default implementations to initialize the engine, setup the input, the scene, and others. To handle more use cases, and if a custom EngineConfigis desiredEnginecan be extended (otherwise, seeEmptyGame). The base implementations provided here will not load any world and start on an empty scene, but with most of the utilities set up to load original content and game mechanics.Therefore, the Enginecan be used to implement viewers and other tools, as well as the actual reimplementations of the Gothic games.Some important virtual functions exist which can be overridden: Some pure virtual functions must be implemented: - setupScene(): Set up the scene this engine should handle.
- config(): Return the engine’s configuration. To use a default implementation, see- EmptyGame.
 To actually run an instance of the engine, see runEngine().Subclassed by REGoth::EmptyGame, REGothWorldViewer Public Functions - 
void loadGamePackages()¶
- Load VDFS packages from the original game. - Will load data in the following order: - Data/(- *.vdf)
- _world/(Recursive)
- Data/modvdf/(- *.mod, recursive)
 
 - 
void loadModPackages(const OriginalGameFiles &files)¶
- Called by - loadOriginalGamePackages().- Can be overriden by the user to load specific MOD-packages. - To load a MOD-package, use - gVirtualFileSystem().loadPackage(p).- Parameters
- files: Reference to- OriginalGameFilesobject, which has some utility methods to access files in the original game directory.
 
 
 - 
bool hasFoundGameFiles()¶
- When called after - loadOriginalGamePackages(), this will check whether Gothics game files were found at the location given to- loadOriginalGamePackages().- Return
- Whether game files were found.
 
 - 
void initializeBsf()¶
- Initializes - bsfand opens the window.
 - 
void loadCachedResourceManifests()¶
- Load all resource manifests written by previous runs of REGoth. 
 - 
void populateResourceCache()¶
- Goes through the loaded VDFS packages and imports the original games resources which were not already cached. 
 - 
void saveCachedResourceManifests()¶
- Save resource manifests containing resources loaded during this run. 
 - 
void setupInput()¶
- Assign buttons and axis to control the game. 
 - 
void setupMainCamera()¶
- Sets up the main camera of this engine. 
 - 
virtual void setupScene() = 0¶
- Load scenes and other objects and add them to the scene. 
 - 
void setShaders()¶
- Set shaders to be used when re-caching the materials. 
 - 
void findEngineContent()¶
- Find the location of REGoths own - contentdirectory.
 - 
void run()¶
- Run the main loop. 
 - 
void shutdown()¶
- Shutdown - bsf.
 - 
virtual const EngineConfig *config() const = 0¶
- Grants access to the engine’s configuration. - If you do not need a custom engine configuration, and - EngineConfigis enough, consider extending- EmptyGameinstead of- Engine, which features a default implementation using- EngineConfig.- Return
- The engine configuration data structure.
 
 
 - 
struct EngineConfig¶
- #include <core/EngineConfig.hpp>The base configuration for an Engine.Configuration objects are required to construct an engine. An EngineConfigis the default configuration object, which is used in the definition ofEngine::config(), and which is also the configuration object for the default engine implementationEmptyGame.If a specialised EngineConfigis needed,Enginemust be extended andEngine::config()overridden accordingly.Subclassed by WorldViewerConfig Public Functions - 
~EngineConfig()¶
- Frees acquired resources. 
 - 
void registerCLIEngineOptions(cxxopts::Options &options)¶
- Registers CLI engine options via the given - cxxoptsoptions parameter.- Parameters
- options: A- cxxoptsoptions configurations object.
 
 
 - 
void verifyCLIEngineOptions()¶
- Verifies CLI engine options after parsing. 
 - 
void registerCLIOptions(cxxopts::Options&)¶
- Registers CLI options via the given - cxxoptsoptions parameter.- Parameters
- options: A- cxxoptsoptions configurations object.
 
 
 - 
void verifyCLIOptions()¶
- Verifies CLI options after parsing. 
 Public Members - 
unsigned int verbosity= 0¶
- Verbosity level. - 0 = quiet. The higher, the more verbose. 
 - 
bs::Path engineExecutablePath¶
- Path to the executable of REGoth. 
 - 
bs::Path originalAssetsPath¶
- Path to the game assets of Gothic or Gothic II. 
 - 
GameType gameType= GameType::Unidentified¶
- The current game type (i.e. - Gothic vs Gothic II). 
 - 
unsigned int resolutionX= 1280¶
- X resolution of the game. 
 - 
unsigned int resolutionY= 720¶
- Y resolution of the game. 
 - 
bool isFullscreen= false¶
- Whether the game should be run in fullscreen. 
 - 
Sky::RenderMode skyRenderMode= Sky::RenderMode::Plane¶
- The sky render mode of the game. 
 
- 
 
- 
template <class T>