diff -Nuhr xscreensaver-4.18/hacks/config/glissajous.xml xscreensaver-4.18-glissajoux/hacks/config/glissajous.xml --- xscreensaver-4.18/hacks/config/glissajous.xml 1970-01-01 01:00:00.000000000 +0100 +++ xscreensaver-4.18-glissajoux/hacks/config/glissajous.xml 2004-08-24 11:51:57.000000000 +0200 @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + <_description> +Draws 3d lissajous curves. + +Written by Andrea Leofreddi. + +
diff -Nuhr xscreensaver-4.18/hacks/glx/glissajous.c xscreensaver-4.18-glissajoux/hacks/glx/glissajous.c --- xscreensaver-4.18/hacks/glx/glissajous.c 1970-01-01 01:00:00.000000000 +0100 +++ xscreensaver-4.18-glissajoux/hacks/glx/glissajous.c 2004-08-24 12:16:44.000000000 +0200 @@ -0,0 +1,323 @@ +/* + * GLissajous, Copyright (c) 2004 Andrea Leofreddi + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation. No representations are made about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * Tue Aug 24 12:16:32 CEST 2004, Andrea Leofreddi + * first revision + */ + +#include +#include + +extern XtAppContext app; + +#define PROGCLASS "GLissajous" + +#define HACK_INIT init_glissajous +#define HACK_DRAW draw_glissajous +#define HACK_RESHAPE reshape_glissajous +#define HACK_HANDLE_EVENT event_glissajous + +#define EVENT_MASK PointerMotionMask + +#define glissajous_opts xlockmore_opts + +/* default settings */ + +#define PERIOD (2.0f * M_PI) + +#define DEF_CAMERA_SPEED "1.0" +#define DEF_CAMERA_DIST "2.0" +#define DEF_COLOR_SPEED "1.0" +#define DEF_COLORS "1" +#define DEF_ANIM_SPEED "1.5" +#define DEF_ANIM_COMPLEXITY "2.0" +#define DEF_ANIM_A "2.0" +#define DEF_ANIM_B "3.0" +#define DEF_ANIM_ZLENGTH "2.0" +#define DEF_ANIM_PLANEDETAIL "200" +#define DEF_ANIM_ZDETAIL "30" +#define DEF_ANIM_ZDISTORSION "1.5" + +#define DEFAULTS "*delay: 30000 \n" \ + "*cameraspeed: " DEF_CAMERA_SPEED "\n" \ + "*cameradist: " DEF_CAMERA_DIST "\n" \ + "*colorspeed: " DEF_COLOR_SPEED "\n" \ + "*colors: " DEF_COLORS "\n" \ + "*speed: " DEF_ANIM_SPEED "\n" \ + "*complexity: " DEF_ANIM_COMPLEXITY "\n" \ + "*a: " DEF_ANIM_A "\n" \ + "*b: " DEF_ANIM_B "\n" \ + "*zlength: " DEF_ANIM_ZLENGTH "\n" \ + "*planedetail: " DEF_ANIM_PLANEDETAIL "\n" \ + "*zdetail: " DEF_ANIM_ZDETAIL "\n" \ + "*zdistorsion: " DEF_ANIM_ZDISTORSION "\n" \ + "*showFPS: False \n" \ + "*wireframe: False \n" + + +#include "xlockmore.h" + +static XrmOptionDescRec opts[] = { + { "-cameraspeed", ".cameraspeed", XrmoptionSepArg, 0 }, + { "-cameradist", ".cameradist", XrmoptionSepArg, 0 }, + { "-colorspeed", ".colorspeed", XrmoptionSepArg, 0 }, + { "-colors", ".colors", XrmoptionSepArg, 0 }, + { "-speed", ".speed", XrmoptionSepArg, 0 }, + { "-complexity", ".complexity", XrmoptionSepArg, 0 }, + { "-a", ".a", XrmoptionSepArg, 0 }, + { "-b", ".b", XrmoptionSepArg, 0 }, + { "-zlength", ".zlength", XrmoptionSepArg, 0 }, + { "-planedetail", ".planedetail", XrmoptionSepArg, 0 }, + { "-zdetail", ".zdetail", XrmoptionSepArg, 0 }, + { "-zdistorsion", ".distorsion", XrmoptionSepArg, 0 }, +}; + +/* screensaver configuration */ +static float setting_cameraspeed, /* camera speed */ + setting_cameradist, /* camera maximum distance */ + setting_colorspeed; /* color change speed */ +static int setting_colors; /* number of colors */ +static float setting_speed, /* animation speed */ + setting_complexity, /* draw complexity */ + setting_a, /* sin/cos coefficients */ + setting_b, + setting_zlength; /* heigth */ +static int setting_planedetail, /* plane render detail */ + setting_zdetail; /* z render detail */ +static float setting_zdistorsion; /* phase skew on z-axis */ + +static argtype vars[] = { + { &setting_cameraspeed, "cameraspeed", "CSpeed", DEF_CAMERA_SPEED, t_Float }, + { &setting_cameradist, "cameradist", "CDist", DEF_CAMERA_DIST, t_Float }, + { &setting_colorspeed, "colorspeed", "ColorSpeed", DEF_COLOR_SPEED, t_Float }, + { &setting_colors, "colors", "Colors", DEF_COLORS, t_Int }, + { &setting_speed, "speed", "Speed", DEF_ANIM_SPEED, t_Float }, + { &setting_complexity, "complexity", "Complexity", DEF_ANIM_COMPLEXITY, t_Float }, + { &setting_a, "a", "A", DEF_ANIM_A, t_Float }, + { &setting_b, "b", "B", DEF_ANIM_B, t_Float }, + { &setting_zlength, "zlength", "ZLength", DEF_ANIM_ZLENGTH, t_Float }, + { &setting_planedetail, "planedetail", "PlaneDetail", DEF_ANIM_PLANEDETAIL, t_Int }, + { &setting_zdetail, "zdetail", "ZDetail", DEF_ANIM_ZDETAIL, t_Int }, + { &setting_zdistorsion, "zdistorsion", "ZDistorsion", DEF_ANIM_ZDISTORSION, t_Float }, +}; + +#undef countof +#define countof(x) (sizeof((x))/sizeof((*x))) + +ModeSpecOpt glissajous_opts = { countof(opts), opts, countof(vars), vars, NULL }; + +#ifdef USE_GL /* whole file */ + +#include + +/* glissajous configuration */ +typedef struct { + GLXContext *glx_context; /* glx context */ + + Bool button; /* true if button1 is pressed */ + + float phase; /* animation phase */ + float camera_phase; /* camera phase */ + float color_phase; /* color phase */ +} configuration_glissajous; + +static configuration_glissajous *gconf = 0; + +/* initializes screensaver */ +void init_glissajous(ModeInfo *mi) { + configuration_glissajous *conf; + + if(!gconf) { + gconf = (configuration_glissajous *)calloc(MI_NUM_SCREENS(mi), sizeof(configuration_glissajous)); + + if(!gconf) { + fprintf(stderr, "%s: out of memory\n", progname); + exit(1); + } + } + + conf = gconf + MI_SCREEN(mi); /* current configuration */ + + conf->glx_context = init_GL(mi); /* initializes opengl */ + + reshape_glissajous(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); /* resize things */ + + /* speeds are in order of 10^-2 */ + setting_speed /= 400.0f; + setting_cameraspeed /= 100.0f; + setting_colorspeed /= 100.0f; + setting_zdistorsion /= 100.0f; +} + +/* renders glissajous */ +void draw_glissajous(ModeInfo *mi) { + configuration_glissajous *conf = &gconf[MI_SCREEN(mi)]; + Display *dpy = MI_DISPLAY(mi); + Window window = MI_WINDOW(mi); + + float z, /* stores current plane height */ + t, /* stores current plane angle */ + x, /* stores current point x */ + y, + phase, /* stores current plane phase */ + cos_phase, /* avoid computing cos(phase) many times */ + + distorsion_step = setting_zdistorsion / setting_zlength, /* distorsion phase step for each iteration */ + z_step = setting_zlength / (float)setting_zdetail, /* z step for each iteration */ + t_step = PERIOD / (float)setting_planedetail; /* t step for each itearation */ + + static float *data = 0; /* array to store previous computed plane data */ + + Bool first_plane; /* true if computing first plane */ + unsigned i; /* counter */ + + /* Do nothing if no GLX context */ + if(!conf->glx_context) + return; + + /* Allocate data if not previously allocated */ + if(!data) { + data = (float *)malloc(sizeof(float) * (setting_planedetail + 1) * 2); + + if(!data) { + fprintf(stderr, "%s: out of memory\n", progname); + exit(1); + } + } + + /* Clear screen */ + glLoadIdentity(); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + /* Enable blending */ + glEnable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + /* Enable wireframe if need to */ + if(MI_IS_WIREFRAME(mi)) + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + else + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + /* Setup camera */ + gluLookAt( + /* position */ + (setting_cameradist + setting_cameradist / 2.0f * cos(conf->camera_phase / 2.0f)) * cos(conf->camera_phase * 2.0f), + (setting_cameradist + setting_cameradist / 2.0f * cos(conf->camera_phase / 3.0f)) * sin(conf->camera_phase * 2.0f), + 2.0f * setting_zlength + setting_cameradist + setting_cameradist * cos(conf->camera_phase), + + /* viewed point */ + 0, + 0, + setting_zlength / 2.0f, + + /* up vector */ + 0, 0, 1.0f + ); + + mi->polygon_count = 0; /* reset polygon counter */ + + /* main drawing loop, iterates through height (z axis) */ + for(z = 0, phase = conf->phase, first_plane = True; z < setting_zlength; z += z_step) { + cos_phase = cos(phase); + + phase += distorsion_step; + + if(setting_colors == -1) + /* if colors is -1, just use one color fading to black */ + glColor4f( + cos(conf->color_phase) * z / setting_zlength, + 0, + z / setting_zlength, + 0.6f + .4f * (1.0f - z / setting_zlength) + ); + else + glColor4f( + cos(conf->color_phase + cos(setting_colors * z / setting_zlength * M_PI)), + cos(2.0f * conf->color_phase + cos(setting_colors * z / setting_zlength * M_PI)), + z / setting_zlength, + 0.6f + .4f * (1.0f - z / setting_zlength) + ); + + glBegin(GL_QUAD_STRIP); + + /* plane drawing loop */ + for(t = 0, i = 0; i < setting_planedetail + 1; t += t_step, ++i) { + x = cos((setting_complexity * setting_a + sin(phase)) * t); + y = sin((setting_complexity * setting_b + cos_phase) * t); + + if(!first_plane) { + glVertex3f(data[2 * i], data[2 * i + 1], z); + glVertex3f(x, y, z + z_step); + + mi->polygon_count++; + } + + data[2 * i] = x; + data[2 * i + 1] = y; + + } + + glEnd(); + + first_plane = False; + } + + /* print fps if need to */ + if(mi->fps_p) + do_fps(mi); + + /* draws tp screen */ + glXSwapBuffers(dpy, window); + + /* do timing stuff */ + if(!conf->button) { + conf->phase += setting_speed; + conf->camera_phase += setting_cameraspeed; + conf->color_phase += setting_colorspeed; + } +} + +/* reshape window */ +void reshape_glissajous(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(); + + glClear(GL_COLOR_BUFFER_BIT); + +} + +/* handle events */ +Bool event_glissajous(ModeInfo *mi, XEvent *event) { + configuration_glissajous *conf = &gconf[MI_SCREEN(mi)]; + + if(event->xany.type == ButtonPress && event->xbutton.button & Button1) { + conf->button = True; + } else if(event->xany.type == ButtonRelease && event->xbutton.button & Button1) { + conf->button = False; + } + + return False; +} + +#endif /* USE_GL */ diff -Nuhr xscreensaver-4.18/hacks/glx/glissajous.man xscreensaver-4.18-glissajoux/hacks/glx/glissajous.man --- xscreensaver-4.18/hacks/glx/glissajous.man 1970-01-01 01:00:00.000000000 +0100 +++ xscreensaver-4.18-glissajoux/hacks/glx/glissajous.man 2004-08-24 12:16:58.000000000 +0200 @@ -0,0 +1,117 @@ +.TH XScreenSaver 1 "30-Oct-99" "X Version 11" +.SH NAME +glissajous - draws 3d lissajous curves +.SH SYNOPSIS +.B glissajous +[\-display \fIhost:display.screen\fP] [\-window] [\-root] [\-install] +[\-visual \fIvisual\fP] +[\-delay \fIusecs\fP] +[\-cameraspeed \fIcameraspeed\fP\] +[\-cameradist \fIcameradist\fP\] +[\-colorspeed \fIcolorspeed\fP\] +[\-colors \fIcolors\fP\] +[\-speed \fIspeed\fP\] +[\-complexity \fIcomplexity\fP\] +[\-a \fIa\fP\] +[\-b \fIb\fP\] +[\-zlength \fIzlength\fP\] +[\-planedetail \fIplanedetail\fP\] +[\-zdetail \fIzdetail\fP\] +[\-zdistorsion \fIzdistorsion\fP\] +[\-wireframe\] +[\-no-wireframe\] +[\-fps\] +[\-no-fps\] + +.SH DESCRIPTION +The \fIglissajous\fP program draws 3d lissajous curves. + +.SH OPTIONS +.I glissajous +accepts the following options: +.TP 8 +.B \-window +Draw on a newly-created window. This is the default. +.TP 8 +.B \-root +Draw on the root window. +.TP 8 +.B \-install +Install a private colormap for the window. +.TP 8 +.B \-visual \fIvisual\fP\fP +Specify which visual to use. Legal values are the name of a visual class, +or the id number (decimal or hex) of a specific visual. +.TP 8 +.B \-delay \fIusecs\fP +The delay between frames of the animation, in microseconds: default 30000. +.TP 8 +.B \-speed \fIratio\fP +How fast the glyphs should move; default 1.0. 2.0 means twice as fast, +0.5 means half as fast. +.TP 8 +.B -cameraspeed \fIcameraspeed\fP +How fast the camera should move; default 1.0. 2.0 means twice as fast, 0.5 means half as fast. +.TP 8 +.B -cameradist \fIcameradist\fP +.TP 8 +.B -colorspeed \fIcolorspeed\fP +How fast colors should change; default 1.0. 2.0 means twice as fast, 0.5 means half as fast. +.TP 8 +.B -colors \fIcolors\fP +.TP 8 +.B -speed \fIspeed\fP +How fast the animation should change; default 1.0. 2.0 means twice as fast, 0.5 means half as fast. +.TP 8 +.B -complexity \fIcomplexity\fP +Draw complexity; default 2.0. +.TP 8 +.B -a \fIa\fP +Lissajous coefficient for cos; default 2.0. +.TP 8 +.B -b \fIb\fP +Lissajous coefficient for sin; default 3.0. +.TP 8 +.B -zlength \fIzlength\fP +Length of figure; default 2.0. +.TP 8 +.B -planedetail \fIplanedetail\fP +Detail level for a single figure (xy plane); default 200. +.TP 8 +.B -zdetail \fIzdetail\fP +Detail level for z-axis; default 30. +.TP 8 +.B -zdistorsion \fIzdistorsion\fP +Distorsion of the figure on x-axis; default 1.5. +.TP 8 +.B -wireframe +Draws wireframe. +.TP 8 +.B -fps +Display a running tally of how many frames per second are being rendered. +In conjunction with \fB\-delay 0\fP, this can be a useful benchmark of +your GL performance. +.TP 8 +.SH ENVIRONMENT +.PP +.TP 8 +.B DISPLAY +to get the default host and display number. +.TP 8 +.B XENVIRONMENT +to get the name of a resource file that overrides the global resources +stored in the RESOURCE_MANAGER property. +.SH SEE ALSO +.BR xissajous (1), +.BR X (1), +.BR xscreensaver (1) +.SH COPYRIGHT +Copyright \(co 2004 by Andrea Leofreddi. Permission to use, copy, modify, +distribute, and sell this software and its documentation for any purpose is +hereby granted without fee, provided that the above copyright notice appear +in all copies and that both that copyright notice and this permission notice +appear in supporting documentation. No representations are made about the +suitability of this software for any purpose. It is provided "as is" without +express or implied warranty. +.SH AUTHOR +Andrea Leofreddi , 24-Aug-2004. diff -Nuhr xscreensaver-4.18/hacks/glx/Makefile.in xscreensaver-4.18-glissajoux/hacks/glx/Makefile.in --- xscreensaver-4.18/hacks/glx/Makefile.in 2004-08-15 07:15:14.000000000 +0200 +++ xscreensaver-4.18-glissajoux/hacks/glx/Makefile.in 2004-08-24 11:47:02.000000000 +0200 @@ -79,7 +79,7 @@ extrusion.c extrusion-helix2.c extrusion-helix3.c \ extrusion-helix4.c extrusion-joinoffset.c extrusion-screw.c \ extrusion-taper.c extrusion-twistoid.c sierpinski3d.c \ - gflux.c stonerview.c stonerview-move.c stonerview-osc.c \ + gflux.c glissajous.c stonerview.c stonerview-move.c stonerview-osc.c \ stonerview-view.c starwars.c glut_stroke.c glut_swidth.c \ gltext.c molecule.c dangerball.c sphere.c tube.c circuit.c \ menger.c engine.c flipscreen3d.c font-ximage.c \ @@ -108,7 +108,7 @@ extrusion.o extrusion-helix2.o extrusion-helix3.o \ extrusion-helix4.o extrusion-joinoffset.o extrusion-screw.o \ extrusion-taper.o extrusion-twistoid.o sierpinski3d.o \ - gflux.o stonerview.o stonerview-move.o stonerview-osc.o \ + gflux.o glissajous.o stonerview.o stonerview-move.o stonerview-osc.o \ stonerview-view.o starwars.o glut_stroke.o glut_swidth.o \ gltext.o molecule.o dangerball.o sphere.o tube.o circuit.o \ menger.o engine.o flipscreen3d.o font-ximage.o \ @@ -129,7 +129,7 @@ GL_EXES = cage gears moebius pipes sproingies stairs superquadrics \ morph3d rubik atlantis lament bubble3d glplanet pulsar \ - sierpinski3d gflux stonerview starwars gltext molecule \ + sierpinski3d gflux glissajous stonerview starwars gltext molecule \ dangerball circuit menger engine flipscreen3d glsnake boxed \ glforestfire sballs cubenetic spheremonics lavalite queens \ endgame glblur flurry atunnel flyingtoasters bouncingcow \ @@ -157,7 +157,7 @@ ants.h polyhedra.h GL_MEN = atlantis.man boxed.man bubble3d.man cage.man circuit.man \ cubenetic.man dangerball.man engine.man extrusion.man \ - flipscreen3d.man gears.man gflux.man glforestfire.man \ + flipscreen3d.man gears.man gflux.man glissajous.man glforestfire.man \ glplanet.man glsnake.man gltext.man lament.man lavalite.man \ menger.man moebius.man molecule.man morph3d.man pipes.man \ pulsar.man queens.man rubik.man sballs.man sierpinski3d.man \ @@ -451,6 +451,9 @@ sierpinski3d: sierpinski3d.o $(HACK_OBJS) $(TRACK_OBJS) $(CC_HACK) -o $@ $@.o $(HACK_OBJS) $(TRACK_OBJS) $(HACK_LIBS) +glissajous: glissajous.o $(HACK_OBJS) $(TRACK_OBJS) $(GRAB_OBJS) + $(CC_HACK) -o $@ $@.o $(HACK_OBJS) $(TRACK_OBJS) $(GRAB_OBJS) $(HACK_LIBS) + gflux: gflux.o $(HACK_OBJS) $(TRACK_OBJS) $(GRAB_OBJS) $(CC_HACK) -o $@ $@.o $(HACK_OBJS) $(TRACK_OBJS) $(GRAB_OBJS) $(HACK_LIBS)