X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fklein.c;h=b90644da9f289e7f007ded0d4fc1a5e6ad42cc73;hb=c1b9b55ad8d59dc05ef55e316aebf5863e7dfa56;hp=b068e3f4e7ff8259be004e41437ea1b78e9d9730;hpb=96bdd7cf6ea60c418a76921acaf0e34d6f5be930;p=xscreensaver diff --git a/hacks/glx/klein.c b/hacks/glx/klein.c index b068e3f4..b90644da 100644 --- a/hacks/glx/klein.c +++ b/hacks/glx/klein.c @@ -10,36 +10,11 @@ * */ -/*- - * due to a Bug/feature in VMS X11/Intrinsic.h has to be placed before xlock. - * otherwise caddr_t is not defined correctly - */ - -#include - #ifdef STANDALONE -# define PROGCLASS "Klein" -# define HACK_INIT init_klein -# define HACK_DRAW draw_klein -# define HACK_RESHAPE reshape_klein -# define HACK_HANDLE_EVENT klein_handle_event -# define EVENT_MASK PointerMotionMask -# define klein_opts xlockmore_opts - - -#define DEF_SPIN "True" -#define DEF_WANDER "False" -#define DEF_RANDOM "False" -#define DEF_SPEED "150" - -# define DEFAULTS "*delay: 20000 \n" \ - "*showFPS: False \n" \ - "*wireframe: False \n" \ - "*random: " DEF_RANDOM "\n" \ - "*speed: " DEF_SPEED "\n" \ - "*spin: " DEF_SPIN "\n" \ - "*wander: " DEF_WANDER "\n" \ +# define DEFAULTS "*delay: 20000 \n" \ + "*showFPS: False \n" +# define refresh_klein 0 # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ # include "xlock.h" /* from the xlockmore distribution */ @@ -47,7 +22,11 @@ #ifdef USE_GL -#include +#define DEF_SPIN "True" +#define DEF_WANDER "False" +#define DEF_RAND "True" +#define DEF_SPEED "150" + #include "rotator.h" #include "gltrackball.h" @@ -64,7 +43,7 @@ enum { SEASHELL, SWALLOWTAIL, BOHEM, - SURFACE_LAST, + SURFACE_LAST }; /* primitives to draw with @@ -78,7 +57,7 @@ enum { MY_POINTS = 0, MY_LINES, MY_LINE_LOOP, - MY_PRIM_LAST, + MY_PRIM_LAST }; @@ -89,7 +68,7 @@ static Bool do_spin; static Bool do_wander; static XrmOptionDescRec opts[] = { - {"-speed", ".speed", XrmoptionSepArg, (caddr_t) 0 }, + {"-speed", ".speed", XrmoptionSepArg, 0 }, { "-spin", ".spin", XrmoptionNoArg, "True" }, { "+spin", ".spin", XrmoptionNoArg, "False" }, { "-wander", ".wander", XrmoptionNoArg, "True" }, @@ -99,14 +78,14 @@ static XrmOptionDescRec opts[] = { }; static argtype vars[] = { - {(caddr_t *) &rand, "rand", "Random", DEF_RANDOM, t_Bool}, - {(caddr_t *) &do_spin, "spin", "Spin", DEF_SPIN, t_Bool}, - {(caddr_t *) &do_wander, "wander", "Wander", DEF_WANDER, t_Bool}, - {(caddr_t *) &speed, "speed", "Speed", DEF_SPEED, t_Int}, + {&rand, "rand", "Random", DEF_RAND, t_Bool}, + {&do_spin, "spin", "Spin", DEF_SPIN, t_Bool}, + {&do_wander, "wander", "Wander", DEF_WANDER, t_Bool}, + {&speed, "speed", "Speed", DEF_SPEED, t_Int}, }; -ModeSpecOpt klein_opts = {countof(opts), opts, countof(vars), vars, NULL}; +ENTRYPOINT ModeSpecOpt klein_opts = {countof(opts), opts, countof(vars), vars, NULL}; @@ -129,6 +108,8 @@ typedef struct { float du, dv; float a, b, c; + float draw_step; + } kleinstruct; static kleinstruct *klein = NULL; @@ -138,10 +119,10 @@ static void draw(ModeInfo *mi) { kleinstruct *kp = &klein[MI_SCREEN(mi)]; - static float step = 0.0; double u, v; float coord[3]; + mi->polygon_count = 0; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); @@ -179,6 +160,7 @@ draw(ModeInfo *mi) coord[2] = sin(u/2)*sin(v) + cos(u/2)*sin(2*v)/2; glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); glVertex3fv(coord); + mi->polygon_count++; } } break; @@ -190,6 +172,7 @@ draw(ModeInfo *mi) coord[2] = kp->a*(cos(v) + sin(tan((v/2))))+0.2*u; glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); glVertex3fv(coord); + mi->polygon_count++; } } break; @@ -201,6 +184,7 @@ draw(ModeInfo *mi) coord[2] = u*u-v*v; glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); glVertex3fv(coord); + mi->polygon_count++; } } break; @@ -213,6 +197,7 @@ draw(ModeInfo *mi) glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); glVertex3fv(coord); + mi->polygon_count++; } } break; @@ -224,6 +209,7 @@ draw(ModeInfo *mi) coord[2] = v*sin(u/2); glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); glVertex3fv(coord); + mi->polygon_count++; } } break; @@ -235,6 +221,7 @@ draw(ModeInfo *mi) coord[2] = sin(kp->b+=0.00001)*v/(2*M_PI)+kp->a*(1-v/(2*M_PI))*sin(u); glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); glVertex3fv(coord); + mi->polygon_count++; } } break; @@ -246,6 +233,7 @@ draw(ModeInfo *mi) coord[2] = u; glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); glVertex3fv(coord); + mi->polygon_count++; } } break; @@ -257,6 +245,7 @@ draw(ModeInfo *mi) coord[2] = sin(v); glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); glVertex3fv(coord); + mi->polygon_count++; } } break; @@ -268,6 +257,7 @@ draw(ModeInfo *mi) coord[2] = sin(u/2)*cos(v) + cos(u/2)*sin(v); glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); glVertex3fv(coord); + mi->polygon_count++; } } break; @@ -275,14 +265,16 @@ draw(ModeInfo *mi) glEnd(); glPopMatrix(); + if (kp->render == GL_LINES) + mi->polygon_count /= 2; - kp->a = sin(step+=0.01); - kp->b = cos(step+=0.01); + kp->a = sin(kp->draw_step+=0.01); + kp->b = cos(kp->draw_step+=0.01); } /* new window size or exposure */ -void +ENTRYPOINT void reshape_klein(ModeInfo *mi, int width, int height) { GLfloat h = (GLfloat) height / (GLfloat) width; @@ -302,19 +294,27 @@ reshape_klein(ModeInfo *mi, int width, int height) } -Bool +ENTRYPOINT Bool klein_handle_event (ModeInfo *mi, XEvent *event) { kleinstruct *kp = &klein[MI_SCREEN(mi)]; - if (event->xany.type == ButtonPress && event->xbutton.button & Button1) { + if (event->xany.type == ButtonPress && event->xbutton.button == Button1) { kp->button_down_p = True; gltrackball_start (kp->trackball, event->xbutton.x, event->xbutton.y, MI_WIDTH (mi), MI_HEIGHT (mi)); return True; - } else if (event->xany.type == ButtonRelease && event->xbutton.button & Button1) { + } else if (event->xany.type == ButtonRelease && event->xbutton.button == Button1) { kp->button_down_p = False; return True; - } else if (event->xany.type == MotionNotify && kp->button_down_p) { + } else if (event->xany.type == ButtonPress && + (event->xbutton.button == Button4 || + event->xbutton.button == Button5 || + event->xbutton.button == Button6 || + event->xbutton.button == Button7)) { + gltrackball_mousewheel (kp->trackball, event->xbutton.button, 10, + !!event->xbutton.state); + return True; + } else if (event->xany.type == MotionNotify && kp->button_down_p) { gltrackball_track (kp->trackball, event->xmotion.x, event->xmotion.y, MI_WIDTH (mi), MI_HEIGHT (mi)); return True; } @@ -323,7 +323,7 @@ klein_handle_event (ModeInfo *mi, XEvent *event) } -void +ENTRYPOINT void init_klein(ModeInfo *mi) { int screen = MI_SCREEN(mi); @@ -380,7 +380,7 @@ init_klein(ModeInfo *mi) } } -void +ENTRYPOINT void draw_klein(ModeInfo * mi) { kleinstruct *kp = &klein[MI_SCREEN(mi)]; @@ -398,7 +398,7 @@ draw_klein(ModeInfo * mi) glXSwapBuffers(display, window); } -void +ENTRYPOINT void release_klein(ModeInfo * mi) { if (klein != NULL) { @@ -419,6 +419,8 @@ release_klein(ModeInfo * mi) } +XSCREENSAVER_MODULE ("Klein", klein) + /*********************************************************/ #endif