X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Ffps-gl.c;h=17b05656135daca1fa1f03263ba45c3e8b9aa989;hb=7edd66e6bd3209013ee059819747b10b5835635b;hp=59032aab8d1e66537c96f1ba1597961c49c70685;hpb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;p=xscreensaver diff --git a/hacks/glx/fps-gl.c b/hacks/glx/fps-gl.c index 59032aab..17b05656 100644 --- a/hacks/glx/fps-gl.c +++ b/hacks/glx/fps-gl.c @@ -1,4 +1,4 @@ -/* fps, Copyright (c) 2001-2008 Jamie Zawinski +/* fps, Copyright (c) 2001-2014 Jamie Zawinski * Draw a frames-per-second display (Xlib and OpenGL). * * Permission to use, copy, modify, distribute, and sell this software and its @@ -16,56 +16,43 @@ #ifdef HAVE_COCOA # include "jwxyz.h" -# include -# include -# include -#else /* !HAVE_COCOA -- real Xlib */ +#elif defined(HAVE_ANDROID) +# include +#else /* real Xlib */ # include # include #endif /* !HAVE_COCOA */ +#ifdef HAVE_JWZGLES +# include "jwzgles.h" +#endif /* HAVE_JWZGLES */ + #include "xlockmoreI.h" #include "fpsI.h" -#include "glxfonts.h" +#include "texfont.h" /* These are in xlock-gl.c */ extern void clear_gl_error (void); extern void check_gl_error (const char *type); +typedef struct { + texture_font_data *texfont; + int line_height; + Bool top_p; +} gl_fps_data; + static void xlockmore_gl_fps_init (fps_state *st) { - XFontStruct *f = st->font; - int first = f->min_char_or_byte2; - int last = f->max_char_or_byte2; - - clear_gl_error (); - st->font_dlist = glGenLists ((GLuint) last+1); - check_gl_error ("glGenLists"); - -# ifndef HAVE_COCOA - - glXUseXFont (f->fid, first, last-first+1, st->font_dlist + first); - check_gl_error ("glXUseXFont"); - -# else /* HAVE_COCOA */ - { - AGLContext ctx = aglGetCurrentContext(); - int afid, face, size; - afid = jwxyz_font_info (f->fid, &size, &face); - - if (! aglUseFont (ctx, afid, face, size, - first, last-first+1, st->font_dlist + first)) { - check_gl_error ("aglUseFont"); - abort(); - } - } -# endif /* HAVE_COCOA */ + gl_fps_data *data = (gl_fps_data *) calloc (1, sizeof(*data)); + data->top_p = get_boolean_resource (st->dpy, "fpsTop", "FPSTop"); + data->texfont = load_texture_font (st->dpy, "fpsFont"); + texture_string_width (data->texfont, "M", &data->line_height); + st->gl_fps_data = data; } - /* Callback in xscreensaver_function_table, via xlockmore.c. */ void @@ -79,7 +66,7 @@ xlockmore_gl_compute_fps (Display *dpy, Window w, fps_state *fpst, xlockmore_gl_fps_init (fpst); } - fps_compute (fpst, mi->polygon_count); + fps_compute (fpst, mi->polygon_count, mi->recursion_depth); } @@ -91,10 +78,10 @@ xlockmore_gl_draw_fps (ModeInfo *mi) fps_state *st = mi->fpst; if (st) /* might be too early */ { + gl_fps_data *data = (gl_fps_data *) st->gl_fps_data; XWindowAttributes xgwa; int lines = 1; const char *s; - int lh = st->font->ascent + st->font->descent; int y = st->y; XGetWindowAttributes (st->dpy, st->window, &xgwa); @@ -102,12 +89,13 @@ xlockmore_gl_draw_fps (ModeInfo *mi) if (*s == '\n') lines++; if (y < 0) - y = xgwa.height + y - lines*lh; - y += lines*lh + st->font->descent; + y = xgwa.height + y - (lines * data->line_height); + y += lines * data->line_height; glColor3f (1, 1, 1); - print_gl_string (st->dpy, st->font, st->font_dlist, - xgwa.width, xgwa.height, - st->x, y, st->string, st->clear_p); + print_texture_label (st->dpy, data->texfont, + xgwa.width, xgwa.height, + (data->top_p ? 1 : 2), + st->string); } }