X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fglx%2Fglxfonts.c;h=37076724f2f6bc0b226d99c1384962a653ba9b4a;hp=3443e4f45e10406b34e9844b3515023bff93475a;hb=6b1c86cf395f59389e4ece4ea8f4bea2c332745b;hpb=2d04c4f22466851aedb6ed0f2919d148f726b889 diff --git a/hacks/glx/glxfonts.c b/hacks/glx/glxfonts.c index 3443e4f4..37076724 100644 --- a/hacks/glx/glxfonts.c +++ b/hacks/glx/glxfonts.c @@ -1,4 +1,4 @@ -/* glxfonts, Copyright (c) 2001-2004 Jamie Zawinski +/* glxfonts, Copyright (c) 2001-2008 Jamie Zawinski * Loads X11 fonts for use with OpenGL. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -10,14 +10,25 @@ * implied warranty. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif -#include "config.h" #include #include #include #include -#include -#include + +#ifdef HAVE_COCOA +# include "jwxyz.h" +# include +# include +# include +#else +# include +# include +#endif + #include "resources.h" #include "glxfonts.h" @@ -36,10 +47,11 @@ extern char *progname; void load_font (Display *dpy, char *res, XFontStruct **font_ret, GLuint *dlist_ret) { - const char *font = get_string_resource (res, "Font"); + XFontStruct *f; + + const char *font = get_string_resource (dpy, res, "Font"); const char *def1 = "-*-times-bold-r-normal-*-180-*"; const char *def2 = "fixed"; - XFontStruct *f; Font id; int first, last; @@ -76,6 +88,9 @@ load_font (Display *dpy, char *res, XFontStruct **font_ret, GLuint *dlist_ret) first = f->min_char_or_byte2; last = f->max_char_or_byte2; + +# ifndef HAVE_COCOA /* Xlib version */ + if (dlist_ret) { clear_gl_error (); @@ -85,6 +100,29 @@ load_font (Display *dpy, char *res, XFontStruct **font_ret, GLuint *dlist_ret) check_gl_error ("glXUseXFont"); } +# else /* HAVE_COCOA */ + + { + int afid, face, size; + afid = jwxyz_font_info (id, &size, &face); + + if (dlist_ret) + { + clear_gl_error (); + *dlist_ret = glGenLists ((GLuint) last+1); + check_gl_error ("glGenLists"); + + AGLContext ctx = aglGetCurrentContext(); + if (! aglUseFont (ctx, afid, face, size, + first, last-first+1, *dlist_ret + first)) { + check_gl_error ("aglUseFont"); + abort(); + } + } + } + +# endif /* HAVE_COCOA */ + if (font_ret) *font_ret = f; } @@ -152,7 +190,7 @@ print_gl_string (Display *dpy, glRasterPos2f (x, y); for (i = 0; i < strlen(string); i++) { - char c = string[i]; + unsigned char c = (unsigned char) string[i]; if (c == '\n') { glRasterPos2f (x, (y -= line_height));