X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fsproingies.c;h=1860b11eaf574baef8134920d0b5d306acf44c7c;hb=39809ded547bdbb08207d3e514950425215b4410;hp=0892eff873da2e11d8bf81fdf34ada83201767ac;hpb=f8cf5ac7b2f53510f80a0eaf286a25298be17bfe;p=xscreensaver diff --git a/hacks/glx/sproingies.c b/hacks/glx/sproingies.c index 0892eff8..1860b11e 100644 --- a/hacks/glx/sproingies.c +++ b/hacks/glx/sproingies.c @@ -36,7 +36,7 @@ static const char sccsid[] = "@(#)sproingies.c 4.04 97/07/28 xlockmore"; #ifdef USE_GL -#ifndef HAVE_COCOA +#if !defined(HAVE_JWZGLES) && !defined(HAVE_COCOA) # include #endif @@ -61,26 +61,6 @@ static const char sccsid[] = "@(#)sproingies.c 4.04 97/07/28 xlockmore"; * * There are other frame numbers for special cases (e.g. BOOM_FRAME). */ -struct sPosColor { /* Position and color of the sproingie */ - int x, y, z; /* Position */ - int frame; /* Current frame (0-5) */ - int life; /* Life points */ - GLfloat r, g, b; /* Color RGB */ - int direction; /* Direction of next hop (left or right) */ -}; - -typedef struct { - int rotx, roty, dist, wireframe, flatshade, groundlevel, - maxsproingies, mono; - int sframe, target_rx, target_ry, target_dist, target_count; - const struct gllist *sproingies[6]; - const struct gllist *SproingieBoom; - GLuint TopsSides; - struct sPosColor *positions; -} sp_instance; - -static sp_instance *si_list = NULL; -static int active_screens = 0; extern const struct gllist *s1_1; extern const struct gllist *s1_2; @@ -352,9 +332,8 @@ AdvanceSproingie(int t, sp_instance * si) } static void -NextSproingie(int screen) +NextSproingie(sp_instance *si) { - sp_instance *si = &si_list[screen]; int ddx, t; struct sPosColor *thisSproingie = &(si->positions[0]); @@ -551,7 +530,11 @@ RenderSproingie(int t, sp_instance * si) glTranslatef((GLfloat) (thisSproingie->x) + 0.5, (GLfloat) (thisSproingie->y) + 0.5, (GLfloat) (thisSproingie->z) - 0.5); - scale = (GLfloat) (1 << (thisSproingie->frame - BOOM_FRAME)); + { + int boom_scale = thisSproingie->frame - BOOM_FRAME; + if (boom_scale >= 31) boom_scale = 31; + scale = (GLfloat) (1 << boom_scale); + } glScalef(scale, scale, scale); if (!si->wireframe) { if (!si->mono) @@ -685,9 +668,8 @@ ComputeGround(sp_instance * si) } void -DisplaySproingies(int screen,int pause) +DisplaySproingies(sp_instance *si) { - sp_instance *si = &si_list[screen]; int t; GLfloat position[] = {8.0, 5.0, -2.0, 0.1}; @@ -738,28 +720,38 @@ DisplaySproingies(int screen,int pause) } void -NextSproingieDisplay(int screen,int pause) +NextSproingieDisplay(sp_instance *si) { - NextSproingie(screen); + NextSproingie(si); /* if (pause) usleep(pause); don't do this! -jwz */ - DisplaySproingies(screen,pause); + DisplaySproingies(si); } void -ReshapeSproingies(int w, int h) +ReshapeSproingies(int width, int height) { - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(65.0, (GLfloat) w / (GLfloat) h, 0.1, 2000.0); /* was 200000.0 */ - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + double h = (GLfloat) height / (GLfloat) width; + int y = 0; + + if (width > height * 5) { /* tiny window: show middle */ + height = width * 9/16; + y = -height/2; + h = height / (GLfloat) width; + } + + glViewport(0, y, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(65.0, 1/h, 0.1, 2000.0); /* was 200000.0 */ + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); } void -CleanupSproingies(int screen) +CleanupSproingies(sp_instance *si) { - sp_instance *si = &si_list[screen]; + if (! si) return; + /* int t; if (si->SproingieBoom) { @@ -769,7 +761,6 @@ CleanupSproingies(int screen) glDeleteLists(si->TopsSides, 2); glDeleteLists(si->SproingieBoom, 1); - --active_screens; si->SproingieBoom = 0; } */ @@ -780,15 +771,11 @@ CleanupSproingies(int screen) (void) free((void *) (si->positions)); si->positions = NULL; } - if ((active_screens == 0) && si_list) { - (void) free((void *) (si_list)); - si_list = NULL; - } } void -InitSproingies(int wfmode, int grnd, int mspr, int smrtspr, - int screen, int numscreens, int mono) +InitSproingies(sp_instance *si, int wfmode, int grnd, int mspr, int smrtspr, + int mono) { GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; @@ -801,18 +788,9 @@ InitSproingies(int wfmode, int grnd, int mspr, int smrtspr, GLfloat mat_shininess[] = {50.0}; - sp_instance *si; int t; - if (si_list == NULL) { - if ((si_list = (sp_instance *) calloc(numscreens, - sizeof (sp_instance))) == NULL) - return; - } - si = &si_list[screen]; - - active_screens++; - CleanupSproingies(screen); + memset (si, 0, sizeof(*si)); if (mspr < 0) mspr = 0;