X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=hacks%2Fglx%2Fsproingiewrap.c;h=b16c87da6f1d33ba2e0b8403ac8a407d13bbd6cd;hp=dff236b08cef160a6b87e0718d133d429b0e5246;hb=07faf451b99879183ed7e909e43a0e065be1ee7f;hpb=df7adbee81405e2849728a24b498ad2117784b1f diff --git a/hacks/glx/sproingiewrap.c b/hacks/glx/sproingiewrap.c index dff236b0..b16c87da 100644 --- a/hacks/glx/sproingiewrap.c +++ b/hacks/glx/sproingiewrap.c @@ -1,9 +1,8 @@ /* -*- Mode: C; tab-width: 4 -*- */ /* sproingiewrap.c - sproingies wrapper */ -#if !defined( lint ) && !defined( SABER ) +#if 0 static const char sccsid[] = "@(#)sproingiewrap.c 4.07 97/11/24 xlockmore"; - #endif /*- @@ -22,10 +21,20 @@ static const char sccsid[] = "@(#)sproingiewrap.c 4.07 97/11/24 xlockmore"; * other special, indirect and consequential damages. * * Programming: Ed Mackey, http://www.netaxs.com/~emackey/ + * Gordon Wrigley, gdw33@student.canterbury.ac.nz + * Sergio GutiƩrrez "Sergut", sergut@gmail.com * Sproingie 3D objects modeled by: Al Mackey, al@iam.com * (using MetaNURBS in NewTek's Lightwave 3D v5). * * Revision History: + * 01-Sep-06: Make the sproingies select a new direction after each hop + * (6 frames); if they fall towards the edge, they explode. + * (TODO: let them fall for a time before they explode or + * disappear) [sergut] + * 13-Dec-02: Changed triangle normals into vertex normals to give a smooth + * apperance and moved the sproingies from Display Lists to + * Vertex Arrays, still need to do this for the TopsSides. + * [gordon] * 26-Apr-97: Added glPointSize() calls around explosions, plus other fixes. * 28-Mar-97: Added size support. * 22-Mar-97: Updated to use glX interface instead of xmesa one. @@ -36,33 +45,16 @@ static const char sccsid[] = "@(#)sproingiewrap.c 4.07 97/11/24 xlockmore"; * 09-Dec-96: Written. */ -/*- - * The sproingies have six "real" frames, (s1_1 to s1_6) that show a - * sproingie jumping off a block, headed down and to the right. But - * the program thinks of sproingies as having twelve "virtual" frames, - * with the latter six being copies of the first, only lowered and - * rotated by 90 degrees (jumping to the left). So after going - * through 12 frames, a sproingie has gone down two rows but not - * moved horizontally. - * - * To have the sproingies randomly choose left/right jumps at each - * block, the program should go back to thinking of only 6 frames, - * and jumping down only one row when it is done. Then it can pick a - * direction for the next row. - * - * (Falling off the end might not be so bad either. :) ) - */ - #ifdef STANDALONE -# define PROGCLASS "Sproingies" -# define HACK_INIT init_sproingies -# define HACK_DRAW draw_sproingies -# define sproingies_opts xlockmore_opts -# define DEFAULTS "*delay: 100 \n" \ - "*count: 5 \n" \ - "*cycles: 0 \n" \ +# define DEFAULTS "*delay: 30000 \n" \ + "*count: 8 \n" \ "*size: 0 \n" \ + "*showFPS: False \n" \ + "*fpsTop: True \n" \ "*wireframe: False \n" + +# define refresh_sproingies 0 +# define sproingies_handle_event 0 # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ # include "xlock.h" /* from the xlockmore distribution */ @@ -70,8 +62,26 @@ static const char sccsid[] = "@(#)sproingiewrap.c 4.07 97/11/24 xlockmore"; #ifdef USE_GL -ModeSpecOpt sproingies_opts = -{0, NULL, 0, NULL, NULL}; +#define DEF_SMART_SPROINGIES "True" /* Smart sproingies do not fall down the edge */ + +#include "sproingies.h" + +#undef countof +#define countof(x) (sizeof((x))/sizeof((*x))) + +static XrmOptionDescRec opts[] = { + {"-fall", ".smartSproingies", XrmoptionNoArg, "False"}, + {"-no-fall", ".smartSproingies", XrmoptionNoArg, "True"}, +}; + +static int smrt_spr; + +static argtype vars[] = { + {&smrt_spr, "smartSproingies", "Boolean", DEF_SMART_SPROINGIES, t_Bool}, +}; + +ENTRYPOINT ModeSpecOpt sproingies_opts = +{countof(opts), opts, countof(vars), vars, NULL}; #ifdef USE_MODULES ModStruct sproingies_description = @@ -84,19 +94,15 @@ ModStruct sproingies_description = #define MINSIZE 32 -#include #include void NextSproingie(int screen); -void NextSproingieDisplay(int screen); -void DisplaySproingies(int screen); - -#if 0 +void NextSproingieDisplay(int screen,int pause); +void DisplaySproingies(int screen,int pause); void ReshapeSproingies(int w, int h); - -#endif void CleanupSproingies(int screen); -void InitSproingies(int wfmode, int grnd, int mspr, int screen, int numscreens, int mono); +void InitSproingies(int wfmode, int grnd, int mspr, int smrtspr, + int screen, int numscreens, int mono); typedef struct { GLfloat view_rotx, view_roty, view_rotz; @@ -111,30 +117,18 @@ typedef struct { static sproingiesstruct *sproingies = NULL; -static Display *swap_display; -static Window swap_window; - -void -SproingieSwap(void) -{ - glFinish(); - glXSwapBuffers(swap_display, swap_window); -} - -void -init_sproingies(ModeInfo * mi) +ENTRYPOINT void +init_sproingies (ModeInfo * mi) { - Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); int screen = MI_SCREEN(mi); - int cycles = MI_CYCLES(mi); int count = MI_COUNT(mi); int size = MI_SIZE(mi); sproingiesstruct *sp; - int wfmode = 0, grnd, mspr, w, h; + int wfmode = 0, grnd = 0, mspr, w, h; if (sproingies == NULL) { if ((sproingies = (sproingiesstruct *) calloc(MI_NUM_SCREENS(mi), @@ -147,9 +141,9 @@ init_sproingies(ModeInfo * mi) sp->window = window; if ((sp->glx_context = init_GL(mi)) != NULL) { - if ((cycles & 1) || MI_IS_WIREFRAME(mi)) + if (MI_IS_WIREFRAME(mi)) wfmode = 1; - grnd = (cycles >> 1); + if (grnd > 2) grnd = 2; @@ -158,7 +152,7 @@ init_sproingies(ModeInfo * mi) mspr = 100; /* wireframe, ground, maxsproingies */ - InitSproingies(wfmode, grnd, mspr, MI_SCREEN(mi), MI_NUM_SCREENS(mi), sp->mono); + InitSproingies(wfmode, grnd, mspr, smrt_spr, MI_SCREEN(mi), MI_NUM_SCREENS(mi), sp->mono); /* Viewport is specified size if size >= MINSIZE && size < screensize */ if (size == 0) { @@ -179,17 +173,16 @@ init_sproingies(ModeInfo * mi) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - swap_display = display; - swap_window = window; - DisplaySproingies(MI_SCREEN(mi)); + DisplaySproingies(MI_SCREEN(mi),mi->pause); + } else { MI_CLEARWINDOW(mi); } } /* ARGSUSED */ -void -draw_sproingies(ModeInfo * mi) +ENTRYPOINT void +draw_sproingies (ModeInfo * mi) { sproingiesstruct *sp = &sproingies[MI_SCREEN(mi)]; Display *display = MI_DISPLAY(mi); @@ -201,13 +194,15 @@ draw_sproingies(ModeInfo * mi) glDrawBuffer(GL_BACK); glXMakeCurrent(display, window, *(sp->glx_context)); - swap_display = display; - swap_window = window; + NextSproingieDisplay(MI_SCREEN(mi),mi->pause); /* It will swap. */ - NextSproingieDisplay(MI_SCREEN(mi)); /* It will swap. */ + if (mi->fps_p) do_fps (mi); + glFinish(); + glXSwapBuffers(MI_DISPLAY(mi), MI_WINDOW(mi)); } -void +#ifndef STANDALONE +ENTRYPOINT void refresh_sproingies(ModeInfo * mi) { /* No need to do anything here... The whole screen is updated @@ -216,9 +211,17 @@ refresh_sproingies(ModeInfo * mi) * with DisplaySproingies(...). */ } +#endif /* !STANDALONE */ + +ENTRYPOINT void +reshape_sproingies (ModeInfo *mi, int w, int h) +{ + ReshapeSproingies(w, h); +} + -void -release_sproingies(ModeInfo * mi) +ENTRYPOINT void +release_sproingies (ModeInfo * mi) { if (sproingies != NULL) { int screen; @@ -239,6 +242,8 @@ release_sproingies(ModeInfo * mi) FreeAllGL(mi); } -#endif +XSCREENSAVER_MODULE ("Sproingies", sproingies) + +#endif /* USE_GL */ /* End of sproingiewrap.c */