X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fglx%2Fgltext.c;h=f9e6f156488bef3026c74a9d5d74072019cc19c2;hp=e1b94fc25071322f3167761f328e14ec7d4f4c8a;hb=6b1c86cf395f59389e4ece4ea8f4bea2c332745b;hpb=447db08c956099b3b183886729108bf5b364c4b8 diff --git a/hacks/glx/gltext.c b/hacks/glx/gltext.c index e1b94fc2..f9e6f156 100644 --- a/hacks/glx/gltext.c +++ b/hacks/glx/gltext.c @@ -1,4 +1,4 @@ -/* gltext, Copyright (c) 2001-2005 Jamie Zawinski +/* gltext, Copyright (c) 2001-2008 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 @@ -9,28 +9,12 @@ * implied warranty. */ -#include - -extern XtAppContext app; - -#define PROGCLASS "GLText" -#define HACK_INIT init_text -#define HACK_DRAW draw_text -#define HACK_RESHAPE reshape_text -#define HACK_HANDLE_EVENT text_handle_event -#define EVENT_MASK PointerMotionMask -#define sws_opts xlockmore_opts - -#define DEF_TEXT "(default)" -#define DEF_PROGRAM "(default)" -#define DEF_SPIN "XYZ" -#define DEF_WANDER "True" -#define DEF_FRONT "False" - #define DEFAULTS "*delay: 20000 \n" \ "*showFPS: False \n" \ "*wireframe: False \n" \ +# define refresh_text 0 +# define release_text 0 #define SMOOTH_TUBE /* whether to have smooth or faceted tubes */ #ifdef SMOOTH_TUBE @@ -48,22 +32,26 @@ extern XtAppContext app; #include "tube.h" #include "rotator.h" #include "gltrackball.h" -#include -#include -#include -#ifdef HAVE_LOCALE_H -# include -#endif /* HAVE_LOCALE_H */ +#include #ifdef USE_GL /* whole file */ +#ifdef HAVE_COCOA +# define DEF_TEXT "%A%n%d %b %Y%n%r" +#else +# define DEF_TEXT "(default)" +#endif + +#define DEF_PROGRAM "(default)" +#define DEF_SPIN "XYZ" +#define DEF_WANDER "True" +#define DEF_FRONT "True" + #ifdef HAVE_UNAME # include #endif /* HAVE_UNAME */ - -#include #include "glutstroke.h" #include "glut_roman.h" #define GLUT_FONT (&glutStrokeRoman) @@ -85,6 +73,8 @@ typedef struct { char *text; int reload; + time_t last_update; + } text_configuration; static text_configuration *tps = NULL; @@ -114,12 +104,12 @@ static argtype vars[] = { {&face_front_p, "faceFront", "FaceFront", DEF_FRONT, t_Bool}, }; -ModeSpecOpt sws_opts = {countof(opts), opts, countof(vars), vars, NULL}; +ENTRYPOINT ModeSpecOpt text_opts = {countof(opts), opts, countof(vars), vars, NULL}; /* Window management, etc */ -void +ENTRYPOINT void reshape_text (ModeInfo *mi, int width, int height) { GLfloat h = (GLfloat) height / (GLfloat) width; @@ -146,7 +136,7 @@ gl_init (ModeInfo *mi) text_configuration *tp = &tps[MI_SCREEN(mi)]; int wire = MI_IS_WIREFRAME(mi); - static GLfloat pos[4] = {5.0, 5.0, 10.0, 1.0}; + static const GLfloat pos[4] = {5.0, 5.0, 10.0, 1.0}; if (!wire) { @@ -289,7 +279,7 @@ parse_text (ModeInfo *mi) } -Bool +ENTRYPOINT Bool text_handle_event (ModeInfo *mi, XEvent *event) { text_configuration *tp = &tps[MI_SCREEN(mi)]; @@ -311,7 +301,9 @@ text_handle_event (ModeInfo *mi, XEvent *event) } else if (event->xany.type == ButtonPress && (event->xbutton.button == Button4 || - event->xbutton.button == Button5)) + event->xbutton.button == Button5 || + event->xbutton.button == Button6 || + event->xbutton.button == Button7)) { gltrackball_mousewheel (tp->trackball, event->xbutton.button, 10, !!event->xbutton.state); @@ -330,16 +322,12 @@ text_handle_event (ModeInfo *mi, XEvent *event) } -void +ENTRYPOINT void init_text (ModeInfo *mi) { text_configuration *tp; int i; -# ifdef HAVE_SETLOCALE - setlocale (LC_TIME, ""); /* for strftime() calls */ -# endif - if (!tps) { tps = (text_configuration *) calloc (MI_NUM_SCREENS(mi), sizeof (text_configuration)); @@ -370,6 +358,7 @@ init_text (ModeInfo *mi) if (*s == 'x' || *s == 'X') tp->spinx = True; else if (*s == 'y' || *s == 'Y') tp->spiny = True; else if (*s == 'z' || *s == 'Z') tp->spinz = True; + else if (*s == '0') ; else { fprintf (stderr, @@ -545,7 +534,7 @@ fill_string (const char *string, Bool wire) } -void +ENTRYPOINT void draw_text (ModeInfo *mi) { text_configuration *tp = &tps[MI_SCREEN(mi)]; @@ -553,19 +542,20 @@ draw_text (ModeInfo *mi) Window window = MI_WINDOW(mi); int wire = MI_IS_WIREFRAME(mi); - static GLfloat color[4] = {0.0, 0.0, 0.0, 1.0}; - static GLfloat white[4] = {1.0, 1.0, 1.0, 1.0}; + GLfloat white[4] = {1.0, 1.0, 1.0, 1.0}; + GLfloat color[4] = {0.0, 0.0, 0.0, 1.0}; if (!tp->glx_context) return; + glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(tp->glx_context)); + if (tp->reload) { - static time_t last_update = 0; - if (time ((time_t *) 0) >= last_update + tp->reload) + if (time ((time_t *) 0) >= tp->last_update + tp->reload) { parse_text (mi); - last_update = time ((time_t *) 0); + tp->last_update = time ((time_t *) 0); } } @@ -575,6 +565,7 @@ draw_text (ModeInfo *mi) glEnable(GL_NORMALIZE); glEnable(GL_CULL_FACE); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix (); @@ -630,4 +621,6 @@ draw_text (ModeInfo *mi) glXSwapBuffers(dpy, window); } +XSCREENSAVER_MODULE_2 ("GLText", gltext, text) + #endif /* USE_GL */