X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fsproingiewrap.c;h=7089f9c1c90ab9a76ef9c8fc196ec6c49cd8a3e9;hb=39809ded547bdbb08207d3e514950425215b4410;hp=f247c97e9f7a2d91e46c9131b5b26cf033e41ad9;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/glx/sproingiewrap.c b/hacks/glx/sproingiewrap.c index f247c97e..7089f9c1 100644 --- a/hacks/glx/sproingiewrap.c +++ b/hacks/glx/sproingiewrap.c @@ -22,14 +22,19 @@ static const char sccsid[] = "@(#)sproingiewrap.c 4.07 97/11/24 xlockmore"; * * 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) + * 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. @@ -40,32 +45,15 @@ 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 DEFAULTS "*delay: 25000 \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 release_sproingies 0 # define sproingies_handle_event 0 # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ @@ -74,15 +62,31 @@ static const char sccsid[] = "@(#)sproingiewrap.c 4.07 97/11/24 xlockmore"; #ifdef USE_GL +#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 = -{0, NULL, 0, NULL, NULL}; +{countof(opts), opts, countof(vars), vars, NULL}; #ifdef USE_MODULES ModStruct sproingies_description = -{"sproingies", "init_sproingies", "draw_sproingies", "release_sproingies", - "refresh_sproingies", "init_sproingies", NULL, &sproingies_opts, +{"sproingies", "init_sproingies", "draw_sproingies", NULL, + "refresh_sproingies", "init_sproingies", "free_sproingies", &sproingies_opts, 1000, 5, 0, 400, 4, 1.0, "", "Shows Sproingies! Nontoxic. Safe for pets and small children", 0, NULL}; @@ -92,13 +96,6 @@ ModStruct sproingies_description = #include -void NextSproingie(int screen); -void NextSproingieDisplay(int screen,int pause); -void DisplaySproingies(int screen,int pause); -void ReshapeSproingies(int w, int h); -void CleanupSproingies(int screen); -void InitSproingies(int wfmode, int grnd, int mspr, int screen, int numscreens, int mono); - typedef struct { GLfloat view_rotx, view_roty, view_rotz; GLint gear1, gear2, gear3; @@ -108,37 +105,34 @@ typedef struct { GLXContext *glx_context; int mono; Window window; + sp_instance si; } sproingiesstruct; static sproingiesstruct *sproingies = NULL; + ENTRYPOINT void init_sproingies (ModeInfo * 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), - sizeof (sproingiesstruct))) == NULL) - return; - } + MI_INIT (mi, sproingies); sp = &sproingies[screen]; sp->mono = (MI_IS_MONO(mi) ? 1 : 0); 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; @@ -147,7 +141,7 @@ init_sproingies (ModeInfo * mi) mspr = 100; /* wireframe, ground, maxsproingies */ - InitSproingies(wfmode, grnd, mspr, MI_SCREEN(mi), MI_NUM_SCREENS(mi), sp->mono); + InitSproingies(&sp->si, wfmode, grnd, mspr, smrt_spr, sp->mono); /* Viewport is specified size if size >= MINSIZE && size < screensize */ if (size == 0) { @@ -168,7 +162,7 @@ init_sproingies (ModeInfo * mi) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - DisplaySproingies(MI_SCREEN(mi),mi->pause); + DisplaySproingies(&sp->si); } else { MI_CLEARWINDOW(mi); @@ -189,7 +183,10 @@ draw_sproingies (ModeInfo * mi) glDrawBuffer(GL_BACK); glXMakeCurrent(display, window, *(sp->glx_context)); - NextSproingieDisplay(MI_SCREEN(mi),mi->pause); /* It will swap. */ + glPushMatrix(); + glRotatef(current_device_rotation(), 0, 0, 1); + NextSproingieDisplay(&sp->si); /* It will swap. */ + glPopMatrix(); if (mi->fps_p) do_fps (mi); glFinish(); @@ -216,29 +213,19 @@ reshape_sproingies (ModeInfo *mi, int w, int h) ENTRYPOINT void -release_sproingies (ModeInfo * mi) +free_sproingies (ModeInfo * mi) { - if (sproingies != NULL) { - int screen; - - for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) { - sproingiesstruct *sp = &sproingies[screen]; + sproingiesstruct *sp = &sproingies[MI_SCREEN(mi)]; - if (sp->glx_context) { + if (sp->glx_context) { - glXMakeCurrent(MI_DISPLAY(mi), sp->window, *(sp->glx_context)); - CleanupSproingies(MI_SCREEN(mi)); - } - } - - (void) free((void *) sproingies); - sproingies = NULL; + glXMakeCurrent(MI_DISPLAY(mi), sp->window, *(sp->glx_context)); + CleanupSproingies(&sp->si); } - FreeAllGL(mi); } XSCREENSAVER_MODULE ("Sproingies", sproingies) -#endif +#endif /* USE_GL */ /* End of sproingiewrap.c */