23 mUpdateLabel(nullptr),
24 mUpdateValue(nullptr),
38 tbProp.
fontName =
"RobotoMono-Medium";
40 const float vertDelta = 25.0f;
41 const float width = 140.0f;
42 const float pad = 5.0f;
43 const float height = vertDelta * 4;
46 rectangleProp.
color = mBgColor;
47 rectangleProp.
size = { width, height };
48 mBackGround = CreateSubobject<Rectangle2D>(rectangleProp);
51 const float middleX = width / 2.0f;
52 const float middleY = height / 2.0f;
53 const float column_0 = -middleX + pad;
54 const float column_1 = column_0 + middleX + pad;
56 const float row_0 = -middleY + tbProp.
fontSize + pad;
57 const float row_1 = row_0 + vertDelta;
58 const float row_2 = row_1 + vertDelta;
59 const float row_3 = row_2 + vertDelta;
61 mFPSLabel = CreateSubobject<TextBlock2D>(tbProp);
66 mFPSValue = CreateSubobject<TextBlock2D>(tbProp);
70 mFrameLabel = CreateSubobject<TextBlock2D>(tbProp);
73 mFrameLabel->
SetPosition(glm::vec2(column_0, row_1));
75 mFrameValue = CreateSubobject<TextBlock2D>(tbProp);
77 mFrameValue->
SetPosition(glm::vec2(column_1, row_1));
79 mUpdateLabel = CreateSubobject<TextBlock2D>(tbProp);
81 mUpdateLabel->
SetText(
"Update:");
82 mUpdateLabel->
SetPosition(glm::vec2(column_0, row_2));
84 mUpdateValue = CreateSubobject<TextBlock2D>(tbProp);
86 mUpdateValue->
SetPosition(glm::vec2(column_1, row_2));
88 mDrawLabel = CreateSubobject<TextBlock2D>(tbProp);
91 mDrawLabel->
SetPosition(glm::vec2(column_0, row_3));
93 mDrawValue = CreateSubobject<TextBlock2D>(tbProp);
95 mDrawValue->
SetPosition(glm::vec2(column_1, row_3));
102 mTimeAccumulator += deltaTime;
103 if (mTimeAccumulator < mUpdateInterval)
106 mTimeAccumulator = 0.0f;
117 fps = frameMetrics.fpsRaw;
121 std::snprintf(bufferFPS,
sizeof(bufferFPS),
"%.2f", fps);
124 char bufferFrame[16];
125 std::snprintf(bufferFrame,
sizeof(bufferFrame),
"%.2f", frameMetrics.frameDurationMs);
126 mFrameValue->
SetText(bufferFrame);
128 char bufferUpdate[16];
129 std::snprintf(bufferUpdate,
sizeof(bufferUpdate),
"%.2f", frameMetrics.updateTimeMs);
130 mUpdateValue->
SetText(bufferUpdate);
133 std::snprintf(bufferDraw,
sizeof(bufferDraw),
"%.2f", frameMetrics.drawTimeMs);
134 mDrawValue->
SetText(bufferDraw);
Base class representing a 2D entity within a Scene.
SceneComponent2D mRootComponent
virtual void Update(float deltaTime)
Updates actor logic and root transform state.
virtual void Initialize()
Initializes the actor after creation.
Scene & GetScene()
Returns the owning Scene.
SceneComponent2D & GetTransform()
Access to the underlying SceneComponent2D (transform).
void SetPosition(const glm::vec2 &position)
Sets the quad position in 2D space.
virtual FrameMetrics GetFrameMetrics() const =0
Returns performance metrics of the last processed frame.
void AttachTo(SceneComponent2D *parent)
Attaches this scene component to a parent scene component.
IApplication * GetApplication()
Returns the application associated with this SceneManager.
Base class representing a renderable scene.
SceneManager & GetSceneManager()
Gets a reference to the SceneManager that owns this scene.
StatsOverlay(Scene &scene)
Constructs a StatsOverlay actor.
void Initialize() override
Creates and positions overlay visual elements.
void Update(float deltaTime) override
Updates displayed statistics each frame.
virtual void SetText(std::string text)
Sets the displayed text.
static AppConfig ReadConfigFile()
Reads application settings from the JSON config file.
Scene::Spawn<T> specializations for built-in drawable types.
bool useSmoothedFPS
Enable FPS smoothing and frame pacing behavior.
std::string fontName
Font family name.
float fontSize
Font size in pixels.