X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fmorph3d.c;h=4bea5766f90002f2545eb7a9dd62b7a5d1c87e07;hb=4361b69d3178d7fc98d0388f9a223af6c2651aba;hp=73f0be629789edaa5ca9fdb8d7a6aa4fb598979e;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/glx/morph3d.c b/hacks/glx/morph3d.c index 73f0be62..4bea5766 100644 --- a/hacks/glx/morph3d.c +++ b/hacks/glx/morph3d.c @@ -55,8 +55,11 @@ static const char sccsid[] = "@(#)morph3d.c 5.01 2001/03/01 xlockmore"; # define MODE_moebius # define DEFAULTS "*delay: 40000 \n" \ "*showFPS: False \n" \ - "*count: 0 \n" + "*count: 0 \n" \ + "*suppressRotationAnimation: True\n" \ + # define refresh_morph3d 0 +# define release_morph3d 0 # define morph3d_handle_event 0 # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ @@ -70,7 +73,7 @@ ENTRYPOINT ModeSpecOpt morph3d_opts = #ifdef USE_MODULES ModStruct morph3d_description = -{"morph3d", "init_morph3d", "draw_morph3d", "release_morph3d", +{"morph3d", "init_morph3d", "draw_morph3d", (char *) NULL, "draw_morph3d", "change_morph3d", (char *) NULL, &morph3d_opts, 1000, 0, 1, 1, 4, 1.0, "", "Shows GL morphing polyhedra", 0, NULL}; @@ -175,6 +178,7 @@ static morph3dstruct *morph3d = (morph3dstruct *) NULL; NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \ glVertex3f(VertX, VertY, VertZ); \ + mi->polygon_count++; \ \ Xf-=Ax; Yf-=Ay; Xa-=Ax; Yb-=Ay; \ \ @@ -186,6 +190,7 @@ static morph3dstruct *morph3d = (morph3dstruct *) NULL; NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \ glVertex3f(VertX, VertY, VertZ); \ + mi->polygon_count++; \ \ Xf-=Ax; Yf+=Ay; Xa-=Ax; Yb+=Ay; \ } \ @@ -241,6 +246,7 @@ static morph3dstruct *morph3d = (morph3dstruct *) NULL; NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \ glVertex3f(VertX, VertY, VertZ); \ + mi->polygon_count++; \ } \ glEnd(); \ } \ @@ -277,18 +283,20 @@ static morph3dstruct *morph3d = (morph3dstruct *) NULL; NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; \ NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \ - glVertex3f(VertX, VertY, VertZ); \ + glVertex3f(VertX, VertY, VertZ); \ + mi->polygon_count++; \ \ Xf-=x[Fi]; Yf-=y[Fi]; Xa-=x[Fi]; Yb-=y[Fi]; \ \ - Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); \ - Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); \ - Factor2=1-((Xf2+sqr(Yb))*AmpVr2); \ + Factor=1-(((Xf2=sqr(Xf))+(Yf2=sqr(Yf)))*AmpVr2); \ + Factor1=1-((sqr(Xa)+Yf2)*AmpVr2); \ + Factor2=1-((Xf2+sqr(Yb))*AmpVr2); \ VertX=Factor*Xf; VertY=Factor*Yf; VertZ=Factor*Zf; \ NeiAX=Factor1*Xa-VertX; NeiAY=Factor1*Yf-VertY; NeiAZ=Factor1*Zf-VertZ; \ NeiBX=Factor2*Xf-VertX; NeiBY=Factor2*Yb-VertY; NeiBZ=Factor2*Zf-VertZ; \ glNormal3f(VectMul(NeiAX, NeiAY, NeiAZ, NeiBX, NeiBY, NeiBZ)); \ - glVertex3f(VertX, VertY, VertZ); \ + glVertex3f(VertX, VertY, VertZ); \ + mi->polygon_count++; \ \ } \ Xf=(float)Ri*x[Fi+1]; \ @@ -305,7 +313,7 @@ static morph3dstruct *morph3d = (morph3dstruct *) NULL; glEnd(); \ } \ } \ - VS=(Factor<0); \ + VS=(Factor<0); \ } static void @@ -601,7 +609,6 @@ pinit(ModeInfo * mi) morph3dstruct *mp = &morph3d[MI_SCREEN(mi)]; glClearDepth(1.0); - glClearColor(0.0, 0.0, 0.0, 1.0); glColor3f(1.0, 1.0, 1.0); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); @@ -712,11 +719,7 @@ init_morph3d(ModeInfo * mi) { morph3dstruct *mp; - if (morph3d == NULL) { - if ((morph3d = (morph3dstruct *) calloc(MI_NUM_SCREENS(mi), - sizeof (morph3dstruct))) == NULL) - return; - } + MI_INIT (mi, morph3d, NULL); mp = &morph3d[MI_SCREEN(mi)]; mp->step = NRAND(90); mp->VisibleSpikes = 1; @@ -750,6 +753,7 @@ draw_morph3d(ModeInfo * mi) if (!mp->glx_context) return; + mi->polygon_count = 0; glXMakeCurrent(display, window, *(mp->glx_context)); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -765,6 +769,15 @@ draw_morph3d(ModeInfo * mi) glScalef(Scale4Iconic * mp->WindH / mp->WindW, Scale4Iconic, Scale4Iconic); } +# ifdef HAVE_MOBILE /* Keep it the same relative size when rotated. */ + { + GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi); + int o = (int) current_device_rotation(); + if (o != 0 && o != 180 && o != -180) + glScalef (1/h, h, 1); + } +# endif + glRotatef(mp->step * 100, 1, 0, 0); glRotatef(mp->step * 95, 0, 1, 0); glRotatef(mp->step * 90, 0, 0, 1); @@ -813,16 +826,6 @@ change_morph3d(ModeInfo * mi) } #endif /* !STANDALONE */ -ENTRYPOINT void -release_morph3d(ModeInfo * mi) -{ - if (morph3d != NULL) { - (void) free((void *) morph3d); - morph3d = (morph3dstruct *) NULL; - } - FreeAllGL(mi); -} - #endif XSCREENSAVER_MODULE ("Morph3D", morph3d)