Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

79 строки
1.6 KiB

  1. //
  2. // Deus Hax (working title)
  3. // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
  4. //
  5. #if defined HAVE_CONFIG_H
  6. # include "config.h"
  7. #endif
  8. #include <cstdio>
  9. #include "core.h"
  10. #include "debugfps.h"
  11. /*
  12. * DebugFps implementation class
  13. */
  14. class DebugFpsData
  15. {
  16. friend class DebugFps;
  17. private:
  18. int fontid;
  19. };
  20. /*
  21. * Public DebugFps class
  22. */
  23. DebugFps::DebugFps()
  24. {
  25. data = new DebugFpsData();
  26. data->fontid = Forge::Register("gfx/font/ascii.png");
  27. drawgroup = DRAWGROUP_HUD;
  28. }
  29. void DebugFps::TickDraw(float deltams)
  30. {
  31. Entity::TickDraw(deltams);
  32. char buf[1024];
  33. Font *font = Forge::GetFont(data->fontid);
  34. sprintf(buf, "%2.2f fps (%i)",
  35. 1e3f / Profiler::GetAvg(Profiler::STAT_TICK_FRAME),
  36. Ticker::GetFrameNum());
  37. font->PrintBold(10, 10, buf);
  38. sprintf(buf, "Game % 7.2f % 7.2f",
  39. Profiler::GetAvg(Profiler::STAT_TICK_GAME),
  40. Profiler::GetMax(Profiler::STAT_TICK_GAME));
  41. font->PrintBold(10, 34, buf);
  42. sprintf(buf, "Draw % 7.2f % 7.2f",
  43. Profiler::GetAvg(Profiler::STAT_TICK_DRAW),
  44. Profiler::GetMax(Profiler::STAT_TICK_DRAW));
  45. font->PrintBold(10, 50, buf);
  46. sprintf(buf, "Blit % 7.2f % 7.2f",
  47. Profiler::GetAvg(Profiler::STAT_TICK_BLIT),
  48. Profiler::GetMax(Profiler::STAT_TICK_BLIT));
  49. font->PrintBold(10, 66, buf);
  50. sprintf(buf, "Frame % 7.2f % 7.2f",
  51. Profiler::GetAvg(Profiler::STAT_TICK_FRAME),
  52. Profiler::GetMax(Profiler::STAT_TICK_FRAME));
  53. font->PrintBold(10, 82, buf);
  54. }
  55. DebugFps::~DebugFps()
  56. {
  57. Forge::Deregister(data->fontid);
  58. delete data;
  59. }