8#include <aegis2d/render/export.hpp>
27 using Clock = std::chrono::steady_clock;
30 static constexpr std::size_t capacity = 120;
35 void tick(Clock::time_point now)
noexcept;
39 void record(
double seconds)
noexcept;
46 [[nodiscard]]
std::
size_t size() const noexcept;
52 [[nodiscard]]
double frame_ms(
std::
size_t index) const;
56 [[nodiscard]]
double last_ms() const noexcept;
60 [[nodiscard]]
double average_ms() const noexcept;
64 [[nodiscard]]
double worst_ms() const noexcept;
69 [[nodiscard]]
double fps() const noexcept;
72 std::array<
double, capacity> frames_{};
73 std::size_t next_ = 0;
74 std::size_t size_ = 0;
75 std::optional<Clock::time_point> last_tick_;
113[[nodiscard]] AEGIS2D_RENDER_EXPORT std::string
115 std::optional<std::size_t> memory = std::nullopt,
116 std::span<const std::string> lines = {});
148 void set_visible(
bool visible) noexcept;
151 void toggle() noexcept;
171 std::optional<
std::
size_t> entities =
std::nullopt,
172 std::span<const
std::
string> lines = {});
179 [[nodiscard]] std::optional<std::size_t>
memory() const noexcept;
183 bool visible_ = false;
184 std::
size_t drawn_sprites_ = 0;
185 std::
size_t drawn_batches_ = 0;
186 std::optional<
std::
size_t> memory_;
Text drawn with a bitmap font, through the sprite batcher.
Monospaced font whose glyphs are cells of a texture, drawn as sprites.
Definition bitmap_font.hpp:68
Durations of the last frames, and the frame rate they make.
Definition metrics_overlay.hpp:24
void tick(Clock::time_point now) noexcept
Records the frame that ends at now: the time since the previous tick().
void record(double seconds) noexcept
Records a frame of a given duration; the oldest one is dropped when full.
std::chrono::steady_clock Clock
Clock of tick().
Definition metrics_overlay.hpp:27
void clear() noexcept
Forgets every frame and the last tick().
What the game draws with, whatever the graphics API behind it.
Definition renderer.hpp:81
Overlay of the frame metrics, for developers: frames per second, frame times, entities,...
Definition metrics_overlay.hpp:136
MetricsOverlay(const MetricsOverlayStyle &style={}) noexcept
Hidden overlay.
bool visible() const noexcept
Tells whether the overlay is shown.
std::optional< std::size_t > memory() const noexcept
Memory of the process the overlay shows.
RGBA color used by the renderer.
OpenGL renderer: sprites, text and camera (client only).
Definition bitmap_font.hpp:16
aegis2d::Vec2 Vec2
2D vector of floats, in logical pixels: the engine-wide aegis2d::Vec2.
Definition renderer.hpp:17
constexpr Color rgb(std::uint32_t hex, float alpha=1.0F) noexcept
Color from its hexadecimal sRGB code, as design tools and palettes give it.
Definition color.hpp:25
std::string metrics_text(const FrameMetrics &metrics, FrameStats stats, std::optional< std::size_t > entities, std::optional< std::size_t > memory=std::nullopt, std::span< const std::string > lines={})
Text of the metrics overlay.
Definition endpoint.hpp:85
Backend-independent renderer interface and the sprite it draws.
RGBA color with components in [0, 1].
Definition color.hpp:10
Counters of the last finished frame.
Definition renderer.hpp:64
Where and how the metrics overlay is drawn.
Definition metrics_overlay.hpp:79
float bar_width
Width of a frame's bar, in logical pixels.
Definition metrics_overlay.hpp:87
Color fast
Color of the frames within the budget.
Definition metrics_overlay.hpp:97
double budget_ms
Frame time budget in milliseconds: a line marks it, half way up the graph, and longer frames are draw...
Definition metrics_overlay.hpp:90
float text_scale
Scale of the text (TextStyle::scale).
Definition metrics_overlay.hpp:83
float graph_height
Height of the frame time graph, in logical pixels.
Definition metrics_overlay.hpp:85
Vec2 position
Top-left corner of the panel, in logical pixels.
Definition metrics_overlay.hpp:81
std::int32_t layer
Layer of the panel and the bars; the text is drawn one layer above. Keep both layers for the overlay ...
Definition metrics_overlay.hpp:93
Color slow
Color of the frames over the budget, told from fast with any color vision.
Definition metrics_overlay.hpp:99
Color text
Color of the text.
Definition metrics_overlay.hpp:95
Color panel
Color of the panel behind.
Definition metrics_overlay.hpp:101