Rendering Engine 0.2.0
Modular Graphics Rendering Engine | v0.2.0
Loading...
Searching...
No Matches
rendering_engine::CoreApplication Class Reference

Default implementation of the IApplication interface. More...

#include <core_application.hpp>

Inherits rendering_engine::IApplication.

Public Member Functions

 CoreApplication ()
 Constructs a CoreApplication using settings from the config file.
 CoreApplication (char const *appName)
 Constructs a CoreApplication with full-screen window size.
 CoreApplication (unsigned int width, unsigned int height, char const *appName)
 Constructs a CoreApplication with explicit window size.
 CoreApplication (unsigned int width, unsigned int height, char const *appName, std::shared_ptr< IWindowSystem > windowSystem, std::shared_ptr< IRenderer > renderer)
 Constructs a CoreApplication with injected subsystems.
 CoreApplication (char const *appName, std::shared_ptr< IWindowSystem > windowSystem, std::shared_ptr< IRenderer > renderer)
 Constructs a CoreApplication with custom systems but default window size.
virtual ~CoreApplication ()
void Initialize () override
 Initializes the application and its subsystems.
void Run () override
 Runs the main application loop.
void Update (float deltaTime) override
 Updates the application state.
void Draw () override
 Executes the rendering logic for the current frame.
void Shutdown () override
 Performs cleanup and shuts down the application.
ScreenSettings GetScreenSettings () const override
 Retrieves the current screen or window settings.
Public Member Functions inherited from rendering_engine::IApplication
virtual ~IApplication ()=default
 Virtual destructor for safe polymorphic deletion.

Protected Attributes

bool bIsFullScreen
unsigned int mWidth
unsigned int mHeight
std::string mAppName
std::shared_ptr< AppTimemAppTime
std::shared_ptr< IWindowSystemmWindowSystem
std::shared_ptr< IRenderermRenderer
std::shared_ptr< SceneManagermSceneManager

Detailed Description

Default implementation of the IApplication interface.

Coordinates the main execution flow of a rendering-based application, including initialization, update, rendering, and shutdown. It acts as the central manager that connects the renderer, window system, and scene management subsystems.

See also
IApplication
IWindowSystem
IRenderer

Definition at line 33 of file core_application.hpp.

Constructor & Destructor Documentation

◆ CoreApplication() [1/5]

rendering_engine::CoreApplication::CoreApplication ( )

Constructs a CoreApplication using settings from the config file.

Loads AppConfig and applies its values to window setup.

Definition at line 13 of file core_application.cpp.

14 :
15 mAppTime(std::make_shared<AppTime>()),
16 mWindowSystem{ nullptr },
17 mRenderer{ nullptr }
18{
19 AppConfig appConfig = Utility::ReadConfigFile();
20
21 mAppName = appConfig.appName.c_str();
22 bIsFullScreen = appConfig.isFullScreen;
23 mWidth = static_cast<unsigned int>(appConfig.screenWidth);
24 mHeight = static_cast<unsigned int>(appConfig.screenHeight);
25}
std::shared_ptr< IWindowSystem > mWindowSystem
std::shared_ptr< AppTime > mAppTime
std::shared_ptr< IRenderer > mRenderer
static AppConfig ReadConfigFile()
Reads application settings from the JSON config file.
Definition utility.cpp:32

◆ CoreApplication() [2/5]

rendering_engine::CoreApplication::CoreApplication ( char const * appName)

Constructs a CoreApplication with full-screen window size.

Parameters
appNameName of the application, used for window caption and logging.

Definition at line 26 of file core_application.cpp.

27 :
28 bIsFullScreen{true},
29 mAppName(appName),
30 mAppTime(std::make_shared<AppTime>()),
31 mWindowSystem{nullptr},
32 mRenderer{nullptr}
33{
34}

◆ CoreApplication() [3/5]

rendering_engine::CoreApplication::CoreApplication ( unsigned int width,
unsigned int height,
char const * appName )

Constructs a CoreApplication with explicit window size.

Parameters
widthWindow width in pixels.
heightWindow height in pixels.
appNameName of the application.

Definition at line 36 of file core_application.cpp.

37 :
38 bIsFullScreen{false},
39 mWidth{width},
40 mHeight{height},
41 mAppName(appName),
42 mAppTime(std::make_shared<AppTime>()),
43 mWindowSystem{ nullptr },
44 mRenderer{ nullptr }
45{
46}

◆ CoreApplication() [4/5]

rendering_engine::CoreApplication::CoreApplication ( unsigned int width,
unsigned int height,
char const * appName,
std::shared_ptr< IWindowSystem > windowSystem,
std::shared_ptr< IRenderer > renderer )

Constructs a CoreApplication with injected subsystems.

Parameters
widthWindow width in pixels.
heightWindow height in pixels.
appNameName of the application.
windowSystemShared pointer to a custom window system implementation.
rendererShared pointer to a custom renderer implementation.

Definition at line 48 of file core_application.cpp.

53 :
54 bIsFullScreen{ false },
55 mWidth{ width },
56 mHeight{ height },
57 mAppName(appName),
58 mAppTime(std::make_shared<AppTime>()),
59 mWindowSystem{ windowSystem },
60 mRenderer{ renderer }
61{}

◆ CoreApplication() [5/5]

rendering_engine::CoreApplication::CoreApplication ( char const * appName,
std::shared_ptr< IWindowSystem > windowSystem,
std::shared_ptr< IRenderer > renderer )

Constructs a CoreApplication with custom systems but default window size.

