|
Post by bitshifter on Sept 9, 2011 2:07:49 GMT -5
My FPS counter is simple and flexible
void SCR_DrawFPS (void) { static char str[8] = ""; static float elapse = 0; static int frames = 0; static int x = 0;
if (!scr_drawfps->value) return;
frames += 1; elapse += cls.frametime;
if (elapse >= scr_drawfps->value) { int cells;
cells = sprintf(str,"%4.0ffps",1/(elapse/frames)) + 1; x = viddef.width - (cells * 8);
frames = 0; elapse = 0; }
DrawString(x,4,str); }
Features: 1) Variable update frequency. 2) Averaged counts (no snapshots). 3) Right justifies on screen.
Ramble: 1) Compiler mileage may vary. (ok with lcc) 2) Suggested update value: 0.1 ~ 1.0 (0 = off) 3) Not very optimal, but easy to read. 4) Assumes 8 pixel glyph width.
Should i make full installation tutorial for this?
|
|