AppState_Base.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "FpsCounter.h"
  5. #include <Urho3D/Scene/Scene.h>
  6. namespace U3D = Urho3D;
  7. inline const U3D::String CURRENT_FPS_STR = "Current FPS";
  8. class AppState_Base : public U3D::Object
  9. {
  10. public:
  11. URHO3D_OBJECT(AppState_Base, Object);
  12. protected:
  13. U3D::String name_ = "Название бенчмарка";
  14. U3D::SharedPtr<U3D::Scene> scene_;
  15. void LoadSceneXml(const U3D::String& path);
  16. FpsCounter fpsCounter_;
  17. void UpdateCurrentFpsElement();
  18. void SetupViewport();
  19. void DestroyViewport();
  20. public:
  21. const U3D::String& GetName() const { return name_; }
  22. const FpsCounter& GetResult() const { return fpsCounter_; }
  23. AppState_Base(U3D::Context* context)
  24. : Object(context)
  25. {
  26. }
  27. void ClearResult() { fpsCounter_.Clear(); }
  28. virtual void OnEnter()
  29. {
  30. }
  31. virtual void OnLeave()
  32. {
  33. }
  34. };
  35. // Note: scene_ and GUI are destroyed and recreated on every state change so as not to affect other benchmarks