Skip to content

Instantly share code, notes, and snippets.

@diegoeche
Created January 26, 2017 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegoeche/91dc0fdefa0aec0687c9449444c40bbc to your computer and use it in GitHub Desktop.
Save diegoeche/91dc0fdefa0aec0687c9449444c40bbc to your computer and use it in GitHub Desktop.
static bool STATS = false;
static const int FRAME_PLOT_SIZE = 50;
static float frameTimes[FRAME_PLOT_SIZE];
void renderUIElements(float elapsed) {
if (STATS) {
std::ostringstream os;
os << "T: " << elapsed;
std::string str = os.str();
char * cstr = new char [str.length()+1];
std::strcpy (cstr, str.c_str());
ImGui::Begin("Stats");
for(int i = 0; i < FRAME_PLOT_SIZE - 1; i++) {
frameTimes[i] = frameTimes[i+1];
}
frameTimes[FRAME_PLOT_SIZE-1] = elapsed;
// Frame Rate
ImGui::PlotHistogram(cstr, frameTimes, FRAME_PLOT_SIZE, 0, NULL, 0, 0.1f);
ImGui::End();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment