X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fglx%2Fgltext.c;h=a537c374299fe7f09e6e98fb1dfa0705bdfb67e1;hp=2ccae16165466b1b4a2916546db3772dc0b01b21;hb=ffd8c0873576a9e3065696a624dce6b766b77062;hpb=13dbc569cdc6e29019722c0ef9b932a925efbcad diff --git a/hacks/glx/gltext.c b/hacks/glx/gltext.c index 2ccae161..a537c374 100644 --- a/hacks/glx/gltext.c +++ b/hacks/glx/gltext.c @@ -1,4 +1,4 @@ -/* gltext, Copyright (c) 2001, 2002 Jamie Zawinski +/* gltext, Copyright (c) 2001, 2002, 2003, 2004 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -25,7 +25,7 @@ extern XtAppContext app; #define DEF_SPIN "XYZ" #define DEF_WANDER "True" -#define DEFAULTS "*delay: 10000 \n" \ +#define DEFAULTS "*delay: 20000 \n" \ "*showFPS: False \n" \ "*wireframe: False \n" \ "*spin: " DEF_SPIN "\n" \ @@ -92,15 +92,15 @@ static Bool do_wander; static XrmOptionDescRec opts[] = { { "-text", ".text", XrmoptionSepArg, 0 }, { "-spin", ".spin", XrmoptionSepArg, 0 }, - { "+spin", ".spin", XrmoptionNoArg, "False" }, + { "+spin", ".spin", XrmoptionNoArg, "" }, { "-wander", ".wander", XrmoptionNoArg, "True" }, { "+wander", ".wander", XrmoptionNoArg, "False" } }; static argtype vars[] = { - {(caddr_t *) &text_fmt, "text", "Text", DEF_TEXT, t_String}, - {(caddr_t *) &do_spin, "spin", "Spin", DEF_SPIN, t_String}, - {(caddr_t *) &do_wander, "wander", "Wander", DEF_WANDER, t_Bool}, + {&text_fmt, "text", "Text", DEF_TEXT, t_String}, + {&do_spin, "spin", "Spin", DEF_SPIN, t_String}, + {&do_wander, "wander", "Wander", DEF_WANDER, t_Bool}, }; ModeSpecOpt sws_opts = {countof(opts), opts, countof(vars), vars, NULL}; @@ -152,6 +152,32 @@ gl_init (ModeInfo *mi) } +/* The GLUT font only has ASCII characters in them, so do what we can to + convert Latin1 characters to the nearest ASCII equivalent... + */ +static void +latin1_to_ascii (char *s) +{ + unsigned char *us = (unsigned char *) s; + const unsigned char ascii[95] = { + '!', 'C', '#', '#', 'Y', '|', 'S', '_', 'C', '?', '<', '=', '-', 'R', '_', + '?', '?', '2', '3', '\'','u', 'P', '.', ',', '1', 'o', '>', '?', '?', '?', + '?', 'A', 'A', 'A', 'A', 'A', 'A', 'E', 'C', 'E', 'E', 'E', 'E', 'I', 'I', + 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'x', '0', 'U', 'U', 'U', 'U', + 'Y', 'p', 'S', 'a', 'a', 'a', 'a', 'a', 'a', 'e', 'c', 'e', 'e', 'e', 'e', + 'i', 'i', 'i', 'i', 'o', 'n', 'o', 'o', 'o', 'o', 'o', '/', 'o', 'u', 'u', + 'u', 'u', 'y', 'p', 'y' }; + while (*us) + { + if (*us >= 161) + *us = ascii[*us - 161]; + else if (*us > 127) + *us = '?'; + us++; + } +} + + static void parse_text (ModeInfo *mi) { @@ -177,13 +203,16 @@ parse_text (ModeInfo *mi) strlen(uts.sysname) + strlen(uts.version) + strlen(uts.release) + 10); -# ifdef _AIX +# if defined(_AIX) sprintf(tp->text, "%s\n%s %s.%s", uts.nodename, uts.sysname, uts.version, uts.release); -# else /* !_AIX */ +# elif defined(__APPLE__) /* MacOS X + XDarwin */ + sprintf(tp->text, "%s\n%s %s\n%s", + uts.nodename, uts.sysname, uts.release, uts.machine); +# else sprintf(tp->text, "%s\n%s %s", uts.nodename, uts.sysname, uts.release); -# endif /* !_AIX */ +# endif /* special system types */ } # else /* !HAVE_UNAME */ # ifdef VMS @@ -208,6 +237,8 @@ parse_text (ModeInfo *mi) if (!*tp->text) sprintf (tp->text, "strftime error:\n%s", text_fmt); } + + latin1_to_ascii (tp->text); } @@ -269,16 +300,33 @@ init_text (ModeInfo *mi) } { - double spin_speed = 1.0; - double wander_speed = 0.05; - double spin_accel = 1.0; + Bool spinx=False, spiny=False, spinz=False; + double spin_speed = 0.5; + double wander_speed = 0.02; + double spin_accel = 0.5; - tp->rot = make_rotator (do_spin ? spin_speed : 0, - do_spin ? spin_speed : 0, - do_spin ? spin_speed : 0, + char *s = do_spin; + while (*s) + { + if (*s == 'x' || *s == 'X') spinx = True; + else if (*s == 'y' || *s == 'Y') spiny = True; + else if (*s == 'z' || *s == 'Z') spinz = True; + else + { + fprintf (stderr, + "%s: spin must contain only the characters X, Y, or Z (not \"%s\")\n", + progname, do_spin); + exit (1); + } + s++; + } + + tp->rot = make_rotator (spinx ? spin_speed : 0, + spiny ? spin_speed : 0, + spinz ? spin_speed : 0, spin_accel, do_wander ? wander_speed : 0, - True); + False); tp->trackball = gltrackball_init (); } @@ -335,7 +383,7 @@ fill_character (GLUTstrokeFont font, int c, Bool wire) coord->x, coord->y, 0, tube_width, tube_width * 0.15, - TUBE_FACES, smooth, wire); + TUBE_FACES, smooth, True, wire); lx = coord->x; ly = coord->y; } @@ -369,9 +417,9 @@ text_extents (const char *string, int *wP, int *hP) if (w > *wP) *wP = w; *hP += line_height; - s++; lines++; if (*s == 0) break; + s++; } else s++;