-/* fps, Copyright (c) 2001-2008 Jamie Zawinski <jwz@jwz.org>
+/* fps, Copyright (c) 2001-2014 Jamie Zawinski <jwz@jwz.org>
* Draw a frames-per-second display (Xlib and OpenGL).
*
* Permission to use, copy, modify, distribute, and sell this software and its
# include "config.h"
#endif /* HAVE_CONFIG_H */
+#include <time.h>
#include "screenhackI.h"
#include "fpsI.h"
fps_state *st;
const char *font;
XFontStruct *f;
- int first, last;
if (! get_boolean_resource (dpy, "doFPS", "DoFPS"))
return 0;
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;
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? */
else
sprintf (st->string + strlen(st->string), "%lu%s ", polys, s);
}
+
+ if (depth >= 0.0)
+ {
+ unsigned long 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;
}
-/* This function is used only in Xlib mode. For GL mode, see glx/fps-glx.c.
+/* This function is used only in Xlib mode. For GL mode, see glx/fps-gl.c.
*/
void
fps_draw (fps_state *st)
s = strchr (string, '\n');
if (! s) s = string + strlen(string);
XDrawString (st->dpy, st->window, st->draw_gc,
- x, y, string, s - string);
+ x, y, string, (int) (s - string));
string = s;
string++;
lines--;