Skip to content

Commit

Permalink
GameEngine.h:
Browse files Browse the repository at this point in the history
Adding a separate frame counter "frame_ctr_measure" that is not counted when paused etc and which can be used for getting a more accurate FPS measurement (hopefully).
  • Loading branch information
razterizer committed Nov 24, 2024
1 parent 6b2131e commit bfc27df
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion GameEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class GameEngine
};
std::vector<AnimCtrData> anim_ctr_data;
int frame_ctr = 0;
int frame_ctr_measure = 0;

YesNoButtons quit_confirm_button = YesNoButtons::No;

Expand Down Expand Up @@ -207,6 +208,7 @@ class GameEngine
return ad.anim_count_per_frame_count;
}
int get_frame_count() const { return frame_ctr; }
int get_frame_count_measure() const { return frame_ctr_measure; }
int get_anim_count(int anim_channel)
{
if (anim_channel < 0)
Expand Down Expand Up @@ -524,8 +526,10 @@ class GameEngine
trg_update_halted.reset();
}

frame_ctr_measure++;

for (size_t ad_idx = 0; ad_idx < anim_ctr_data.size(); ++ad_idx)
if (frame_ctr % anim_ctr_data[ad_idx].anim_count_per_frame_count == 0)
if (frame_ctr_measure % anim_ctr_data[ad_idx].anim_count_per_frame_count == 0)
anim_ctr_data[ad_idx].anim_ctr++;

sim_time_s += sim_dt_s;
Expand Down

0 comments on commit bfc27df

Please sign in to comment.