engine.h 3.3 KB

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