Created
January 26, 2017 14:27
-
-
Save diegoeche/91dc0fdefa0aec0687c9449444c40bbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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