editor: improve engine_tick powersave feature
parent
e4b736e98a
commit
4fd3e9cd67
2
MAKE.bat
2
MAKE.bat
|
@ -40,7 +40,7 @@ if "%1"=="help" (
|
||||||
echo %0 [amalgamation] ; combine engine/v4k* into a single-header file
|
echo %0 [amalgamation] ; combine engine/v4k* into a single-header file
|
||||||
echo %0 [prep] ; combine split files into a single-header file, ready for use
|
echo %0 [prep] ; combine split files into a single-header file, ready for use
|
||||||
echo %0 [sln] ; generate a xcode/gmake/ninja/visual studio solution
|
echo %0 [sln] ; generate a xcode/gmake/ninja/visual studio solution
|
||||||
echo %0 [addons[ names ] ] ; specify list of addons you want to compile with the engine
|
echo %0 [addons[ names ] ] ; specify list of addons you want to compile with the engine
|
||||||
echo %0 [cl^|tcc^|cc^|gcc^|clang^|clang-cl] [dbg^|dev^|rel^|ret] [static^|dll] [nov4k^|nodemos^|editor] [vis] [-- args]
|
echo %0 [cl^|tcc^|cc^|gcc^|clang^|clang-cl] [dbg^|dev^|rel^|ret] [static^|dll] [nov4k^|nodemos^|editor] [vis] [-- args]
|
||||||
echo cl \
|
echo cl \
|
||||||
echo tcc ^|
|
echo tcc ^|
|
||||||
|
|
|
@ -382161,16 +382161,18 @@ int engine_send(const char *cmd, const char *optional_value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int engine_tick() {
|
int engine_tick() {
|
||||||
enum { engine_hz = 60 };
|
enum { engine_hz_mid = 30 };
|
||||||
enum { engine_hz_mid = 18 };
|
enum { engine_hz_low = 10 };
|
||||||
enum { engine_hz_low = 5 };
|
static double old_hz = 0.0;
|
||||||
if( *engine_geti("powersave") ) {
|
if( *engine_geti("powersave") ) {
|
||||||
// adaptive framerate
|
// adaptive framerate
|
||||||
int app_on_background = !window_has_focus();
|
int app_on_background = !window_has_focus();
|
||||||
int hz = app_on_background ? engine_hz_low : engine_hz_mid;
|
int hz = app_on_background ? engine_hz_low : engine_hz_mid;
|
||||||
window_fps_lock( hz < 5 ? 5 : hz );
|
if (!old_hz) old_hz = window_fps_target();
|
||||||
} else {
|
window_fps_lock( hz );
|
||||||
// window_fps_lock( editor_hz );
|
} else if( old_hz && old_hz != window_fps_target() ) {
|
||||||
|
window_fps_lock( old_hz );
|
||||||
|
old_hz = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -139,16 +139,18 @@ int engine_send(const char *cmd, const char *optional_value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int engine_tick() {
|
int engine_tick() {
|
||||||
enum { engine_hz = 60 };
|
enum { engine_hz_mid = 30 };
|
||||||
enum { engine_hz_mid = 18 };
|
enum { engine_hz_low = 10 };
|
||||||
enum { engine_hz_low = 5 };
|
static double old_hz = 0.0;
|
||||||
if( *engine_geti("powersave") ) {
|
if( *engine_geti("powersave") ) {
|
||||||
// adaptive framerate
|
// adaptive framerate
|
||||||
int app_on_background = !window_has_focus();
|
int app_on_background = !window_has_focus();
|
||||||
int hz = app_on_background ? engine_hz_low : engine_hz_mid;
|
int hz = app_on_background ? engine_hz_low : engine_hz_mid;
|
||||||
window_fps_lock( hz < 5 ? 5 : hz );
|
if (!old_hz) old_hz = window_fps_target();
|
||||||
} else {
|
window_fps_lock( hz );
|
||||||
// window_fps_lock( editor_hz );
|
} else if( old_hz && old_hz != window_fps_target() ) {
|
||||||
|
window_fps_lock( old_hz );
|
||||||
|
old_hz = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
14
engine/v4k.c
14
engine/v4k.c
|
@ -29305,16 +29305,18 @@ int engine_send(const char *cmd, const char *optional_value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int engine_tick() {
|
int engine_tick() {
|
||||||
enum { engine_hz = 60 };
|
enum { engine_hz_mid = 30 };
|
||||||
enum { engine_hz_mid = 18 };
|
enum { engine_hz_low = 10 };
|
||||||
enum { engine_hz_low = 5 };
|
static double old_hz = 0.0;
|
||||||
if( *engine_geti("powersave") ) {
|
if( *engine_geti("powersave") ) {
|
||||||
// adaptive framerate
|
// adaptive framerate
|
||||||
int app_on_background = !window_has_focus();
|
int app_on_background = !window_has_focus();
|
||||||
int hz = app_on_background ? engine_hz_low : engine_hz_mid;
|
int hz = app_on_background ? engine_hz_low : engine_hz_mid;
|
||||||
window_fps_lock( hz < 5 ? 5 : hz );
|
if (!old_hz) old_hz = window_fps_target();
|
||||||
} else {
|
window_fps_lock( hz );
|
||||||
// window_fps_lock( editor_hz );
|
} else if( old_hz && old_hz != window_fps_target() ) {
|
||||||
|
window_fps_lock( old_hz );
|
||||||
|
old_hz = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue