![]() |
ezEngine
Release 25.03
|
The base class for all typical game applications made with ezEngine. More...
#include <GameApplication.h>
Public Types | |
using | SUPER = ezGameApplicationBase |
![]() | |
using | SUPER = ezApplication |
Public Member Functions | |
ezGameApplication (const char *szAppName, const char *szProjectPath) | |
szProjectPath may be nullptr, if FindProjectDirectory() is overridden. | |
virtual ezString | FindProjectDirectory () const override |
Implementation of ezGameApplicationBase::FindProjectDirectory to define the 'project' special data directory. More... | |
void | ReinitializeInputConfig () |
Used at runtime (by the editor) to reload input maps. Forwards to Init_ConfigureInput() | |
ezStringView | GetAppProjectPath () const |
Returns the project path that was given to the constructor (or modified by an overridden implementation). | |
![]() | |
ezGameApplicationBase (ezStringView sAppName) | |
void | TakeProfilingCapture () |
Does a profiling capture and writes it to disk at ':appdata'. | |
void | TakeScreenshot () |
Schedules a screenshot to be taken at the end of the frame. More... | |
void | CaptureFrame () |
Schedules a frame capture if the corresponding plugin is loaded. More... | |
void | SetContinuousFrameCapture (bool bEnable) |
Controls if frame captures are taken continuously (without being persisted) or only on-demand. More... | |
bool | GetContinousFrameCapture () const |
virtual ezResult | GetAbsFrameCaptureOutputPath (ezStringBuilder &ref_sOutputPath) |
Get the absolute base output path for frame captures. | |
void | ActivateGameState (ezWorld *pWorld, ezStringView sStartPosition, const ezTransform &startPositionOffset) |
Creates and activates the game state for this application. More... | |
void | DeactivateGameState () |
Deactivates and destroys the active game state. More... | |
ezGameStateBase * | GetActiveGameState () const |
Returns the currently active game state. Could be nullptr. | |
const ezPlatformProfile & | GetPlatformProfile () const |
Returns the ezPlatformProfile that has been loaded for this application. | |
virtual void | Run () override |
Main run function which is called periodically. This function must be overridden. More... | |
void | RunOneFrame () |
ezTime | GetFrameTime () const |
![]() | |
ezApplication (ezStringView sAppName) | |
Constructor. | |
virtual | ~ezApplication () |
Virtual destructor. | |
void | SetApplicationName (ezStringView sAppName) |
Changes the application name. | |
const ezString & | GetApplicationName () const |
Returns the application name. | |
virtual void | AfterHighLevelSystemsShutdown () |
Called after ezStartup::ShutdownHighLevelSystems() has been executed. | |
virtual void | AfterCoreSystemsShutdown () |
This function is called after ezStartup::ShutdownCoreSystems() has been called. More... | |
virtual void | BeforeEnterBackground () |
This function is called when an application is moved to the background. More... | |
virtual void | BeforeEnterForeground () |
This function is called whenever an application is resumed from background mode. More... | |
void | SetReturnCode (ezInt32 iReturnCode) |
Sets the value that the application will return to the OS. You can call this function at any point during execution to update the return value of the application. Default is zero. | |
ezInt32 | GetReturnCode () const |
Returns the currently set value that the application will return to the OS. | |
virtual const char * | TranslateReturnCode () const |
If the return code is not zero, this function might be called to get a string to print the error code in human readable form. | |
void | SetCommandLineArguments (ezUInt32 uiArgumentCount, const char **pArguments) |
Will set the command line arguments that were passed to the app by the OS. This is automatically called by EZ_APPLICATION_ENTRY_POINT(). | |
ezUInt32 | GetArgumentCount () const |
Returns the number of command line arguments that were passed to the application. More... | |
const char * | GetArgument (ezUInt32 uiArgument) const |
Returns one of the command line arguments that was passed to the application. | |
const char ** | GetArgumentsArray () const |
Returns the complete array of command line arguments that were passed to the application. | |
void | EnableMemoryLeakReporting (bool bEnable) |
bool | IsMemoryLeakReportingEnabled () const |
virtual void | RequestApplicationQuit () |
Calling this function requests that the application quits after the current invocation of Run() finishes. More... | |
EZ_ALWAYS_INLINE bool | ShouldApplicationQuit () const |
Returns whether RequestQuit() was called. | |
Static Public Member Functions | |
static ezGameApplication * | GetGameApplicationInstance () |
Returns the ezGameApplication singleton. | |
static ezStringView | GetActiveRenderer () |
Returns the active renderer of the current app. Either the default or overridden via -render command line flag. | |
static void | SetOverrideDefaultDeviceCreator (ezDelegate< ezGALDevice *(const ezGALDeviceCreationDescription &)> creator) |
When the graphics device is created, by default the game application will pick a platform specific implementation. This function allows to override that by setting a custom function that creates a graphics device. | |
![]() | |
static ezGameApplicationBase * | GetGameApplicationBaseInstance () |
Returns the ezGameApplicationBase singleton. | |
![]() | |
static ezApplication * | GetApplicationInstance () |
Returns the one instance of ezApplication that is available. | |
Static Public Attributes | |
static ezCVarBool | cvar_AppVSync |
static ezCVarBool | cvar_AppShowFPS |
Protected Member Functions | |
virtual void | Init_ConfigureInput () override |
virtual void | Init_ConfigureAssetManagement () override |
virtual void | Init_LoadRequiredPlugins () override |
virtual void | Init_SetupDefaultResources () override |
virtual void | Init_SetupGraphicsDevice () override |
virtual void | Deinit_ShutdownGraphicsDevice () override |
virtual bool | IsGameUpdateEnabled () const override |
virtual bool | Run_ProcessApplicationInput () override |
virtual void | Run_AcquireImage () override |
This function can be used to acquire a new window from a swap-chain or do any other update operations on windows before the multi-threaded rendering and update phase starts. | |
virtual void | Run_WorldUpdateAndRender () override |
virtual void | Run_PresentImage () override |
This function can be used to present the final image to a window. It is run at the end of the rendering phase. It can also be used to inspect the swap-chain e.g. for screenshot purposes before presenting. | |
virtual void | Run_FinishFrame () override |
void | RenderFps () |
void | RenderConsole () |
void | UpdateWorldsAndExtractViews () |
![]() | |
virtual void | BeforeHighLevelSystemsShutdown () override |
This function is called after the application main loop has run for the last time, before engine deinitialization. More... | |
virtual void | BeforeCoreSystemsShutdown () override |
This function is called after the application main loop has run for the last time, before engine deinitialization. More... | |
virtual void | Deinit_UnloadPlugins () |
virtual void | Deinit_ShutdownLogging () |
virtual void | StoreScreenshot (ezImage &&image, ezStringView sContext={}) |
Called with the result from taking a screenshot. The default implementation writes the image to disk at ':appdata/Screenshots'. | |
void | ExecuteTakeScreenshot (ezWindowOutputTargetBase *pOutputTarget, ezStringView sContext={}) |
void | ExecuteFrameCapture (ezWindowHandle targetWindowHandle, ezStringView sContext={}) |
virtual ezUniquePtr< ezGameStateBase > | CreateGameState () |
Creates a game state for the application to use. More... | |
virtual void | ActivateGameStateAtStartup () |
Allows to override whether a game state is created and activated at application startup. More... | |
virtual ezResult | BeforeCoreSystemsStartup () override |
This function is called before any kind of engine initialization is done. More... | |
virtual void | AfterCoreSystemsStartup () override |
This function is called after basic engine initialization has been done. More... | |
virtual ezString | GetBaseDataDirectoryPath () const |
Returns the target of the 'base' data directory. More... | |
virtual ezString | GetProjectDataDirectoryPath () const |
Returns the target of the 'project' data directory. More... | |
virtual void | ExecuteBaseInitFunctions () |
Executes all 'BaseInit_' functions. Typically done very early, before core system startup. | |
virtual void | BaseInit_ConfigureLogging () |
virtual void | ExecuteInitFunctions () |
Executes all 'Init_' functions. Typically done after core system startup. | |
virtual void | Init_PlatformProfile_SetPreferred () |
virtual void | Init_ConfigureTelemetry () |
virtual void | Init_FileSystem_SetSpecialDirs () |
virtual void | Init_FileSystem_ConfigureDataDirs () |
virtual void | Init_LoadWorldModuleConfig () |
virtual void | Init_LoadProjectPlugins () |
virtual void | Init_PlatformProfile_LoadForRuntime () |
virtual void | Init_ConfigureTags () |
virtual void | Init_ConfigureCVars () |
virtual void | Run_InputUpdate () |
virtual void | Run_BeforeWorldUpdate () |
virtual void | Run_AfterWorldUpdate () |
virtual void | Run_UpdatePlugins () |
void | UpdateFrameTime () |
Protected Attributes | |
ezString | m_sAppProjectPath |
Stores what is given to the constructor. | |
ezSharedPtr< ezDelegateTask< void > > | m_pUpdateTask |
bool | m_bShowConsole = false |
ezUniquePtr< ezQuakeConsole > | m_pConsole |
![]() | |
bool | m_bTakeScreenshot = false |
ezConsoleFunction< void()> | m_ConFunc_TakeScreenshot |
expose TakeScreenshot() as a console function | |
bool | m_bContinuousFrameCapture = false |
bool | m_bCaptureFrame = false |
ezConsoleFunction< void()> | m_ConFunc_CaptureFrame |
expose CaptureFrame() as a console function | |
ezUniquePtr< ezGameStateBase > | m_pGameState |
ezPlatformProfile | m_PlatformProfile |
ezEventSubscriptionID | m_LogToConsoleID = 0 |
ezEventSubscriptionID | m_LogToVsID = 0 |
ezEvent< const ezGameApplicationStaticEvent & > | m_StaticEvents |
ezTime | m_FrameTime |
![]() | |
bool | m_bWasQuitRequested = false |
Static Protected Attributes | |
static ezGameApplication * | s_pGameApplicationInstance = nullptr |
static ezDelegate< ezGALDevice *(const ezGALDeviceCreationDescription &)> | s_DefaultDeviceCreator |
![]() | |
static ezGameApplicationBase * | s_pGameApplicationBaseInstance = nullptr |
Additional Inherited Members | |
![]() | |
ezCopyOnBroadcastEvent< const ezGameApplicationExecutionEvent & > | m_ExecutionEvents |
The base class for all typical game applications made with ezEngine.
While ezApplication is an abstraction for the operating system entry point, ezGameApplication extends this to implement startup and tear down functionality of a typical game that uses the standard functionality of ezEngine.
ezGameApplication implements a lot of functionality needed by most games, such as setting up data directories, loading plugins, configuring the input system, etc.
For every such step a virtual function is called, allowing to override steps in custom applications.
The default implementation tries to do as much of this in a data-driven way. E.g. plugin and data directory configurations are read from DDL files. These can be configured by hand or using ezEditor.
You are NOT supposed to implement game functionality by deriving from ezGameApplication. Instead see ezGameState.
ezGameApplication will create exactly one ezGameState by looping over all available ezGameState types (through reflection) and picking the one whose DeterminePriority function returns the highest priority. That game state will live throughout the entire application life-time and will be stepped every frame.
|
overridevirtual |
Implementation of ezGameApplicationBase::FindProjectDirectory to define the 'project' special data directory.
The default implementation will try to resolve m_sAppProjectPath to an absolute path. m_sAppProjectPath can be absolute itself, relative to ">sdk/" or relative to ezOSFile::GetApplicationDirectory(). m_sAppProjectPath must be set either via the ezGameApplication constructor or manually set before project.
Alternatively, ezGameApplication::FindProjectDirectory() must be overwritten.
Implements ezGameApplicationBase.
Reimplemented in ezEngineProcessGameApplication.
|
overrideprotectedvirtual |
Reimplemented from ezGameApplicationBase.