Overlay of the frame metrics, for developers: frames per second, frame times, entities, sprites and draw calls of the frame before, the memory of the process, the game's own lines (its network numbers...), and a bar per frame kept.
More...
#include <aegis2d/render/metrics_overlay.hpp>
Overlay of the frame metrics, for developers: frames per second, frame times, entities, sprites and draw calls of the frame before, the memory of the process, the game's own lines (its network numbers...), and a bar per frame kept.
Hidden by default. The game calls draw() once every frame, shown or not, so that the counts leave out the overlay's own sprites and draw calls.
metrics.
tick(render::FrameMetrics::Clock::now());
}
renderer.begin_frame(background);
overlay.
draw(renderer, font, metrics, registry.size());
renderer.end_frame();
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().
Overlay of the frame metrics, for developers: frames per second, frame times, entities,...
Definition metrics_overlay.hpp:136
void toggle() noexcept
Shows the overlay if hidden, hides it if shown.
void draw(IRenderer &renderer, const BitmapFont &font, const FrameMetrics &metrics, std::optional< std::size_t > entities=std::nullopt, std::span< const std::string > lines={})
Draws the overlay, if shown.
◆ MetricsOverlay()
Hidden overlay.
- Parameters
-
| style | Where and how it is drawn. |
◆ draw()
| void aegis2d::render::MetricsOverlay::draw |
( |
IRenderer & |
renderer, |
|
|
const BitmapFont & |
font, |
|
|
const FrameMetrics & |
metrics, |
|
|
std::optional< std::size_t > |
entities = std::nullopt, |
|
|
std::span< const std::string > |
lines = {} |
|
) |
| |
Draws the overlay, if shown.
- Parameters
-
| renderer | Renderer in a frame. |
| font | Font of the text. |
| metrics | Frame times. |
| entities | Number of entities, or nothing for a program without any. |
| lines | The game's own lines, shown under the others: the numbers of its network connection while it has one, for instance. |
- Exceptions
-
◆ game_stats()
Counters of the renderer's last finished frame, without the overlay.
- Parameters
-
| renderer | Renderer the overlay is drawn with. |
- Returns
renderer.stats() less the sprites and draw calls of the overlay's last draw().
◆ memory()
| std::optional< std::size_t > aegis2d::render::MetricsOverlay::memory |
( |
| ) |
const |
|
noexcept |
Memory of the process the overlay shows.
Asked to the system (core::memory_use()) by draw() while shown, at most every half second.
- Returns
- The bytes, or nothing before the first draw() shown or if the system does not tell.
◆ set_visible()
| void aegis2d::render::MetricsOverlay::set_visible |
( |
bool |
visible | ) |
|
|
noexcept |
Shows or hides the overlay.
- Parameters
-
◆ style()
Where and how the overlay is drawn.
- Returns
- The style given to the constructor.
◆ toggle()
| void aegis2d::render::MetricsOverlay::toggle |
( |
| ) |
|
|
noexcept |
Shows the overlay if hidden, hides it if shown.
◆ visible()
| bool aegis2d::render::MetricsOverlay::visible |
( |
| ) |
const |
|
noexcept |
Tells whether the overlay is shown.
- Returns
false by default.
The documentation for this class was generated from the following file: