17 mAppTime(std::make_shared<
AppTime>()),
18 mWindowSystem{ nullptr },
32 mAppTime(std::make_shared<
AppTime>()),
33 mWindowSystem{nullptr},
45 mAppTime(std::make_shared<
AppTime>()),
46 mWindowSystem{ nullptr },
55 std::shared_ptr<IWindowSystem> windowSystem,
56 std::shared_ptr<IRenderer> renderer)
58 bIsFullScreen{ false },
62 mAppTime(std::make_shared<
AppTime>()),
63 mWindowSystem{ windowSystem },
70 std::shared_ptr<IWindowSystem> windowSystem,
71 std::shared_ptr<IRenderer> renderer)
73 bIsFullScreen{ true },
77 mAppTime(std::make_shared<
AppTime>()),
78 mWindowSystem{ windowSystem },
90 LOG_INFO(
"Initializing CoreApplication...");
93 auto startTime = std::chrono::steady_clock::now();
97 LOG_DEBUG(
"Creating StandaloneDesktopWindow...");
98 mWindowSystem = std::make_shared<StandaloneDesktopWindow>(*
this);
106 LOG_INFO(
"Creating application window...");
113 LOG_INFO(
"Fullscreen mode enabled. Resolution set to: "
116 LOG_INFO(
"Initializing renderer...");
119 LOG_INFO(
"Initializing SceneManager...");
123 auto endTime = std::chrono::steady_clock::now();
124 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count();
126 LOG_INFO(
"CoreApplication initialized in " + std::to_string(duration) +
" ms.");
136 const float targetFrameTimeMs =
141 const auto frameStart = std::chrono::steady_clock::now();
146 const auto updateStart = std::chrono::steady_clock::now();
148 const auto updateEnd = std::chrono::steady_clock::now();
150 const auto drawStart = std::chrono::steady_clock::now();
152 const auto drawEnd = std::chrono::steady_clock::now();
154 const auto frameEnd = std::chrono::steady_clock::now();
157 std::chrono::duration<float, std::milli>(updateEnd - updateStart).count();
159 std::chrono::duration<float, std::milli>(drawEnd - drawStart).count();
161 std::chrono::duration<float, std::milli>(frameEnd - frameStart).count();
167 const auto afterMetrics = std::chrono::steady_clock::now();
169 const float actualFrameTimeMs =
170 std::chrono::duration<float, std::milli>(afterMetrics - frameStart).count();
172 if (actualFrameTimeMs < targetFrameTimeMs)
174 const auto sleepDuration =
175 std::chrono::duration<float, std::milli>(
176 targetFrameTimeMs - actualFrameTimeMs);
178 std::this_thread::sleep_for(sleepDuration);
182 const auto frameEndTotal = std::chrono::steady_clock::now();
183 const auto frameLengthTotal = std::chrono::duration<float, std::milli>(frameEndTotal - frameStart).count();
189 const float alpha = 0.1f;
230 LOG_INFO(
"Shutting down CoreApplication...");
232 LOG_DEBUG(
"Shutting down SceneManager...");
236 LOG_DEBUG(
"Shutting down WindowSystem...");
238 LOG_INFO(
"CoreApplication shutdown complete.");
High-resolution clock for updating application time.
Provides time tracking for the application runtime.
Provides high-resolution timing for frame updates.
void Reset()
Resets the clock to the current system time.
void UpdateAppTime(AppTime &appTime)
Updates the given AppTime instance with elapsed and total durations.
Manages current, total, and elapsed time for the application.
std::shared_ptr< SceneManager > mSceneManager
CoreApplication()
Constructs a CoreApplication using settings from the config file.
FrameMetrics mFrameMetrics
FrameMetrics GetFrameMetrics() const override
Returns performance metrics of the last processed frame.
ScreenSettings GetScreenSettings() const override
Retrieves the current screen or window settings.
virtual ~CoreApplication()
std::shared_ptr< IWindowSystem > mWindowSystem
void Draw() override
Executes the rendering logic for the current frame.
void Shutdown() override
Performs cleanup and shuts down the application.
std::shared_ptr< AppTime > mAppTime
void Run() override
Runs the main application loop.
void Update(float deltaTime) override
Updates the application state.
std::shared_ptr< IRenderer > mRenderer
void Initialize() override
Initializes the application and its subsystems.
void Shutdown()
Finalizes logging system and closes the log file.
void Initialize(const std::string &appName)
Initializes logging system and creates a new log file.
static Logger & Get()
Returns singleton logger instance.
static AppConfig ReadConfigFile()
Reads application settings from the JSON config file.
Engine-wide logging system for runtime diagnostics and performance tracking.
float targetFPS
Target frame rate (0 = uncapped).
float screenWidth
Desired window width in pixels (ignored in full-screen mode).
bool isFullScreen
Whether the application should start in full-screen mode.
std::string appName
Name of the application.
float screenHeight
Desired window height in pixels (ignored in full-screen mode).
Stores CPU timing statistics for a rendered frame.
Describes window and display configuration for the application.
std::string name
The window or application name.
unsigned int width
Screen or window width in pixels.
unsigned int height
Screen or window height in pixels.
bool isFullScreen
Whether the application runs in fullscreen mode.