engine.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*************************************************************************/
  2. /* engine.cpp */
  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. #include "engine.h"
  30. #include "version.h"
  31. void Engine::set_iterations_per_second(int p_ips) {
  32. ips=p_ips;
  33. }
  34. int Engine::get_iterations_per_second() const {
  35. return ips;
  36. }
  37. void Engine::set_target_fps(int p_fps) {
  38. _target_fps=p_fps>0? p_fps : 0;
  39. }
  40. float Engine::get_target_fps() const {
  41. return _target_fps;
  42. }
  43. uint64_t Engine::get_frames_drawn() {
  44. return frames_drawn;
  45. }
  46. void Engine::set_frame_delay(uint32_t p_msec) {
  47. _frame_delay=p_msec;
  48. }
  49. uint32_t Engine::get_frame_delay() const {
  50. return _frame_delay;
  51. }
  52. void Engine::set_time_scale(float p_scale) {
  53. _time_scale=p_scale;
  54. }
  55. float Engine::get_time_scale() const {
  56. return _time_scale;
  57. }
  58. Dictionary Engine::get_version_info() const {
  59. Dictionary dict;
  60. dict["major"] = VERSION_MAJOR;
  61. dict["minor"] = VERSION_MINOR;
  62. #ifdef VERSION_PATCH
  63. dict["patch"] = VERSION_PATCH;
  64. #else
  65. dict["patch"] = 0;
  66. #endif
  67. dict["status"] = _MKSTR(VERSION_STATUS);
  68. dict["revision"] = _MKSTR(VERSION_REVISION);
  69. dict["year"] = VERSION_YEAR;
  70. String stringver = String(dict["major"]) + "." + String(dict["minor"]);
  71. if ((int)dict["patch"] != 0)
  72. stringver += "." + String(dict["patch"]);
  73. stringver += "-" + String(dict["status"]) + " (" + String(dict["revision"]) + ")";
  74. dict["string"] = stringver;
  75. return dict;
  76. }
  77. Engine *Engine::singleton=NULL;
  78. Engine *Engine::get_singleton() {
  79. return singleton;
  80. }
  81. Engine::Engine()
  82. {
  83. singleton=this;
  84. frames_drawn=0;
  85. ips=60;
  86. _frame_delay=0;
  87. _fps=1;
  88. _target_fps=0;
  89. _time_scale=1.0;
  90. _pixel_snap=false;
  91. _fixed_frames=0;
  92. _idle_frames=0;
  93. _in_fixed=false;
  94. }