X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Ffps.c;h=8a63ccff7fbabdd119fda1b0c55697d3f9c808e0;hb=ec8d2b32b63649e6d32bdfb306eda062769af823;hp=2aa0174377756afeaea6754ada674ff93a8b4a44;hpb=f0261d8acab611f3433160e4f07367b870439739;p=xscreensaver diff --git a/hacks/fps.c b/hacks/fps.c index 2aa01743..8a63ccff 100644 --- a/hacks/fps.c +++ b/hacks/fps.c @@ -1,4 +1,4 @@ -/* fps, Copyright (c) 2001-2008 Jamie Zawinski +/* fps, Copyright (c) 2001-2011 Jamie Zawinski * Draw a frames-per-second display (Xlib and OpenGL). * * Permission to use, copy, modify, distribute, and sell this software and its @@ -23,7 +23,6 @@ fps_init (Display *dpy, Window window) fps_state *st; const char *font; XFontStruct *f; - int first, last; if (! get_boolean_resource (dpy, "doFPS", "DoFPS")) return 0; @@ -40,9 +39,6 @@ fps_init (Display *dpy, Window window) f = XLoadQueryFont (dpy, font); if (!f) f = XLoadQueryFont (dpy, "fixed"); - first = f->min_char_or_byte2; - last = f->max_char_or_byte2; - { XWindowAttributes xgwa; XGCValues gcv; @@ -85,7 +81,7 @@ fps_slept (fps_state *st, unsigned long usecs) double -fps_compute (fps_state *st, unsigned long polys) +fps_compute (fps_state *st, unsigned long polys, double depth) { if (! st) return 0; /* too early? */ @@ -153,6 +149,18 @@ fps_compute (fps_state *st, unsigned long polys) else sprintf (st->string + strlen(st->string), "%lu%s ", polys, s); } + + if (depth >= 0.0) + { + int L = strlen (st->string); + char *s = st->string + L; + strcat (s, "\nDepth: "); + sprintf (s + strlen(s), "%.1f", depth); + L = strlen (s); + /* Remove trailing ".0" in case depth is not a fraction. */ + if (s[L-2] == '.' && s[L-1] == '0') + s[L-2] = 0; + } } return st->last_fps;