Skip to content

Commit

Permalink
Added delayed frame time info
Browse files Browse the repository at this point in the history
  • Loading branch information
mariofv committed Nov 15, 2019
1 parent 3f8b5a1 commit 571352b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Engine/ModuleTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ update_status ModuleTime::PostUpdate()
if (remaining_frame_time > 0)
{
SDL_Delay(remaining_frame_time);
last_frame_delay = remaining_frame_time;
}
else
{
Expand All @@ -62,6 +63,10 @@ update_status ModuleTime::PostUpdate()
delta_time = (game_time_clock->Read() - frame_start_time) * time_scale;
real_time_delta_time = real_time_clock->Read() - real_frame_start_time;
}
else
{
last_frame_delay = 0.f;
}

time += delta_time;
real_time_since_startup += real_time_delta_time;
Expand Down Expand Up @@ -183,13 +188,15 @@ void ModuleTime::ShowTimeOptions()
if (ImGui::SliderInt("Max FPS", &max_fps, 10, 60))
{
SetMaxFPS(max_fps);
LOG("He cambiado el tiempo a %f", max_fps)
}

char frame_info[2048];
sprintf(frame_info, "Limiting to %d fps means each frame needs to take %f ms", max_fps, 1000.f / max_fps);
ImGui::Text(frame_info);

sprintf(frame_info, "Last frame we delayed for %f ms", last_frame_delay);
ImGui::Text(frame_info);

sprintf_s(frame_info, "Real Time since Start: %.0f Real Time dt: %.0f", real_time_since_startup, real_time_delta_time);
ImGui::Text(frame_info);

Expand Down
2 changes: 2 additions & 0 deletions Engine/ModuleTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class ModuleTime : public Module
float real_frame_start_time = 0.f;

bool limit_fps = false;
float last_frame_delay = 0.f;

int max_fps = 60;

bool stepping_frame = false;
Expand Down

0 comments on commit 571352b

Please sign in to comment.