diff options
-rw-r--r-- | x11/xscreensaver-gnome/Makefile | 3 | ||||
-rw-r--r-- | x11/xscreensaver-gnome/PLIST | 8 | ||||
-rw-r--r-- | x11/xscreensaver/Makefile | 4 | ||||
-rw-r--r-- | x11/xscreensaver/Makefile.common | 4 | ||||
-rw-r--r-- | x11/xscreensaver/PLIST | 8 | ||||
-rw-r--r-- | x11/xscreensaver/distinfo | 7 | ||||
-rw-r--r-- | x11/xscreensaver/patches/patch-ae | 853 |
7 files changed, 875 insertions, 12 deletions
diff --git a/x11/xscreensaver-gnome/Makefile b/x11/xscreensaver-gnome/Makefile index f70fe638ab9..c500f56c38b 100644 --- a/x11/xscreensaver-gnome/Makefile +++ b/x11/xscreensaver-gnome/Makefile @@ -1,8 +1,7 @@ -# $NetBSD: Makefile,v 1.17 2003/05/02 11:57:34 wiz Exp $ +# $NetBSD: Makefile,v 1.18 2003/05/23 09:39:53 wiz Exp $ # PKGNAME= ${DISTNAME:S/-/-gnome-/} -PKGREVISION= 1 COMMENT= Screen saver and locker for the X window system (with GNOME support) CONFLICTS+= xscreensaver-[0-9]* diff --git a/x11/xscreensaver-gnome/PLIST b/x11/xscreensaver-gnome/PLIST index 459cce57344..db1b02de426 100644 --- a/x11/xscreensaver-gnome/PLIST +++ b/x11/xscreensaver-gnome/PLIST @@ -1,4 +1,4 @@ -@comment $NetBSD: PLIST,v 1.12 2003/03/25 10:38:01 wiz Exp $ +@comment $NetBSD: PLIST,v 1.13 2003/05/23 09:39:53 wiz Exp $ bin/screensaver-properties-capplet bin/xscreensaver bin/xscreensaver-command @@ -29,6 +29,7 @@ libexec/xscreensaver/bumps libexec/xscreensaver/cage libexec/xscreensaver/ccurve libexec/xscreensaver/circuit +libexec/xscreensaver/cloudlife libexec/xscreensaver/compass libexec/xscreensaver/coral libexec/xscreensaver/critical @@ -84,6 +85,7 @@ libexec/xscreensaver/jigsaw libexec/xscreensaver/juggle libexec/xscreensaver/julia libexec/xscreensaver/kaleidescope +libexec/xscreensaver/klein libexec/xscreensaver/kumppa libexec/xscreensaver/lament libexec/xscreensaver/laser @@ -239,10 +241,12 @@ man/man1/hypercube.1 man/man1/ifs.1 man/man1/imsmap.1 man/man1/interference.1 +man/man1/jigglypuff.1 man/man1/jigsaw.1 man/man1/juggle.1 man/man1/julia.1 man/man1/kaleidescope.1 +man/man1/klein.1 man/man1/kumppa.1 man/man1/lament.1 man/man1/laser.1 @@ -357,6 +361,7 @@ share/control-center/screensavers/bumps.xml share/control-center/screensavers/cage.xml share/control-center/screensavers/ccurve.xml share/control-center/screensavers/circuit.xml +share/control-center/screensavers/cloudlife.xml share/control-center/screensavers/compass.xml share/control-center/screensavers/coral.xml share/control-center/screensavers/cosmos.xml @@ -410,6 +415,7 @@ share/control-center/screensavers/hypercube.xml share/control-center/screensavers/ifs.xml share/control-center/screensavers/imsmap.xml share/control-center/screensavers/interference.xml +share/control-center/screensavers/jigglypuff.xml share/control-center/screensavers/jigsaw.xml share/control-center/screensavers/juggle.xml share/control-center/screensavers/julia.xml diff --git a/x11/xscreensaver/Makefile b/x11/xscreensaver/Makefile index c925df80b80..bd6c2e579e3 100644 --- a/x11/xscreensaver/Makefile +++ b/x11/xscreensaver/Makefile @@ -1,8 +1,6 @@ -# $NetBSD: Makefile,v 1.56 2003/05/02 11:57:34 wiz Exp $ +# $NetBSD: Makefile,v 1.57 2003/05/23 09:39:52 wiz Exp $ # -PKGREVISION= 1 - COMMENT= Screen saver and locker for the X window system CONFLICTS+= xscreensaver-gnome-[0-9]* diff --git a/x11/xscreensaver/Makefile.common b/x11/xscreensaver/Makefile.common index d6297b2ea80..09fc5027236 100644 --- a/x11/xscreensaver/Makefile.common +++ b/x11/xscreensaver/Makefile.common @@ -1,7 +1,7 @@ -# $NetBSD: Makefile.common,v 1.46 2003/03/25 10:38:00 wiz Exp $ +# $NetBSD: Makefile.common,v 1.47 2003/05/23 09:39:52 wiz Exp $ # -DISTNAME= xscreensaver-4.09 +DISTNAME= xscreensaver-4.10 CATEGORIES= x11 MASTER_SITES= ${HOMEPAGE} \ ftp://ftp.fu-berlin.de/unix/X11/graphics/xscreensaver/ diff --git a/x11/xscreensaver/PLIST b/x11/xscreensaver/PLIST index 26992fae1bd..6891f9a51ad 100644 --- a/x11/xscreensaver/PLIST +++ b/x11/xscreensaver/PLIST @@ -1,4 +1,4 @@ -@comment $NetBSD: PLIST,v 1.12 2003/03/25 10:38:00 wiz Exp $ +@comment $NetBSD: PLIST,v 1.13 2003/05/23 09:39:52 wiz Exp $ @comment bin/screensaver-properties-capplet bin/xscreensaver bin/xscreensaver-command @@ -29,6 +29,7 @@ libexec/xscreensaver/bumps libexec/xscreensaver/cage libexec/xscreensaver/ccurve libexec/xscreensaver/circuit +libexec/xscreensaver/cloudlife libexec/xscreensaver/compass libexec/xscreensaver/config/README libexec/xscreensaver/config/anemone.xml @@ -51,6 +52,7 @@ libexec/xscreensaver/config/bumps.xml libexec/xscreensaver/config/cage.xml libexec/xscreensaver/config/ccurve.xml libexec/xscreensaver/config/circuit.xml +libexec/xscreensaver/config/cloudlife.xml libexec/xscreensaver/config/compass.xml libexec/xscreensaver/config/coral.xml libexec/xscreensaver/config/cosmos.xml @@ -104,6 +106,7 @@ libexec/xscreensaver/config/hypercube.xml libexec/xscreensaver/config/ifs.xml libexec/xscreensaver/config/imsmap.xml libexec/xscreensaver/config/interference.xml +libexec/xscreensaver/config/jigglypuff.xml libexec/xscreensaver/config/jigsaw.xml libexec/xscreensaver/config/juggle.xml libexec/xscreensaver/config/julia.xml @@ -254,6 +257,7 @@ libexec/xscreensaver/jigsaw libexec/xscreensaver/juggle libexec/xscreensaver/julia libexec/xscreensaver/kaleidescope +libexec/xscreensaver/klein libexec/xscreensaver/kumppa libexec/xscreensaver/lament libexec/xscreensaver/laser @@ -409,10 +413,12 @@ man/man1/hypercube.1 man/man1/ifs.1 man/man1/imsmap.1 man/man1/interference.1 +man/man1/jigglypuff.1 man/man1/jigsaw.1 man/man1/juggle.1 man/man1/julia.1 man/man1/kaleidescope.1 +man/man1/klein.1 man/man1/kumppa.1 man/man1/lament.1 man/man1/laser.1 diff --git a/x11/xscreensaver/distinfo b/x11/xscreensaver/distinfo index ca40fb84ead..16028720ce4 100644 --- a/x11/xscreensaver/distinfo +++ b/x11/xscreensaver/distinfo @@ -1,8 +1,9 @@ -$NetBSD: distinfo,v 1.25 2003/03/25 10:38:00 wiz Exp $ +$NetBSD: distinfo,v 1.26 2003/05/23 09:39:52 wiz Exp $ -SHA1 (xscreensaver-4.09.tar.gz) = c5fa5ecd102cf7f157d7a0927b08905cb80b5bf4 -Size (xscreensaver-4.09.tar.gz) = 3503133 bytes +SHA1 (xscreensaver-4.10.tar.gz) = 335680994fcd74261192cca060e2b3ffdd6f0c10 +Size (xscreensaver-4.10.tar.gz) = 3593957 bytes SHA1 (patch-aa) = 0b4de3babe3fe191943ce31c055e8047911c1326 SHA1 (patch-ab) = 3dc02761edb19658e17935bd245208fa7387316d SHA1 (patch-ac) = 430b3318a1d1623c5ac2ba51dd531c3bff8c9a70 SHA1 (patch-ad) = 64cd7a683da1afea599d1e8b8dffd951243c9d9b +SHA1 (patch-ae) = 69b71676f23f6a6e5fb8b2d25eaf21a8388236f8 diff --git a/x11/xscreensaver/patches/patch-ae b/x11/xscreensaver/patches/patch-ae new file mode 100644 index 00000000000..be8f77ceb78 --- /dev/null +++ b/x11/xscreensaver/patches/patch-ae @@ -0,0 +1,853 @@ +$NetBSD: patch-ae,v 1.8 2003/05/23 09:39:53 wiz Exp $ + +--- hacks/glx/klein.c.orig Tue May 20 13:33:47 2003 ++++ hacks/glx/klein.c +@@ -1,424 +1,424 @@ +-/* -*- Mode: C; tab-width: 4 -*- */
+-/* Klein --- Klein Bottle, Moebius and other parametric surfaces
+- * visualization */
+-
+-/*
+- * Revision History:
+- * 2000: written by Andrey Mirtchovski <mirtchov@cpsc.ucalgary.ca
+- *
+- * 01-Mar-2003 mirtchov modified as a xscreensaver hack
+- *
+- */
+-
+-/*-
+- * due to a Bug/feature in VMS X11/Intrinsic.h has to be placed before xlock.
+- * otherwise caddr_t is not defined correctly
+- */
+-
+-#include <X11/Intrinsic.h>
+-
+-#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" \
+-
+-# include "xlockmore.h" /* from the xscreensaver distribution */
+-#else /* !STANDALONE */
+-# include "xlock.h" /* from the xlockmore distribution */
+-#endif /* !STANDALONE */
+-
+-#ifdef USE_GL
+-
+-#include <GL/glu.h>
+-#include "rotator.h"
+-#include "gltrackball.h"
+-
+-#undef countof
+-#define countof(x) (sizeof((x))/sizeof((*x)))
+-
+-/* surfaces being drawn */
+-enum {
+- KLEIN = 0,
+- DINI,
+- ENNEPER,
+- KUEN,
+- MOEBIUS,
+- SEASHELL,
+- SWALLOWTAIL,
+- BOHEM,
+- SURFACE_LAST,
+-};
+-
+-/* primitives to draw with
+- * note that we skip the polygons and
+- * triangle fans -- too slow
+- *
+- * also removed triangle_strip and quads --
+- * just doesn't look good enough
+- */
+-enum {
+- MY_POINTS = 0,
+- MY_LINES,
+- MY_LINE_LOOP,
+- MY_PRIM_LAST,
+-};
+-
+-
+-static Bool rand;
+-static int render;
+-static int speed;
+-static Bool do_spin;
+-static Bool do_wander;
+-
+-static XrmOptionDescRec opts[] = {
+- {"-speed", ".speed", XrmoptionSepArg, (caddr_t) 0 },
+- { "-spin", ".spin", XrmoptionNoArg, "True" },
+- { "+spin", ".spin", XrmoptionNoArg, "False" },
+- { "-wander", ".wander", XrmoptionNoArg, "True" },
+- { "+wander", ".wander", XrmoptionNoArg, "False" },
+- { "-random", ".rand", XrmoptionNoArg, "True" },
+- { "+random", ".rand", XrmoptionNoArg, "False" },
+-};
+-
+-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},
+-};
+-
+-
+-ModeSpecOpt klein_opts = {countof(opts), opts, countof(vars), vars, NULL};
+-
+-
+-
+-typedef struct{
+- GLfloat x;
+- GLfloat y;
+- GLfloat z;
+-} GL_VECTOR;
+-
+-typedef struct {
+- GLXContext *glx_context;
+- Window window;
+- rotator *rot;
+- trackball_state *trackball;
+- Bool button_down_p;
+-
+- int render;
+- int surface;
+-
+- float du, dv;
+- float a, b, c;
+-
+-} kleinstruct;
+-
+-static kleinstruct *klein = NULL;
+-
+-
+-static void
+-draw(ModeInfo *mi)
+-{
+- kleinstruct *kp = &klein[MI_SCREEN(mi)];
+- static float step = 0.0;
+- double u, v;
+- float coord[3];
+-
+- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+-
+- glEnable(GL_DEPTH_TEST);
+- glEnable(GL_NORMALIZE);
+- glEnable(GL_CULL_FACE);
+-
+- glPushMatrix();
+-
+- {
+- double x, y, z;
+- get_position (kp->rot, &x, &y, &z, !kp->button_down_p);
+- glTranslatef((x - 0.5) * 10,
+- (y - 0.5) * 10,
+- (z - 0.5) * 20);
+-
+- gltrackball_rotate (kp->trackball);
+-
+- get_rotation (kp->rot, &x, &y, &z, !kp->button_down_p);
+- glRotatef (x * 360, 1.0, 0.0, 0.0);
+- glRotatef (y * 360, 0.0, 1.0, 0.0);
+- glRotatef (z * 360, 0.0, 0.0, 1.0);
+- }
+-
+- glScalef( 4.0, 4.0, 4.0 );
+-
+- glBegin(kp->render);
+- switch(kp->surface) {
+- case KLEIN:
+- for(u = -M_PI; u < M_PI; u+=kp->du){
+- for(v = -M_PI; v < M_PI; v+=kp->dv){
+- coord[0] = cos(u)*(kp->a + sin(v)*cos(u/2) -
+- sin(2*v)*sin(u/2)/2);
+- coord[1] = sin(u)*(kp->a + sin(v)*cos(u/2) -
+- sin(2*v)*sin(u/2)/2);
+- 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);
+- }
+- }
+- break;
+- case DINI:
+- for(u = -M_PI; u < M_PI; u+=kp->du){
+- for(v = -M_PI; v < M_PI; v+=kp->dv){
+- coord[0] = kp->a*cos(u)*sin(v);
+- coord[1] = kp->a*sin(u)*sin(v);
+- 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);
+- }
+- }
+- break;
+- case ENNEPER:
+- for(u = -M_PI; u < M_PI; u+=kp->du){
+- for(v = -M_PI; v < M_PI; v+=kp->dv){
+- coord[0] = kp->a*(u-(u*u*u/3)+u*v*v);
+- coord[1] = kp->b*(v-(v*v*v/3)+u*u*v);
+- coord[2] = u*u-v*v;
+- glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7);
+- glVertex3fv(coord);
+- }
+- }
+- break;
+- case KUEN:
+- for(u = -M_PI; u < M_PI; u+=kp->du){
+- for(v = -M_PI; v < M_PI; v+=kp->dv){
+- coord[0] = 2*(cos(u)+u*sin(u))*sin(v)/(1+u*u*sin(v)*sin(v));
+- coord[1] = 2*(sin(u)-u*cos(u))*sin(v)/(1+u*u*sin(v)*sin(v));
+- coord[2] = sin(tan(v/2))+2*cos(v)/(1+u*u*sin(v)*sin(v));
+-
+- glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7);
+- glVertex3fv(coord);
+- }
+- }
+- break;
+- case MOEBIUS:
+- for(u = -M_PI; u < M_PI; u+=kp->du){
+- for(v = -M_PI; v < M_PI; v+=kp->dv){
+- coord[0] = cos(u)+v*cos(u/2)*cos(u);
+- coord[1] = sin(u)+v*cos(u/2)*sin(u);
+- coord[2] = v*sin(u/2);
+- glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7);
+- glVertex3fv(coord);
+- }
+- }
+- break;
+- case SEASHELL:
+- for(u = 0; u < 2*M_PI; u+=kp->du){
+- for(v = 0; v < 2*M_PI; v+=kp->dv){
+- coord[0] = kp->a*(1-v/(2*M_PI))*cos(2*v)*(1+cos(u))+sin(kp->c+=0.00001)*cos(2*v);
+- coord[1] = kp->a*(1-v/(2*M_PI))*sin(2*v)*(1+cos(u))+cos(kp->c+=0.00001)*sin(2*v);
+- 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);
+- }
+- }
+- break;
+- case SWALLOWTAIL:
+- for(u = -M_PI; u < M_PI; u+=kp->du){
+- for(v = -M_PI; v < M_PI; v+=kp->dv){
+- coord[0] = u*pow(v,2) + 3*pow(v,4);
+- coord[1] = -2*u*v - 4*pow(v,3);
+- coord[2] = u;
+- glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7);
+- glVertex3fv(coord);
+- }
+- }
+- break;
+- case BOHEM:
+- for(u = -M_PI; u < M_PI; u+=kp->du){
+- for(v = -M_PI; v < M_PI; v+=kp->dv){
+- coord[0] = kp->a*cos(u);
+- coord[1] = 1.5*cos(v) + kp->a*sin(u);
+- coord[2] = sin(v);
+- glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7);
+- glVertex3fv(coord);
+- }
+- }
+- break;
+- default:
+- for(u = -M_PI; u < M_PI; u+=kp->du){
+- for(v = -M_PI; v < M_PI; v+=kp->dv){
+- coord[0] = sin(u)*kp->a;
+- coord[1] = cos(u)*kp->a;
+- 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);
+- }
+- }
+- break;
+- }
+- glEnd();
+- glPopMatrix();
+-
+-
+- kp->a = sin(step+=0.01);
+- kp->b = cos(step+=0.01);
+-}
+-
+-
+-/* new window size or exposure */
+-void
+-reshape_klein(ModeInfo *mi, int width, int height)
+-{
+- GLfloat h = (GLfloat) height / (GLfloat) width;
+-
+- glViewport(0, 0, (GLint) width, (GLint) height);
+- glMatrixMode(GL_PROJECTION);
+- glLoadIdentity();
+- gluPerspective (30.0, 1/h, 1.0, 100.0);
+-
+- glMatrixMode(GL_MODELVIEW);
+- glLoadIdentity();
+- gluLookAt( 0.0, 0.0, 30.0,
+- 0.0, 0.0, 0.0,
+- 0.0, 1.0, 0.0);
+-
+- glClear(GL_COLOR_BUFFER_BIT);
+-}
+-
+-
+-Bool
+-klein_handle_event (ModeInfo *mi, XEvent *event)
+-{
+- kleinstruct *kp = &klein[MI_SCREEN(mi)];
+-
+- 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) {
+- kp->button_down_p = False;
+- 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;
+- }
+-
+- return False;
+-}
+-
+-
+-void
+-init_klein(ModeInfo *mi)
+-{
+- int screen = MI_SCREEN(mi);
+- kleinstruct *kp;
+-
+- if (klein == NULL) {
+- if ((klein = (kleinstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (kleinstruct))) == NULL)
+- return;
+- }
+- kp = &klein[screen];
+-
+- kp->window = MI_WINDOW(mi);
+-
+- {
+- double spin_speed = 1.0;
+- double wander_speed = 0.03;
+- kp->rot = make_rotator (do_spin ? spin_speed : 0,
+- do_spin ? spin_speed : 0,
+- do_spin ? spin_speed : 0,
+- 1.0,
+- do_wander ? wander_speed : 0,
+- True);
+- kp->trackball = gltrackball_init ();
+- }
+-
+- if(rand) {
+- render = random() % MY_PRIM_LAST;
+- kp->surface = random() % SURFACE_LAST;
+- } else {
+- render = MY_LINE_LOOP;
+- kp->surface = KLEIN;
+- }
+-
+- switch (render) {
+- case MY_POINTS: kp->render = GL_POINTS; break;
+- case MY_LINES: kp->render = GL_LINES; break;
+- case MY_LINE_LOOP: kp->render = GL_LINE_LOOP; break;
+- default:
+- kp->render = GL_LINE_LOOP;
+- }
+-/*kp->render=GL_TRIANGLE_FAN;*/
+-/*kp->render=GL_POLYGON;*/
+-
+- kp->du = 0.07;
+- kp->dv = 0.07;
+- kp->a = kp->b = 1;
+- kp->c = 0.1;
+-
+-
+- if ((kp->glx_context = init_GL(mi)) != NULL) {
+- reshape_klein(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
+- } else {
+- MI_CLEARWINDOW(mi);
+- }
+-}
+-
+-void
+-draw_klein(ModeInfo * mi)
+-{
+- kleinstruct *kp = &klein[MI_SCREEN(mi)];
+- Display *display = MI_DISPLAY(mi);
+- Window window = MI_WINDOW(mi);
+-
+- if (!kp->glx_context) return;
+-
+- glDrawBuffer(GL_BACK);
+-
+- glXMakeCurrent(display, window, *(kp->glx_context));
+- draw(mi);
+- if (mi->fps_p) do_fps (mi);
+- glFinish();
+- glXSwapBuffers(display, window);
+-}
+-
+-void
+-release_klein(ModeInfo * mi)
+-{
+- if (klein != NULL) {
+- int screen;
+-
+- for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
+- kleinstruct *kp = &klein[screen];
+-
+- if (kp->glx_context) {
+- /* Display lists MUST be freed while their glXContext is current. */
+- glXMakeCurrent(MI_DISPLAY(mi), kp->window, *(kp->glx_context));
+- }
+- }
+- (void) free((void *) klein);
+- klein = NULL;
+- }
+- FreeAllGL(mi);
+-}
+-
+-
+-/*********************************************************/
+-
+-#endif
++/* -*- Mode: C; tab-width: 4 -*- */ ++/* Klein --- Klein Bottle, Moebius and other parametric surfaces ++ * visualization */ ++ ++/* ++ * Revision History: ++ * 2000: written by Andrey Mirtchovski <mirtchov@cpsc.ucalgary.ca ++ * ++ * 01-Mar-2003 mirtchov modified as a xscreensaver hack ++ * ++ */ ++ ++/*- ++ * due to a Bug/feature in VMS X11/Intrinsic.h has to be placed before xlock. ++ * otherwise caddr_t is not defined correctly ++ */ ++ ++#include <X11/Intrinsic.h> ++ ++#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" \ ++ ++# include "xlockmore.h" /* from the xscreensaver distribution */ ++#else /* !STANDALONE */ ++# include "xlock.h" /* from the xlockmore distribution */ ++#endif /* !STANDALONE */ ++ ++#ifdef USE_GL ++ ++#include <GL/glu.h> ++#include "rotator.h" ++#include "gltrackball.h" ++ ++#undef countof ++#define countof(x) (sizeof((x))/sizeof((*x))) ++ ++/* surfaces being drawn */ ++enum { ++ KLEIN = 0, ++ DINI, ++ ENNEPER, ++ KUEN, ++ MOEBIUS, ++ SEASHELL, ++ SWALLOWTAIL, ++ BOHEM, ++ SURFACE_LAST, ++}; ++ ++/* primitives to draw with ++ * note that we skip the polygons and ++ * triangle fans -- too slow ++ * ++ * also removed triangle_strip and quads -- ++ * just doesn't look good enough ++ */ ++enum { ++ MY_POINTS = 0, ++ MY_LINES, ++ MY_LINE_LOOP, ++ MY_PRIM_LAST, ++}; ++ ++ ++static Bool rand; ++static int render; ++static int speed; ++static Bool do_spin; ++static Bool do_wander; ++ ++static XrmOptionDescRec opts[] = { ++ {"-speed", ".speed", XrmoptionSepArg, (caddr_t) 0 }, ++ { "-spin", ".spin", XrmoptionNoArg, "True" }, ++ { "+spin", ".spin", XrmoptionNoArg, "False" }, ++ { "-wander", ".wander", XrmoptionNoArg, "True" }, ++ { "+wander", ".wander", XrmoptionNoArg, "False" }, ++ { "-random", ".rand", XrmoptionNoArg, "True" }, ++ { "+random", ".rand", XrmoptionNoArg, "False" }, ++}; ++ ++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}, ++}; ++ ++ ++ModeSpecOpt klein_opts = {countof(opts), opts, countof(vars), vars, NULL}; ++ ++ ++ ++typedef struct{ ++ GLfloat x; ++ GLfloat y; ++ GLfloat z; ++} GL_VECTOR; ++ ++typedef struct { ++ GLXContext *glx_context; ++ Window window; ++ rotator *rot; ++ trackball_state *trackball; ++ Bool button_down_p; ++ ++ int render; ++ int surface; ++ ++ float du, dv; ++ float a, b, c; ++ ++} kleinstruct; ++ ++static kleinstruct *klein = NULL; ++ ++ ++static void ++draw(ModeInfo *mi) ++{ ++ kleinstruct *kp = &klein[MI_SCREEN(mi)]; ++ static float step = 0.0; ++ double u, v; ++ float coord[3]; ++ ++ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ++ ++ glEnable(GL_DEPTH_TEST); ++ glEnable(GL_NORMALIZE); ++ glEnable(GL_CULL_FACE); ++ ++ glPushMatrix(); ++ ++ { ++ double x, y, z; ++ get_position (kp->rot, &x, &y, &z, !kp->button_down_p); ++ glTranslatef((x - 0.5) * 10, ++ (y - 0.5) * 10, ++ (z - 0.5) * 20); ++ ++ gltrackball_rotate (kp->trackball); ++ ++ get_rotation (kp->rot, &x, &y, &z, !kp->button_down_p); ++ glRotatef (x * 360, 1.0, 0.0, 0.0); ++ glRotatef (y * 360, 0.0, 1.0, 0.0); ++ glRotatef (z * 360, 0.0, 0.0, 1.0); ++ } ++ ++ glScalef( 4.0, 4.0, 4.0 ); ++ ++ glBegin(kp->render); ++ switch(kp->surface) { ++ case KLEIN: ++ for(u = -M_PI; u < M_PI; u+=kp->du){ ++ for(v = -M_PI; v < M_PI; v+=kp->dv){ ++ coord[0] = cos(u)*(kp->a + sin(v)*cos(u/2) - ++ sin(2*v)*sin(u/2)/2); ++ coord[1] = sin(u)*(kp->a + sin(v)*cos(u/2) - ++ sin(2*v)*sin(u/2)/2); ++ 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); ++ } ++ } ++ break; ++ case DINI: ++ for(u = -M_PI; u < M_PI; u+=kp->du){ ++ for(v = -M_PI; v < M_PI; v+=kp->dv){ ++ coord[0] = kp->a*cos(u)*sin(v); ++ coord[1] = kp->a*sin(u)*sin(v); ++ 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); ++ } ++ } ++ break; ++ case ENNEPER: ++ for(u = -M_PI; u < M_PI; u+=kp->du){ ++ for(v = -M_PI; v < M_PI; v+=kp->dv){ ++ coord[0] = kp->a*(u-(u*u*u/3)+u*v*v); ++ coord[1] = kp->b*(v-(v*v*v/3)+u*u*v); ++ coord[2] = u*u-v*v; ++ glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); ++ glVertex3fv(coord); ++ } ++ } ++ break; ++ case KUEN: ++ for(u = -M_PI; u < M_PI; u+=kp->du){ ++ for(v = -M_PI; v < M_PI; v+=kp->dv){ ++ coord[0] = 2*(cos(u)+u*sin(u))*sin(v)/(1+u*u*sin(v)*sin(v)); ++ coord[1] = 2*(sin(u)-u*cos(u))*sin(v)/(1+u*u*sin(v)*sin(v)); ++ coord[2] = sin(tan(v/2))+2*cos(v)/(1+u*u*sin(v)*sin(v)); ++ ++ glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); ++ glVertex3fv(coord); ++ } ++ } ++ break; ++ case MOEBIUS: ++ for(u = -M_PI; u < M_PI; u+=kp->du){ ++ for(v = -M_PI; v < M_PI; v+=kp->dv){ ++ coord[0] = cos(u)+v*cos(u/2)*cos(u); ++ coord[1] = sin(u)+v*cos(u/2)*sin(u); ++ coord[2] = v*sin(u/2); ++ glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); ++ glVertex3fv(coord); ++ } ++ } ++ break; ++ case SEASHELL: ++ for(u = 0; u < 2*M_PI; u+=kp->du){ ++ for(v = 0; v < 2*M_PI; v+=kp->dv){ ++ coord[0] = kp->a*(1-v/(2*M_PI))*cos(2*v)*(1+cos(u))+sin(kp->c+=0.00001)*cos(2*v); ++ coord[1] = kp->a*(1-v/(2*M_PI))*sin(2*v)*(1+cos(u))+cos(kp->c+=0.00001)*sin(2*v); ++ 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); ++ } ++ } ++ break; ++ case SWALLOWTAIL: ++ for(u = -M_PI; u < M_PI; u+=kp->du){ ++ for(v = -M_PI; v < M_PI; v+=kp->dv){ ++ coord[0] = u*pow(v,2) + 3*pow(v,4); ++ coord[1] = -2*u*v - 4*pow(v,3); ++ coord[2] = u; ++ glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); ++ glVertex3fv(coord); ++ } ++ } ++ break; ++ case BOHEM: ++ for(u = -M_PI; u < M_PI; u+=kp->du){ ++ for(v = -M_PI; v < M_PI; v+=kp->dv){ ++ coord[0] = kp->a*cos(u); ++ coord[1] = 1.5*cos(v) + kp->a*sin(u); ++ coord[2] = sin(v); ++ glColor3f(coord[0]+0.7, coord[1]+0.7, coord[2]+0.7); ++ glVertex3fv(coord); ++ } ++ } ++ break; ++ default: ++ for(u = -M_PI; u < M_PI; u+=kp->du){ ++ for(v = -M_PI; v < M_PI; v+=kp->dv){ ++ coord[0] = sin(u)*kp->a; ++ coord[1] = cos(u)*kp->a; ++ 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); ++ } ++ } ++ break; ++ } ++ glEnd(); ++ glPopMatrix(); ++ ++ ++ kp->a = sin(step+=0.01); ++ kp->b = cos(step+=0.01); ++} ++ ++ ++/* new window size or exposure */ ++void ++reshape_klein(ModeInfo *mi, int width, int height) ++{ ++ GLfloat h = (GLfloat) height / (GLfloat) width; ++ ++ glViewport(0, 0, (GLint) width, (GLint) height); ++ glMatrixMode(GL_PROJECTION); ++ glLoadIdentity(); ++ gluPerspective (30.0, 1/h, 1.0, 100.0); ++ ++ glMatrixMode(GL_MODELVIEW); ++ glLoadIdentity(); ++ gluLookAt( 0.0, 0.0, 30.0, ++ 0.0, 0.0, 0.0, ++ 0.0, 1.0, 0.0); ++ ++ glClear(GL_COLOR_BUFFER_BIT); ++} ++ ++ ++Bool ++klein_handle_event (ModeInfo *mi, XEvent *event) ++{ ++ kleinstruct *kp = &klein[MI_SCREEN(mi)]; ++ ++ 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) { ++ kp->button_down_p = False; ++ 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; ++ } ++ ++ return False; ++} ++ ++ ++void ++init_klein(ModeInfo *mi) ++{ ++ int screen = MI_SCREEN(mi); ++ kleinstruct *kp; ++ ++ if (klein == NULL) { ++ if ((klein = (kleinstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (kleinstruct))) == NULL) ++ return; ++ } ++ kp = &klein[screen]; ++ ++ kp->window = MI_WINDOW(mi); ++ ++ { ++ double spin_speed = 1.0; ++ double wander_speed = 0.03; ++ kp->rot = make_rotator (do_spin ? spin_speed : 0, ++ do_spin ? spin_speed : 0, ++ do_spin ? spin_speed : 0, ++ 1.0, ++ do_wander ? wander_speed : 0, ++ True); ++ kp->trackball = gltrackball_init (); ++ } ++ ++ if(rand) { ++ render = random() % MY_PRIM_LAST; ++ kp->surface = random() % SURFACE_LAST; ++ } else { ++ render = MY_LINE_LOOP; ++ kp->surface = KLEIN; ++ } ++ ++ switch (render) { ++ case MY_POINTS: kp->render = GL_POINTS; break; ++ case MY_LINES: kp->render = GL_LINES; break; ++ case MY_LINE_LOOP: kp->render = GL_LINE_LOOP; break; ++ default: ++ kp->render = GL_LINE_LOOP; ++ } ++/*kp->render=GL_TRIANGLE_FAN;*/ ++/*kp->render=GL_POLYGON;*/ ++ ++ kp->du = 0.07; ++ kp->dv = 0.07; ++ kp->a = kp->b = 1; ++ kp->c = 0.1; ++ ++ ++ if ((kp->glx_context = init_GL(mi)) != NULL) { ++ reshape_klein(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); ++ } else { ++ MI_CLEARWINDOW(mi); ++ } ++} ++ ++void ++draw_klein(ModeInfo * mi) ++{ ++ kleinstruct *kp = &klein[MI_SCREEN(mi)]; ++ Display *display = MI_DISPLAY(mi); ++ Window window = MI_WINDOW(mi); ++ ++ if (!kp->glx_context) return; ++ ++ glDrawBuffer(GL_BACK); ++ ++ glXMakeCurrent(display, window, *(kp->glx_context)); ++ draw(mi); ++ if (mi->fps_p) do_fps (mi); ++ glFinish(); ++ glXSwapBuffers(display, window); ++} ++ ++void ++release_klein(ModeInfo * mi) ++{ ++ if (klein != NULL) { ++ int screen; ++ ++ for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) { ++ kleinstruct *kp = &klein[screen]; ++ ++ if (kp->glx_context) { ++ /* Display lists MUST be freed while their glXContext is current. */ ++ glXMakeCurrent(MI_DISPLAY(mi), kp->window, *(kp->glx_context)); ++ } ++ } ++ (void) free((void *) klein); ++ klein = NULL; ++ } ++ FreeAllGL(mi); ++} ++ ++ ++/*********************************************************/ ++ ++#endif |