Simulant  21.12-194
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
stats_panel.h
1 /* * Copyright (c) 2011-2017 Luke Benstead https://simulant-engine.appspot.com
2  *
3  * This file is part of Simulant.
4  *
5  * Simulant is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Simulant is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with Simulant. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include <list>
22 
23 #include "panel.h"
24 #include "../types.h"
25 #include "../generic/managed.h"
26 
27 namespace smlt {
28 
29 class Window;
30 
31 class StatsPanel:
32  public Panel,
33  public RefCounted<StatsPanel> {
34 
35 public:
36  StatsPanel(Window* window);
37 
38  bool init() override;
39  void clean_up() override;
40 private:
41  Window* window_ = nullptr;
42 
43  void do_activate() override;
44  void do_deactivate() override;
45 
46  CameraPtr ui_camera_;
47  PipelinePtr pipeline_;
48 
49  void update();
50 
51  int32_t get_memory_usage_in_megabytes();
52 
53  ui::WidgetPtr fps_;
54  ui::WidgetPtr frame_time_;
55  ui::WidgetPtr ram_usage_;
56  ui::WidgetPtr vram_usage_;
57  ui::WidgetPtr actors_rendered_;
58  ui::WidgetPtr polygons_rendered_;
59  ui::WidgetPtr stage_node_pool_size_;
60 
61  MaterialPtr graph_material_;
62  MeshPtr ram_graph_mesh_;
63  ActorPtr ram_graph_;
64  std::list<float> free_ram_history_;
65 
66  void rebuild_ram_graph();
67 
68  ui::WidgetPtr low_mem_;
69  ui::WidgetPtr high_mem_;
70 
71  sig::connection frame_started_;
72  bool first_update_ = true;
73  float last_update_ = 0.0f;
74 };
75 
76 }
smlt::sig::Connection
Definition: signal.h:65
smlt::RefCounted
Definition: managed.h:65
smlt
Definition: animation.cpp:25
smlt::Panel
Definition: panel.h:29
smlt::Window
Definition: window.h:65
smlt::StatsPanel
Definition: stats_panel.h:33
smlt::default_init_ptr< Camera >