source: trunk/src/debugfps.cpp @ 210

Last change on this file since 210 was 210, checked in by sam, 11 years ago

Allow for different priorities in game and draw tick levels.

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <cstdio>
11
12#include "core.h"
13#include "debugfps.h"
14
15/*
16 * DebugFps implementation class
17 */
18
19class DebugFpsData
20{
21    friend class DebugFps;
22
23private:
24    int fontid;
25};
26
27/*
28 * Public DebugFps class
29 */
30
31DebugFps::DebugFps()
32{
33    data = new DebugFpsData();
34
35    data->fontid = Forge::Register("gfx/font/ascii.png");
36
37    drawgroup = DRAWGROUP_HUD;
38}
39
40void DebugFps::TickDraw(float deltams)
41{
42    Entity::TickDraw(deltams);
43
44    char buf[1024];
45    Font *font = Forge::GetFont(data->fontid);
46
47    sprintf(buf, "%2.2f fps (%i)",
48            1e3f / Profiler::GetAvg(Profiler::STAT_TICK_FRAME),
49            Ticker::GetFrameNum());
50    font->PrintBold(10, 10, buf);
51
52    sprintf(buf, "Game  % 7.2f % 7.2f",
53            Profiler::GetAvg(Profiler::STAT_TICK_GAME),
54            Profiler::GetMax(Profiler::STAT_TICK_GAME));
55    font->PrintBold(10, 34, buf);
56
57    sprintf(buf, "Draw  % 7.2f % 7.2f",
58            Profiler::GetAvg(Profiler::STAT_TICK_DRAW),
59            Profiler::GetMax(Profiler::STAT_TICK_DRAW));
60    font->PrintBold(10, 50, buf);
61
62    sprintf(buf, "Blit  % 7.2f % 7.2f",
63            Profiler::GetAvg(Profiler::STAT_TICK_BLIT),
64            Profiler::GetMax(Profiler::STAT_TICK_BLIT));
65    font->PrintBold(10, 66, buf);
66
67    sprintf(buf, "Frame % 7.2f % 7.2f",
68            Profiler::GetAvg(Profiler::STAT_TICK_FRAME),
69            Profiler::GetMax(Profiler::STAT_TICK_FRAME));
70    font->PrintBold(10, 82, buf);
71}
72
73DebugFps::~DebugFps()
74{
75    Forge::Deregister(data->fontid);
76    delete data;
77}
78
Note: See TracBrowser for help on using the repository browser.