engine.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*************************************************************************/
  2. /* engine.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef ENGINE_H
  31. #define ENGINE_H
  32. #include "list.h"
  33. #include "os/main_loop.h"
  34. #include "ustring.h"
  35. #include "vector.h"
  36. class Engine {
  37. friend class Main;
  38. uint64_t frames_drawn;
  39. uint32_t _frame_delay;
  40. uint64_t _frame_ticks;
  41. float _frame_step;
  42. int ips;
  43. float _fps;
  44. int _target_fps;
  45. float _time_scale;
  46. bool _pixel_snap;
  47. uint64_t _physics_frames;
  48. uint64_t _idle_frames;
  49. bool _in_physics;
  50. bool editor_hint;
  51. static Engine *singleton;
  52. public:
  53. static Engine *get_singleton();
  54. virtual void set_iterations_per_second(int p_ips);
  55. virtual int get_iterations_per_second() const;
  56. virtual void set_target_fps(int p_fps);
  57. virtual float get_target_fps() const;
  58. virtual float get_frames_per_second() const { return _fps; }
  59. uint64_t get_frames_drawn();
  60. uint64_t get_physics_frames() const { return _physics_frames; }
  61. uint64_t get_idle_frames() const { return _idle_frames; }
  62. bool is_in_physics_frame() const { return _in_physics; }
  63. uint64_t get_idle_frame_ticks() const { return _frame_ticks; }
  64. float get_idle_frame_step() const { return _frame_step; }
  65. void set_time_scale(float p_scale);
  66. float get_time_scale() const;
  67. void set_frame_delay(uint32_t p_msec);
  68. uint32_t get_frame_delay() const;
  69. _FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; }
  70. #ifdef TOOLS_ENABLED
  71. _FORCE_INLINE_ void set_editor_hint(bool p_enabled) { editor_hint = p_enabled; }
  72. _FORCE_INLINE_ bool is_editor_hint() const { return editor_hint; }
  73. #else
  74. _FORCE_INLINE_ void set_editor_hint(bool p_enabled) {}
  75. _FORCE_INLINE_ bool is_editor_hint() const { return false; }
  76. #endif
  77. Dictionary get_version_info() const;
  78. Engine();
  79. };
  80. #endif // ENGINE_H