Skip to content

Commit

Permalink
experimental main loop timing settings (disabled by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmaclarty committed Sep 30, 2016
1 parent bcf5f6b commit 9f20e33
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lua/time.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ function am.perf_stats()
end
end
--log("total time = %0.5f, max_time = %0.5f", total_time, max_dt)
stats.time = total_time
stats.frames = count
stats.min_fps = 1 / max_dt
stats.avg_fps = count / total_time
return stats
Expand Down
7 changes: 6 additions & 1 deletion src/am_backend_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,14 +472,19 @@ int main( int argc, char *argv[] )

if (am_conf_fixed_delta_time > 0.0) {
while (t_debt > 0.0) {
double t0 = am_get_current_time();
if (!am_execute_actions(L, am_conf_fixed_delta_time)) {
exit_status = EXIT_FAILURE;
goto quit;
}
t_debt -= am_conf_fixed_delta_time;
double t = am_get_current_time() - t0;
t_debt -= am_max(t, am_conf_fixed_delta_time);
}
} else {
if (t_debt > am_conf_min_delta_time) {
if (am_conf_delta_time_step > 0.0) {
t_debt = floor(t_debt / am_conf_delta_time_step + 0.5) * am_conf_delta_time_step;
}
if (!am_execute_actions(L, t_debt)) {
exit_status = EXIT_FAILURE;
goto quit;
Expand Down
3 changes: 2 additions & 1 deletion src/am_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ int am_conf_default_recursion_limit = 8;
const char *am_conf_default_modelview_matrix_name = "MV";
const char *am_conf_default_projection_matrix_name = "P";

double am_conf_fixed_delta_time = -1.0; //1.0 / 60.0; //-1.0;
double am_conf_fixed_delta_time = -1.0; //1.0 / 60.0;
double am_conf_delta_time_step = -1.0; //1.0/240.0;
double am_conf_min_delta_time = 1.0/240.0;
double am_conf_max_delta_time = 1.0/15.0;
double am_conf_warn_delta_time = -1.0; //1.0/30.0;
Expand Down
1 change: 1 addition & 0 deletions src/am_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extern const char *am_conf_default_projection_matrix_name;

// game loop options
extern double am_conf_fixed_delta_time;
extern double am_conf_delta_time_step;
extern double am_conf_min_delta_time;
extern double am_conf_max_delta_time;
extern double am_conf_warn_delta_time;
Expand Down

0 comments on commit 9f20e33

Please sign in to comment.