Rendering Engine
0.2.9
Modular Graphics Rendering Engine | v0.2.9
stats_overlay.hpp
Go to the documentation of this file.
1
// This file is part of the Rendering Engine project.
2
// Author: Alexander Obzherin <alexanderobzherin@gmail.com>
3
// Copyright (c) 2026 Alexander Obzherin
4
// Distributed under the terms of the zlib License. See LICENSE.md for details.
5
6
#pragma once
7
8
#include "
actor_2d.hpp
"
9
10
namespace
rendering_engine
11
{
12
class
Rectangle2D;
13
class
TextBlock2D;
14
15
/**
16
* @class StatsOverlay
17
* @brief Displays real-time frame statistics as a 2D overlay.
18
*
19
* StatsOverlay renders a simple performance panel containing:
20
* - FPS
21
* - Frame duration (ms)
22
* - Update time (ms)
23
* - Draw time (ms)
24
*
25
* The overlay is drawn in screen space using Rectangle2D and TextBlock2D
26
* subobjects. Values are updated every frame using FrameMetrics obtained
27
* from the active application.
28
*
29
* Intended for debugging and performance diagnostics.
30
*/
31
class
RE_API
StatsOverlay
:
public
Actor2D
32
{
33
public
:
34
/**
35
* @brief Constructs a StatsOverlay actor.
36
*
37
* Reads configuration options and prepares internal state.
38
*
39
* @param scene Reference to the owning scene.
40
*/
41
StatsOverlay
(
Scene
& scene);
42
/**
43
* @brief Creates and positions overlay visual elements.
44
*
45
* Spawns background rectangle and label/value text blocks,
46
* attaches them to the root component, and arranges them
47
* in a two-column layout.
48
*/
49
void
Initialize()
override
;
50
/**
51
* @brief Updates displayed statistics each frame.
52
*
53
* Retrieves FrameMetrics from the active application and
54
* updates value text blocks accordingly.
55
*
56
* @param deltaTime Time elapsed since previous frame (ms).
57
*/
58
void
Update(
float
deltaTime)
override
;
59
60
private
:
61
Rectangle2D
* mBackGround;
62
63
TextBlock2D
* mFPSLabel;
64
TextBlock2D
* mFPSValue;
65
66
TextBlock2D
* mFrameLabel;
67
TextBlock2D
* mFrameValue;
68
69
TextBlock2D
* mUpdateLabel;
70
TextBlock2D
* mUpdateValue;
71
72
TextBlock2D
* mDrawLabel;
73
TextBlock2D
* mDrawValue;
74
75
glm::vec4 mBgColor{ 0.0f, 0.0f, 1.0f, 0.9f };
76
glm::vec4 mLabelColor{ 0.5f, 0.5f, 0.5f, 1.0f };
77
glm::vec4 mValueColor{ 1.0f, 1.0f, 1.0f, 1.0f };
78
79
bool
bUseSmoothedFPS =
true
;
80
81
float
mTimeAccumulator = 0.0f;
82
const
float
mUpdateInterval = 0.25f;
// seconds
83
};
84
85
}
// namespace rendering_engine
actor_2d.hpp
rendering_engine::Actor2D
Base class representing a 2D entity within a Scene.
Definition:
actor_2d.hpp:46
rendering_engine::Rectangle2D
2D drawable component for rendering rectangle.
Definition:
rectangle_2d.hpp:22
rendering_engine::Scene
Base class representing a renderable scene.
Definition:
scene.hpp:44
rendering_engine::StatsOverlay
Displays real-time frame statistics as a 2D overlay.
Definition:
stats_overlay.hpp:32
rendering_engine::TextBlock2D
2D drawable representing a block of rendered text.
Definition:
text_block_2d.hpp:53
rendering_engine
Definition:
actor.hpp:13
RE_API
#define RE_API
Definition:
rendering_engine_export.hpp:10
RenderingEngine
RenderingLibrary
Include
stats_overlay.hpp
Generated by
1.9.4