added new graph style

master
Moritz Kassner 2014-08-26 09:00:25 +02:00
parent 6b69e7bce0
commit b112ce00b7
2 changed files with 18 additions and 1 deletions

View File

@ -125,6 +125,15 @@ void renderGraph(NVGcontext* vg, float x, float y, PerfGraph* fps)
vy = y + h - ((v / 80.0f) * h);
nvgLineTo(vg, vx, vy);
}
} else if (fps->style == GRAPH_RENDER_PERCENT) {
for (i = 0; i < GRAPH_HISTORY_COUNT; i++) {
float v = fps->values[(fps->head+i) % GRAPH_HISTORY_COUNT] * 1.0f;
float vx, vy;
if (v > 100.0f) v = 100.0f;
vx = x + ((float)i/(GRAPH_HISTORY_COUNT-1)) * w;
vy = y + h - ((v / 100.0f) * h);
nvgLineTo(vg, vx, vy);
}
} else {
for (i = 0; i < GRAPH_HISTORY_COUNT; i++) {
float v = fps->values[(fps->head+i) % GRAPH_HISTORY_COUNT] * 1000.0f;
@ -154,12 +163,19 @@ void renderGraph(NVGcontext* vg, float x, float y, PerfGraph* fps)
nvgFillColor(vg, nvgRGBA(240,240,240,255));
sprintf(str, "%.2f FPS", 1.0f / avg);
nvgText(vg, x+w-3,y+1, str, NULL);
nvgFontSize(vg, 15.0f);
nvgTextAlign(vg,NVG_ALIGN_RIGHT|NVG_ALIGN_BOTTOM);
nvgFillColor(vg, nvgRGBA(240,240,240,160));
sprintf(str, "%.2f ms", avg * 1000.0f);
nvgText(vg, x+w-3,y+h-1, str, NULL);
}
else if (fps->style == GRAPH_RENDER_PERCENT) {
nvgFontSize(vg, 18.0f);
nvgTextAlign(vg,NVG_ALIGN_RIGHT|NVG_ALIGN_TOP);
nvgFillColor(vg, nvgRGBA(240,240,240,255));
sprintf(str, "%.1f %%", avg * 1.0f);
nvgText(vg, x+w-3,y+1, str, NULL);
} else {
nvgFontSize(vg, 18.0f);
nvgTextAlign(vg,NVG_ALIGN_RIGHT|NVG_ALIGN_TOP);

View File

@ -10,6 +10,7 @@ extern "C" {
enum GraphrenderStyle {
GRAPH_RENDER_FPS,
GRAPH_RENDER_MS,
GRAPH_RENDER_PERCENT,
};
#define GRAPH_HISTORY_COUNT 100