source: trunk/src/debugfps.cpp @ 111

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

The frame counter is now an asset object.

  • Property svn:keywords set to Id
File size: 933 bytes
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 "debugfps.h"
13#include "forge.h"
14
15/*
16 * DebugFps implementation class
17 */
18
19class DebugFpsData
20{
21    friend class DebugFps;
22
23private:
24    Font *font;
25    int frame;
26};
27
28/*
29 * Public DebugFps class
30 */
31
32DebugFps::DebugFps()
33{
34    data = new DebugFpsData();
35
36    data->font = Forge::GetFont("gfx/font/ascii.png");
37    data->frame = 0;
38}
39
40Asset::Group DebugFps::GetGroup()
41{
42    return GROUP_AFTER;
43}
44
45void DebugFps::TickRender(float delta_time)
46{
47    Asset::TickGame(delta_time);
48
49    char buf[1024];
50    sprintf(buf, "%3.2f fps (%i)", 1000.0f / delta_time, data->frame++);
51    data->font->Print(10, 10, buf);
52    data->font->Print(11, 10, buf);
53    data->font->Print(10, 11, buf);
54}
55
56DebugFps::~DebugFps()
57{
58    Forge::ReleaseFont(data->font);
59    delete data;
60}
61
Note: See TracBrowser for help on using the repository browser.