Parameters
appNameName of the application.
windowSystemShared pointer to a custom window system implementation.
rendererShared pointer to a custom renderer implementation.

Definition at line 63 of file core_application.cpp.

66 :
67 bIsFullScreen{ true },
68 mWidth{ 0 },
69 mHeight{ 0 },
70 mAppName(appName),
71 mAppTime(std::make_shared<AppTime>()),
72 mWindowSystem{ windowSystem },
73 mRenderer{ renderer }
74{}

◆ ~CoreApplication()

rendering_engine::CoreApplication::~CoreApplication ( )
virtual

Definition at line 76 of file core_application.cpp.

76{};

Member Function Documentation

◆ Draw()

void rendering_engine::CoreApplication::Draw ( )
overridevirtual

Executes the rendering logic for the current frame.

Implements rendering_engine::IApplication.

Definition at line 124 of file core_application.cpp.

125{
126 if (mRenderer->BeginFrame())
127 {
128 mRenderer->BeginRenderPass();
129 mSceneManager->Draw();
130 mRenderer->EndRenderPass();
131 mRenderer->EndFrame();
132 }
133}
std::shared_ptr< SceneManager > mSceneManager

◆ GetScreenSettings()

ScreenSettings rendering_engine::CoreApplication::GetScreenSettings ( ) const
overridevirtual

Retrieves the current screen or window settings.

Returns
A structure describing screen configuration parameters.

Implements rendering_engine::IApplication.

Definition at line 143 of file core_application.cpp.

144{
145 ScreenSettings ss;
146 ss.name = mAppName;
147 ss.isFullScreen = bIsFullScreen;
148 ss.height = mHeight;
149 ss.width = mWidth;
150
151 return ss;
152}

◆ Initialize()

void rendering_engine::CoreApplication::Initialize ( )
overridevirtual

Initializes the application and its subsystems.

Implements rendering_engine::IApplication.

Definition at line 78 of file core_application.cpp.

79{
80 if (!mWindowSystem)
81 {
82 mWindowSystem = std::make_shared<StandaloneDesktopWindow>(*this);
83 }
84 if (!mRenderer)
85 {
86 mRenderer = std::make_shared<VulkanRenderer>(*mWindowSystem.get());
87 }
88
89
90 mWindowSystem->CreateAppWindow(mWidth, mHeight, mAppName);
91 if (bIsFullScreen)
92 {
93 mWidth = mWindowSystem->GetFullScreenResolution().width;
94 mHeight = mWindowSystem->GetFullScreenResolution().height;
95 }
96 mRenderer->InitializeRenderer();
97
98 mSceneManager = std::make_shared<SceneManager>(mRenderer.get(), this);
99 mSceneManager->Initialize();
100}

◆ Run()

void rendering_engine::CoreApplication::Run ( )
overridevirtual

Runs the main application loop.

Implements rendering_engine::IApplication.

Definition at line 102 of file core_application.cpp.

103{
104 AppClock appClock;
105 appClock.Reset();
106
107 while (!mWindowSystem->ShouldClose())
108 {
109 appClock.UpdateAppTime(*mAppTime);
110 mWindowSystem->PollEvents();
111 Update(mAppTime->ElapsedAppTimeMilliseconds());
112 Draw();
113 }
114}
void Draw() override
Executes the rendering logic for the current frame.
void Update(float deltaTime) override
Updates the application state.

◆ Shutdown()

void rendering_engine::CoreApplication::Shutdown ( )
overridevirtual

Performs cleanup and shuts down the application.

Implements rendering_engine::IApplication.

Definition at line 135 of file core_application.cpp.

136{
137 mRenderer->WaitIdle();
138 mSceneManager->Shutdown();
139 mRenderer->ShutdownRenderer();
140 mWindowSystem->Shutdown();
141}

◆ Update()

void rendering_engine::CoreApplication::Update ( float deltaTime)
overridevirtual

Updates the application state.

Parameters
deltaTimeTime elapsed since the previous frame, in milliseconds.

Implements rendering_engine::IApplication.

Definition at line 116 of file core_application.cpp.

117{
118 if (mSceneManager)
119 {
120 mSceneManager->Update(deltaTime);
121 }
122}

Member Data Documentation

◆ bIsFullScreen

bool rendering_engine::CoreApplication::bIsFullScreen
protected

Definition at line 94 of file core_application.hpp.

◆ mAppName

std::string rendering_engine::CoreApplication::mAppName
protected

Definition at line 97 of file core_application.hpp.

◆ mAppTime

std::shared_ptr<AppTime> rendering_engine::CoreApplication::mAppTime
protected

Definition at line 99 of file core_application.hpp.

◆ mHeight

unsigned int rendering_engine::CoreApplication::mHeight
protected

Definition at line 96 of file core_application.hpp.

◆ mRenderer

std::shared_ptr<IRenderer> rendering_engine::CoreApplication::mRenderer
protected

Definition at line 101 of file core_application.hpp.

◆ mSceneManager

std::shared_ptr<SceneManager> rendering_engine::CoreApplication::mSceneManager
protected

Definition at line 103 of file core_application.hpp.

◆ mWidth

unsigned int rendering_engine::CoreApplication::mWidth
protected

Definition at line 95 of file core_application.hpp.

◆ mWindowSystem

std::shared_ptr<IWindowSystem> rendering_engine::CoreApplication::mWindowSystem
protected

Definition at line 100 of file core_application.hpp.


The documentation for this class was generated from the following files: