DebugHud.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifdef __disabled
  2. //
  3. // Copyright (c) 2008-2014 the Urho3D project.
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #pragma once
  24. #include "../Core/Object.h"
  25. #include "../Core/Timer.h"
  26. namespace Atomic
  27. {
  28. class Engine;
  29. class Font;
  30. class Text;
  31. class XMLFile;
  32. static const unsigned DEBUGHUD_SHOW_NONE = 0x0;
  33. static const unsigned DEBUGHUD_SHOW_STATS = 0x1;
  34. static const unsigned DEBUGHUD_SHOW_MODE = 0x2;
  35. static const unsigned DEBUGHUD_SHOW_PROFILER = 0x4;
  36. static const unsigned DEBUGHUD_SHOW_ALL = 0x7;
  37. /// Displays rendering stats and profiling information.
  38. class ATOMIC_API DebugHud : public Object
  39. {
  40. OBJECT(DebugHud);
  41. public:
  42. /// Construct.
  43. DebugHud(Context* context);
  44. /// Destruct.
  45. ~DebugHud();
  46. /// Update. Called by HandlePostUpdate().
  47. void Update();
  48. /// Set UI elements' style from an XML file.
  49. void SetDefaultStyle(XMLFile* style);
  50. /// Set elements to show.
  51. void SetMode(unsigned mode);
  52. /// Set maximum profiler block depth, default unlimited.
  53. void SetProfilerMaxDepth(unsigned depth);
  54. /// Set profiler accumulation interval in seconds.
  55. void SetProfilerInterval(float interval);
  56. /// Set whether to show 3D geometry primitive/batch count only. Default false.
  57. void SetUseRendererStats(bool enable);
  58. /// Toggle elements.
  59. void Toggle(unsigned mode);
  60. /// Toggle all elements.
  61. void ToggleAll();
  62. /// Return the UI style file.
  63. XMLFile* GetDefaultStyle() const;
  64. /// Return rendering stats text.
  65. Text* GetStatsText() const { return statsText_; }
  66. /// Return rendering mode text.
  67. Text* GetModeText() const { return modeText_; }
  68. /// Return profiler text.
  69. Text* GetProfilerText() const { return profilerText_; }
  70. /// Return currently shown elements.
  71. unsigned GetMode() const { return mode_; }
  72. /// Return maximum profiler block depth.
  73. unsigned GetProfilerMaxDepth() const { return profilerMaxDepth_; }
  74. /// Return profiler accumulation interval in seconds
  75. float GetProfilerInterval() const;
  76. /// Return whether showing 3D geometry primitive/batch count only.
  77. bool GetUseRendererStats() const { return useRendererStats_; }
  78. /// Set application-specific stats.
  79. void SetAppStats(const String& label, const Variant& stats);
  80. /// Set application-specific stats.
  81. void SetAppStats(const String& label, const String& stats);
  82. /// Reset application-specific stats. Return true if it was erased successfully.
  83. bool ResetAppStats(const String& label);
  84. /// Clear all application-specific stats.
  85. void ClearAppStats();
  86. private:
  87. /// Handle logic post-update event. The HUD texts are updated here.
  88. void HandlePostUpdate(StringHash eventType, VariantMap& eventData);
  89. /// Rendering stats text.
  90. SharedPtr<Text> statsText_;
  91. /// Rendering mode text.
  92. SharedPtr<Text> modeText_;
  93. /// Profiling information text.
  94. SharedPtr<Text> profilerText_;
  95. /// Hashmap containing application specific stats.
  96. HashMap<String, String> appStats_;
  97. /// Profiler timer.
  98. Timer profilerTimer_;
  99. /// Profiler max block depth.
  100. unsigned profilerMaxDepth_;
  101. /// Profiler accumulation interval.
  102. unsigned profilerInterval_;
  103. /// Show 3D geometry primitive/batch count flag.
  104. bool useRendererStats_;
  105. /// Current shown-element mode.
  106. unsigned mode_;
  107. };
  108. }
  109. #endif