Class for interaction with engine systems. More...
#include <Engine.hpp>
Public Member Functions | |
| Engine (const char *title, int width, int height, GameInfo gInfo) | |
| Constructor for the Engine class. | |
| virtual bool | IsEditor () |
| Returns true if the engine is running in editor mode. | |
| void | run (std::function< void()> onUpdateLoop=nullptr) |
| Starts and runs the main game loop. | |
| vex::Entity | getCamera () |
| Function returning the entity of the camera. | |
| void | setResolutionMode (ResolutionMode mode) |
| Sets the resolution mode and updates the resolution manager. | |
| void | setPaused (bool paused) |
| Internal function for handling pausing and resuming the game. | |
| bool | isPaused () const |
| Function returning the current state of the game. | |
| ResolutionMode | getResolutionMode () const |
| Returns the current resolution mode. | |
| ResolutionManager * | getResolutionManager () const |
| returns a pointer to the resolution manager. | |
| void | setInputMode (InputMode mode) |
| Function allowing for changing input mode at runtime. | |
| InputMode | getInputMode () const |
| Returns the current input mode. | |
| void | setEnvironmentSettings (environment settings) |
| Applies new global environment settings (lighting, shading) to the interface. | |
| environment | getEnvironmentSettings () |
| Returns the current environment settings. | |
| Interface * | getInterface () |
| Returns Interface, used internally. | |
| std::shared_ptr< VirtualFileSystem > | getFileSystem () |
| Returns std::shared_ptr of VirtualFileSystem. | |
| vex::Registry & | getRegistry () |
| Returns a reference to vex::Registry. | |
| PhysicsSystem * | getPhysicsSystem () |
| Returns pointer to PhysicsSystem. | |
| SceneManager * | getSceneManager () |
| Returns pointer to SceneManager. | |
| std::shared_ptr< VexUI > | createVexUI () |
| Creates and returns a shared pointer to a VexUI instance. | |
| int | GetCurrentFrame () |
| Returns current frame number. | |
| void | setRenderPhysicsDebug (bool value) |
| Function to enable/disable rendering collision shapes. | |
| virtual void | setFullscreen (bool enabled, bool exclusive=false) |
| Function to enable/disable fullscreen mode. with optional exclusive parameter. | |
| bool | isFullscreen () |
| Function to check if fullscreen mode is enabled. | |
| std::vector< std::string > | getLastLoadedScenes () |
| Function to get the last loaded scenes. | |
| void | prepareScenesForHotReload () |
| Prepares the engine for a hot-reload event. | |
| virtual void | processEvent (const SDL_Event &event, float deltaTime) |
| Internal virtual function for handling window/keyboard events. | |
| virtual void | beginGame () |
| Internal virtual function for handling stuff right at the beginning of the game but after initialization of the engine. | |
| virtual void | update (float deltaTime) |
| Internal function for handling updates; called every frame before rendering. | |
| virtual void | render () |
| Internal function that orchestrates the frame rendering process. | |
| virtual void | refreshForObject () |
| Internal virtual function for editor. | |
| void | quit () |
| Simply sets m_running to false, Effectivelly soft shuting down the engine. | |
| void | WaitForGpu () |
| Waits for the GPU to finish all pending operations. | |
| void | setFrameLimit (int fps) |
| Sets the target frame rate limit. | |
| int | getFrameLimit () const |
| void | setVSync (bool enabled) |
| Toggles VSync (Vertical Synchronization). | |
| bool | getVSync () const |
| Returns the current state of VSync. | |
| float | getDeltaTime () const |
| Returns the time since last frame. | |
| std::shared_ptr< AudioSystem > | getAudioSystem () const |
| Returns the audio system. | |
Static Public Member Functions | |
| static const char * | GetBuildHash () |
| returns engine hash generated during build process. | |
| static int | GetVersionMajor () |
| Returns the major version of the engine. | |
| static int | GetVersionMinor () |
| Returns the minor version of the engine. | |
| static int | GetVersionPatch () |
| Returns the patch version of the engine. | |
| static const char * | GetVersionString () |
| Returns the version string of the engine. | |
Protected Member Functions | |
| Engine (SkipInit) | |
| Alternative constructor for editor to skip default init code. | |
Protected Attributes | |
| std::shared_ptr< Window > | m_window |
| std::shared_ptr< VirtualFileSystem > | m_vfs |
| std::shared_ptr< AudioSystem > | m_audioSystem |
| std::unique_ptr< Interface > | m_interface |
| std::unique_ptr< ResolutionManager > | m_resolutionManager |
| std::unique_ptr< ImGUIWrapper > | m_imgui |
| std::unique_ptr< InputSystem > | m_inputSystem |
| std::unique_ptr< PhysicsSystem > | m_physicsSystem |
| std::unique_ptr< SceneManager > | m_sceneManager |
| vex::Registry | m_registry |
| bool | m_running = true |
| bool | m_paused = false |
| bool | m_internally_paused = false |
| bool | m_renderPhysicsDebug = false |
| int | m_frame = 0 |
| int | m_targetFps = 0 |
| bool | m_vsyncEnabled = false |
| float | m_deltaTime = 0.016f |
| GameInfo | m_gameInfo |
| std::vector< std::string > | lastLoadedScenes |
Class for interaction with engine systems.
Definition at line 47 of file Engine.hpp.
| vex::Engine::Engine | ( | const char * | title, |
| int | width, | ||
| int | height, | ||
| GameInfo | gInfo ) |
Constructor for the Engine class.
Initializes the core systems in the following order:
| const | char* title - Title of the game window. |
| int | width - Initial width of the game window. |
| int | height - Initial height of the game window. |
| GameInfo | gInfo - Game Info struct containing versioning and metadata. |
Definition at line 46 of file Engine.cpp.
| vex::Engine::~Engine | ( | ) |
Definition at line 220 of file Engine.cpp.
|
protected |
Alternative constructor for editor to skip default init code.
Definition at line 234 of file Engine.cpp.
|
virtual |
Internal virtual function for handling stuff right at the beginning of the game but after initialization of the engine.
Definition at line 316 of file Engine.cpp.
| std::shared_ptr< VexUI > vex::Engine::createVexUI | ( | ) |
Creates and returns a shared pointer to a VexUI instance.
Constructs a VexUI object linked to the current Vulkan context, VFS, and resource manager.
Definition at line 110 of file Engine.cpp.
|
inline |
Returns the audio system.
Definition at line 235 of file Engine.hpp.
|
static |
returns engine hash generated during build process.
Definition at line 98 of file Engine.cpp.
|
inline |
Function returning the entity of the camera.
Definition at line 93 of file Engine.hpp.
|
inline |
Returns current frame number.
Definition at line 161 of file Engine.hpp.
|
inline |
Returns the time since last frame.
Definition at line 232 of file Engine.hpp.
| environment vex::Engine::getEnvironmentSettings | ( | ) |
Returns the current environment settings.
Definition at line 249 of file Engine.cpp.
|
inline |
Returns std::shared_ptr of VirtualFileSystem.
Definition at line 144 of file Engine.hpp.
|
inline |
Definition at line 223 of file Engine.hpp.
|
inline |
Returns the current input mode.
Definition at line 130 of file Engine.hpp.
| Interface * vex::Engine::getInterface | ( | ) |
Returns Interface, used internally.
Definition at line 106 of file Engine.cpp.
|
inline |
Function to get the last loaded scenes.
Definition at line 176 of file Engine.hpp.
|
inline |
Returns pointer to PhysicsSystem.
Definition at line 150 of file Engine.hpp.
|
inline |
Returns a reference to vex::Registry.
Definition at line 147 of file Engine.hpp.
|
inline |
returns a pointer to the resolution manager.
Definition at line 122 of file Engine.hpp.
|
inline |
Returns the current resolution mode.
Definition at line 118 of file Engine.hpp.
| SceneManager * vex::Engine::getSceneManager | ( | ) |
Returns pointer to SceneManager.
Definition at line 102 of file Engine.cpp.
|
static |
Returns the major version of the engine.
Definition at line 30 of file Engine.cpp.
|
static |
Returns the minor version of the engine.
Definition at line 34 of file Engine.cpp.
|
static |
Returns the patch version of the engine.
Definition at line 38 of file Engine.cpp.
|
static |
Returns the version string of the engine.
Definition at line 42 of file Engine.cpp.
| bool vex::Engine::getVSync | ( | ) | const |
Returns the current state of VSync.
Definition at line 216 of file Engine.cpp.
|
inlinevirtual |
Returns true if the engine is running in editor mode.
Reimplemented in vex::Editor.
Definition at line 80 of file Engine.hpp.
| bool vex::Engine::isFullscreen | ( | ) |
Function to check if fullscreen mode is enabled.
Definition at line 259 of file Engine.cpp.
|
inline |
Function returning the current state of the game.
Definition at line 114 of file Engine.hpp.
| void vex::Engine::prepareScenesForHotReload | ( | ) |
Prepares the engine for a hot-reload event.
Snapshots the names of currently loaded scenes into lastLoadedScenes via SceneManager::GetAllSceneNames so they can be restored after the reload.
Definition at line 263 of file Engine.cpp.
|
virtual |
Internal virtual function for handling window/keyboard events.
Delegates processing to the InputSystem.
| const | SDL_Event& event - The SDL event to process. |
| float | deltaTime - Time since last frame. |
Reimplemented in vex::Editor.
Definition at line 267 of file Engine.cpp.
|
inline |
Simply sets m_running to false, Effectivelly soft shuting down the engine.
Definition at line 213 of file Engine.hpp.
|
inlinevirtual |
Internal virtual function for editor.
Reimplemented in vex::Editor.
Definition at line 208 of file Engine.hpp.
|
virtual |
Internal function that orchestrates the frame rendering process.
| std::exception | - If frame rendering fails, logging the error before handling. |
Reimplemented in vex::DialogWindow, vex::Editor, and vex::ProjectSelector.
Definition at line 317 of file Engine.cpp.
| void vex::Engine::run | ( | std::function< void()> | onUpdateLoop = nullptr | ) |
Starts and runs the main game loop.
Handles the lifecycle of the application, including:
| std::function<void()> | onUpdateLoop - Optional callback function, primarily used for hot-reload logic to inject code into the loop. |
Definition at line 114 of file Engine.cpp.
| void vex::Engine::setEnvironmentSettings | ( | environment | settings | ) |
Applies new global environment settings (lighting, shading) to the interface.
| environment | settings - The new environment configuration struct. |
Definition at line 245 of file Engine.cpp.
| void vex::Engine::setFrameLimit | ( | int | fps | ) |
Sets the target frame rate limit.
Uses SDL_Delay in the main loop to sleep if the frame completes faster than the target time.
| int | fps - Target FPS. Pass 0 to disable the limit (unlimited FPS). |
Definition at line 203 of file Engine.cpp.
|
virtual |
Function to enable/disable fullscreen mode. with optional exclusive parameter.
| bool | enabled - True to enable, false to disable. |
| bool | exclusive - True to enable exclusive fullscreen mode, false to disable. |
Reimplemented in vex::Editor.
Definition at line 253 of file Engine.cpp.
|
inline |
Function allowing for changing input mode at runtime.
| InputMode | mode - Enum storing input modes. |
Definition at line 126 of file Engine.hpp.
|
inline |
Internal function for handling pausing and resuming the game.
| bool | paused - Whether the game should be paused or resumed. |
Definition at line 110 of file Engine.hpp.
|
inline |
Function to enable/disable rendering collision shapes.
| bool | value - True to enable, false to disable. |
Definition at line 165 of file Engine.hpp.
| void vex::Engine::setResolutionMode | ( | ResolutionMode | mode | ) |
Sets the resolution mode and updates the resolution manager.
| ResolutionMode | mode - The new resolution mode (e.g., NATIVE, PS1_SHARP). |
Definition at line 238 of file Engine.cpp.
| void vex::Engine::setVSync | ( | bool | enabled | ) |
Toggles VSync (Vertical Synchronization).
Definition at line 207 of file Engine.cpp.
|
virtual |
Internal function for handling updates; called every frame before rendering.
Updates the InputSystem, initializes/updates dynamic UiComponents, and steps the SceneManager and PhysicsSystem. Skips scene and physics updates if the engine is paused (m_paused or m_internally_paused).
| float | deltaTime - Time elapsed since the last frame in seconds. |
Reimplemented in vex::Editor.
Definition at line 271 of file Engine.cpp.
| void vex::Engine::WaitForGpu | ( | ) |
Waits for the GPU to finish all pending operations.
Essential to call before destroying resources (e.g., during shutdown or scene transitions) to prevent Vulkan validation errors or crashes.
Definition at line 197 of file Engine.cpp.
|
protected |
Definition at line 271 of file Engine.hpp.
|
protected |
Definition at line 244 of file Engine.hpp.
|
protected |
Definition at line 264 of file Engine.hpp.
|
protected |
Definition at line 259 of file Engine.hpp.
|
protected |
Definition at line 270 of file Engine.hpp.
|
protected |
Definition at line 248 of file Engine.hpp.
|
protected |
Definition at line 249 of file Engine.hpp.
|
protected |
Definition at line 246 of file Engine.hpp.
|
protected |
Definition at line 257 of file Engine.hpp.
|
protected |
Definition at line 256 of file Engine.hpp.
|
protected |
Definition at line 250 of file Engine.hpp.
|
protected |
Definition at line 253 of file Engine.hpp.
|
protected |
Definition at line 258 of file Engine.hpp.
|
protected |
Definition at line 247 of file Engine.hpp.
|
protected |
Definition at line 255 of file Engine.hpp.
|
protected |
Definition at line 251 of file Engine.hpp.
|
protected |
Definition at line 261 of file Engine.hpp.
|
protected |
Definition at line 243 of file Engine.hpp.
|
protected |
Definition at line 262 of file Engine.hpp.
|
protected |
Definition at line 242 of file Engine.hpp.