Add possibility to limit frame to main loop (application/target_fps)
target-fps working, and use fixed physics step before adding physics-fps in project setting Complete implementation of framelimit Conflicts: main/main.cpp
This commit is contained in:
@ -199,6 +199,14 @@ int _OS::get_iterations_per_second() const {
|
||||
|
||||
}
|
||||
|
||||
void _OS::set_target_fps(int p_fps) {
|
||||
OS::get_singleton()->set_target_fps(p_fps);
|
||||
}
|
||||
|
||||
float _OS::get_target_fps() const {
|
||||
return OS::get_singleton()->get_target_fps();
|
||||
}
|
||||
|
||||
void _OS::set_low_processor_usage_mode(bool p_enabled) {
|
||||
|
||||
OS::get_singleton()->set_low_processor_usage_mode(p_enabled);
|
||||
@ -537,6 +545,8 @@ void _OS::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_iterations_per_second","iterations_per_second"),&_OS::set_iterations_per_second);
|
||||
ObjectTypeDB::bind_method(_MD("get_iterations_per_second"),&_OS::get_iterations_per_second);
|
||||
ObjectTypeDB::bind_method(_MD("set_target_fps","target_fps"),&_OS::set_target_fps);
|
||||
ObjectTypeDB::bind_method(_MD("get_target_fps"),&_OS::get_target_fps);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("has_touchscreen_ui_hint"),&_OS::has_touchscreen_ui_hint);
|
||||
|
||||
|
||||
@ -106,6 +106,9 @@ public:
|
||||
void set_iterations_per_second(int p_ips);
|
||||
int get_iterations_per_second() const;
|
||||
|
||||
void set_target_fps(int p_fps);
|
||||
float get_target_fps() const;
|
||||
|
||||
void set_low_processor_usage_mode(bool p_enabled);
|
||||
bool is_in_low_processor_usage_mode() const;
|
||||
|
||||
|
||||
@ -92,6 +92,14 @@ int OS::get_iterations_per_second() const {
|
||||
return ips;
|
||||
}
|
||||
|
||||
void OS::set_target_fps(int p_fps) {
|
||||
_target_fps=p_fps>0? p_fps : 0;
|
||||
}
|
||||
|
||||
float OS::get_target_fps() const {
|
||||
return _target_fps;
|
||||
}
|
||||
|
||||
void OS::set_low_processor_usage_mode(bool p_enabled) {
|
||||
|
||||
low_processor_usage_mode=p_enabled;
|
||||
@ -474,6 +482,7 @@ OS::OS() {
|
||||
_exit_code=0;
|
||||
_orientation=SCREEN_LANDSCAPE;
|
||||
_fps=1;
|
||||
_target_fps=0;
|
||||
_render_thread_mode=RENDER_THREAD_SAFE;
|
||||
Math::seed(1234567);
|
||||
}
|
||||
|
||||
@ -54,6 +54,7 @@ class OS {
|
||||
int _exit_code;
|
||||
int _orientation;
|
||||
float _fps;
|
||||
int _target_fps;
|
||||
|
||||
char *last_error;
|
||||
|
||||
@ -149,8 +150,12 @@ public:
|
||||
virtual void set_iterations_per_second(int p_ips);
|
||||
virtual int get_iterations_per_second() const;
|
||||
|
||||
virtual void set_target_fps(int p_fps);
|
||||
virtual float get_target_fps() const;
|
||||
|
||||
virtual float get_frames_per_second() const { return _fps; };
|
||||
|
||||
|
||||
virtual void set_low_processor_usage_mode(bool p_enabled);
|
||||
virtual bool is_in_low_processor_usage_mode() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user