X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fglx%2Fatlantis.c;h=44bc6eb69488bf1d2abe98ab684a1c86f425368b;hb=39809ded547bdbb08207d3e514950425215b4410;hp=4b13c3217b1cb734c82911fce578ebdc2402318d;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/glx/atlantis.c b/hacks/glx/atlantis.c index 4b13c321..44bc6eb6 100644 --- a/hacks/glx/atlantis.c +++ b/hacks/glx/atlantis.c @@ -112,7 +112,8 @@ static const char sccsid[] = "@(#)atlantis.c 5.08 2003/04/09 xlockmore"; "*cycles: 100 \n" \ "*size: 6000 \n" \ "*wireframe: False \n" -# define atlantis_handle_event 0 +# define release_atlantis 0 +# define atlantis_handle_event xlockmore_no_events # include "xlockmore.h" /* from the xscreensaver distribution */ #else /* !STANDALONE */ # include "xlock.h" /* from the xlockmore distribution */ @@ -155,8 +156,8 @@ ENTRYPOINT ModeSpecOpt atlantis_opts = #ifdef USE_MODULES ModStruct atlantis_description = -{"atlantis", "init_atlantis", "draw_atlantis", "release_atlantis", - "refresh_atlantis", "change_atlantis", NULL, &atlantis_opts, +{"atlantis", "init_atlantis", "draw_atlantis", NULL, + "refresh_atlantis", "change_atlantis", "free_atlantis", &atlantis_opts, 1000, NUM_SHARKS, SHARKSPEED, SHARKSIZE, 64, 1.0, "", "Shows moving sharks/whales/dolphin", 0, NULL}; @@ -271,8 +272,6 @@ Init(ModeInfo *mi) } else { - GLfloat s_plane[] = { 1, 0, 0, 0 }; - GLfloat t_plane[] = { 0, 0, 1, 0 }; GLfloat scale = 0.0005; if (!ap->texture) @@ -292,13 +291,18 @@ Init(ModeInfo *mi) glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); - glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); - glTexGenfv(GL_S, GL_EYE_PLANE, s_plane); - glTexGenfv(GL_T, GL_EYE_PLANE, t_plane); - - glEnable(GL_TEXTURE_GEN_S); - glEnable(GL_TEXTURE_GEN_T); +# ifndef HAVE_JWZGLES + { + GLfloat s_plane[] = { 1, 0, 0, 0 }; + GLfloat t_plane[] = { 0, 0, 1, 0 }; + glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR); + glTexGenfv(GL_S, GL_EYE_PLANE, s_plane); + glTexGenfv(GL_T, GL_EYE_PLANE, t_plane); + glEnable(GL_TEXTURE_GEN_S); + glEnable(GL_TEXTURE_GEN_T); + } +# endif glEnable(GL_TEXTURE_2D); glMatrixMode(GL_TEXTURE); @@ -312,20 +316,28 @@ Init(ModeInfo *mi) /* Add a little randomness */ fblue = ((float) (NRAND(30)) / 100.0) + 0.70; fgreen = fblue * 0.56; - glClearColor(0.0, fgreen, fblue, 0.0); + glClearColor(0.0, fgreen, fblue, 1.0); } ENTRYPOINT void reshape_atlantis(ModeInfo * mi, int width, int height) { - atlantisstruct *ap = &atlantis[MI_SCREEN(mi)]; + double h = (GLfloat) height / (GLfloat) width; + atlantisstruct *ap = &atlantis[MI_SCREEN(mi)]; + int y = 0; - glViewport(0, 0, ap->WinW = (GLint) width, ap->WinH = (GLint) height); + if (width > height * 5) { /* tiny window: show middle */ + height = width * 9/16; + y = -height/2; + h = height / (GLfloat) width; + } - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(400.0, (GLdouble) width / (GLdouble) height, 1.0, 2000000.0); - glMatrixMode(GL_MODELVIEW); + glViewport(0, y, ap->WinW = (GLint) width, ap->WinH = (GLint) height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluPerspective(400.0, 1/h, 1.0, 2000000.0); + glMatrixMode(GL_MODELVIEW); } @@ -340,8 +352,8 @@ clear_tank (atlantisstruct * ap) if (do_gradient && !ap->wire) { - GLfloat top[3] = { 0.00, 0.40, 0.70 }; - GLfloat bot[3] = { 0.00, 0.05, 0.18 }; + GLfloat top[4] = { 0.00, 0.40, 0.70, }; + GLfloat bot[4] = { 0.00, 0.05, 0.18, }; glMatrixMode(GL_PROJECTION); glPushMatrix(); @@ -351,26 +363,22 @@ clear_tank (atlantisstruct * ap) glPushMatrix(); { glLoadIdentity(); - - /* save GL_COLOR_MATERIAL, GL_COLOR_MATERIAL_FACE, etc. - This stalls the pipeline, so it would be better to do this - with explicit enable/disable calls, but I can't figure - out how to undo the glEnable() and glColor() calls below! - Simply calling glDisable(GL_COLOR_MATERIAL) is insufficient! - */ - glPushAttrib (GL_LIGHTING_BIT); - { - glEnable (GL_COLOR_MATERIAL); - - glShadeModel(GL_SMOOTH); - glBegin(GL_QUADS); - glColor3f (bot[0], bot[1], bot[2]); glVertex3f (-1, -1, 1); - glColor3f (bot[0], bot[1], bot[2]); glVertex3f ( 1, -1, 1); - glColor3f (top[0], top[1], top[2]); glVertex3f ( 1, 1, 1); - glColor3f (top[0], top[1], top[2]); glVertex3f (-1, 1, 1); - glEnd(); - } - glPopAttrib(); + /* glRotatef(current_device_rotation(), 0, 0, 1); */ + +# ifndef HAVE_JWZGLES + glShadeModel (GL_SMOOTH); +# endif + glDisable (GL_LIGHTING); + glBegin (GL_QUADS); + glColor3fv (bot); + glVertex3f (-1, -1, 1); glVertex3f ( 1, -1, 1); + glColor3fv (top); + glVertex3f ( 1, 1, 1); glVertex3f (-1, 1, 1); + glEnd(); + glEnable (GL_LIGHTING); + + /* Need to reset this because jwzgles conflates color and material */ + glColor3f (0.0, 0.1, 0.2); } glPopMatrix(); } @@ -452,11 +460,7 @@ init_atlantis(ModeInfo * mi) Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); - if (atlantis == NULL) { - if ((atlantis = (atlantisstruct *) calloc(MI_NUM_SCREENS(mi), - sizeof (atlantisstruct))) == NULL) - return; - } + MI_INIT(mi, atlantis); ap = &atlantis[screen]; ap->num_sharks = MI_COUNT(mi); if (ap->sharks == NULL) { @@ -521,8 +525,11 @@ draw_atlantis(ModeInfo * mi) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glPushMatrix(); + glRotatef(current_device_rotation(), 0, 0, 1); AllDisplay(ap); Animate(ap); + glPopMatrix(); if (mi->fps_p) do_fps (mi); glXSwapBuffers(display, window); @@ -532,35 +539,27 @@ draw_atlantis(ModeInfo * mi) /* *----------------------------------------------------------------------------- * The display is being taken away from us. Free up malloc'ed - * memory and X resources that we've alloc'ed. Only called - * once, we must zap everything for every screen. + * memory and X resources that we've alloc'ed. *----------------------------------------------------------------------------- */ ENTRYPOINT void -release_atlantis(ModeInfo * mi) +free_atlantis(ModeInfo * mi) { - int screen; - - if (atlantis != NULL) { - for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) { - atlantisstruct *ap = &atlantis[screen]; +#if 0 + atlantisstruct *ap = &atlantis[screen]; - if (ap->sharks) - (void) free((void *) ap->sharks); - } - (void) free((void *) atlantis); - atlantis = NULL; - } - FreeAllGL(mi); + if (ap->sharks) + (void) free((void *) ap->sharks); +#endif } +#ifndef STANDALONE ENTRYPOINT void refresh_atlantis(ModeInfo * mi) { } -#ifndef STANDALONE ENTRYPOINT void change_atlantis(ModeInfo * mi) {