http://packetstormsecurity.org/UNIX/admin/xscreensaver-4.14.tar.gz
[xscreensaver] / hacks / glx / atlantis.c
1 /* atlantis --- Shows moving 3D sea animals */
2
3 #if 0
4 static const char sccsid[] = "@(#)atlantis.c    5.08 2003/04/09 xlockmore";
5 #endif
6
7 /* Copyright (c) E. Lassauge, 1998. */
8
9 /*
10  * Permission to use, copy, modify, and distribute this software and its
11  * documentation for any purpose and without fee is hereby granted,
12  * provided that the above copyright notice appear in all copies and that
13  * both that copyright notice and this permission notice appear in
14  * supporting documentation.
15  *
16  * This file is provided AS IS with no warranties of any kind.  The author
17  * shall have no liability with respect to the infringement of copyrights,
18  * trade secrets or any patents by this file or any part thereof.  In no
19  * event will the author be liable for any lost revenue or profits or
20  * other special, indirect and consequential damages.
21  *
22  * The original code for this mode was written by Mark J. Kilgard
23  * as a demo for openGL programming.
24  * 
25  * Porting it to xlock  was possible by comparing the original Mesa's morph3d 
26  * demo with it's ported version to xlock, so thanks for Marcelo F. Vianna 
27  * (look at morph3d.c) for his indirect help.
28  *
29  * Thanks goes also to Brian Paul for making it possible and inexpensive
30  * to use OpenGL at home.
31  *
32  * My e-mail address is lassauge@mail.dotcom.fr
33  *
34  * Eric Lassauge  (May-13-1998)
35  *
36  * REVISION HISTORY:
37  * 
38  * Jamie Zawinski, 2-Apr-01:  - The fishies were inside out!  The back faces
39  *                              were being drawn, not the front faces.
40  *                            - Added a texture to simulate light from the
41  *                              surface, like in the SGI version.
42  *
43  * David A. Bagley - 98/06/17 : Add whalespeed option. Global options to
44  *                              initialize local variables are now:
45  *                              XLock.atlantis.cycles: 100      ! SharkSpeed
46  *                              XLock.atlantis.batchcount: 4    ! SharkNum
47  *                              XLock.atlantis.whalespeed: 250  ! WhaleSpeed
48  *                              XLock.atlantis.size: 6000       ! SharkSize
49  *                              Add random direction for whales/dolphins
50  * 
51  * E.Lassauge - 98/06/16: Use the following global options to initialize
52  *                        local variables :
53  *                              XLock.atlantis.delay: 100       ! SharkSpeed
54  *                              XLock.atlantis.batchcount: 4    ! SharkNum
55  *                              XLock.atlantis.cycles: 250      ! WhaleSpeed
56  *                              XLock.atlantis.size: 6000       ! SharkSize
57  *                        Add support for -/+ wireframe (t'was so easy to do!)
58  *
59  * TODO : 
60  *        - add a sort of background image or random bg color
61  *        - better handling of sizes and speeds
62  *        - test standalone and module modes
63  *        - purify it (!)
64  */
65
66 /* Copyright (c) Mark J. Kilgard, 1994. */
67
68 /**
69  * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
70  * ALL RIGHTS RESERVED
71  * Permission to use, copy, modify, and distribute this software for
72  * any purpose and without fee is hereby granted, provided that the above
73  * copyright notice appear in all copies and that both the copyright notice
74  * and this permission notice appear in supporting documentation, and that
75  * the name of Silicon Graphics, Inc. not be used in advertising
76  * or publicity pertaining to distribution of the software without specific,
77  * written prior permission.
78  *
79  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
80  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
81  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
82  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
83  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
84  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
85  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
86  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
87  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
88  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
89  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
90  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
91  *
92  * US Government Users Restricted Rights
93  * Use, duplication, or disclosure by the Government is subject to
94  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
95  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
96  * clause at DFARS 252.227-7013 and/or in similar or successor
97  * clauses in the FAR or the DOD or NASA FAR Supplement.
98  * Unpublished-- rights reserved under the copyright laws of the
99  * United States.  Contractor/manufacturer is Silicon Graphics,
100  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
101  *
102  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
103  */
104
105 #define DEF_TEXTURE "True"
106 #define DEF_GRADIENT "False"
107 #define DEF_WHALESPEED  "250"
108
109 #ifdef STANDALONE
110 # define PROGCLASS      "Atlantis"
111 # define HACK_INIT      init_atlantis
112 # define HACK_DRAW      draw_atlantis
113 # define HACK_RESHAPE   reshape_atlantis
114 # define atlantis_opts  xlockmore_opts
115 # define DEFAULTS       "*delay:       25000 \n" \
116                          "*count:          4 \n" \
117                          "*showFPS:    False \n" \
118                          "*cycles:       100 \n" \
119                          "*size:        6000 \n" \
120                          "*wireframe:  False \n" \
121                          "*texture:    " DEF_TEXTURE    " \n" \
122                          "*gradient:   " DEF_GRADIENT   " \n" \
123                          "*whalespeed: " DEF_WHALESPEED " \n"
124 # include "xlockmore.h"         /* from the xscreensaver distribution */
125 #else  /* !STANDALONE */
126 # include "xlock.h"             /* from the xlockmore distribution */
127 #include "vis.h"
128 #endif /* !STANDALONE */
129
130 #ifdef USE_GL
131
132 #include "atlantis.h"
133 #include <GL/glu.h>
134
135
136 static int  whalespeed;
137 static int do_texture;
138 static int do_gradient;
139 static XrmOptionDescRec opts[] =
140 {
141      {"-whalespeed", ".atlantis.whalespeed", XrmoptionSepArg, (caddr_t) NULL},
142      {"-texture",    ".atlantis.texture",    XrmoptionNoArg, (caddr_t)"true"},
143      {"+texture",    ".atlantis.texture",    XrmoptionNoArg, (caddr_t)"false"},
144      {"-gradient",   ".atlantis.gradient",   XrmoptionNoArg, (caddr_t)"true"},
145      {"+gradient",   ".atlantis.gradient",   XrmoptionNoArg, (caddr_t)"false"},
146 };
147
148 static argtype vars[] =
149 {
150  {(caddr_t *) & whalespeed, "whalespeed", "WhaleSpeed", DEF_WHALESPEED, t_Int},
151  {(caddr_t *) &do_texture,  "texture",    "Texture",    DEF_TEXTURE,   t_Bool},
152  {(caddr_t *) &do_gradient, "gradient",   "Gradient",   DEF_GRADIENT,  t_Bool},
153 };
154
155 static OptionStruct desc[] =
156 {
157         {"-whalespeed num", "speed of whales and the dolphin"},
158         {"-texture num",    "whether to introduce water-like distortion"}
159 };
160
161 ModeSpecOpt atlantis_opts =
162 {sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
163
164 #ifdef USE_MODULES
165 ModStruct   atlantis_description =
166 {"atlantis", "init_atlantis", "draw_atlantis", "release_atlantis",
167  "refresh_atlantis", "change_atlantis", NULL, &atlantis_opts,
168  1000, NUM_SHARKS, SHARKSPEED, SHARKSIZE, 64, 1.0, "",
169  "Shows moving sharks/whales/dolphin", 0, NULL};
170
171 #endif
172
173 static atlantisstruct *atlantis = NULL;
174
175 #include "xpm-ximage.h"
176
177 #include "../images/sea-texture.xpm"
178
179
180 static void
181 parse_image_data(ModeInfo *mi)
182 {
183   atlantisstruct *ap = &atlantis[MI_SCREEN(mi)];
184   ap->texture = xpm_to_ximage (mi->dpy,
185                                mi->xgwa.visual,
186                                mi->xgwa.colormap,
187                                sea_texture);
188 }
189
190 static void
191 InitFishs(atlantisstruct * ap)
192 {
193         int         i;
194
195         for (i = 0; i < ap->num_sharks; i++) {
196                 ap->sharks[i].x = 70000.0 + NRAND(ap->sharksize);
197                 ap->sharks[i].y = NRAND(ap->sharksize);
198                 ap->sharks[i].z = NRAND(ap->sharksize);
199                 ap->sharks[i].psi = NRAND(360) - 180.0;
200                 ap->sharks[i].v = 1.0;
201         }
202
203         /* Random whale direction */
204         ap->whaledir = LRAND() & 1;
205
206         ap->dolph.x = 30000.0;
207         ap->dolph.y = 0.0;
208         ap->dolph.z = (float) (ap->sharksize);
209         ap->dolph.psi = (ap->whaledir) ? 90.0 : -90.0;
210         ap->dolph.theta = 0.0;
211         ap->dolph.v = 6.0;
212
213         ap->momWhale.x = 70000.0;
214         ap->momWhale.y = 0.0;
215         ap->momWhale.z = 0.0;
216         ap->momWhale.psi = (ap->whaledir) ? 90.0 : -90.0;
217         ap->momWhale.theta = 0.0;
218         ap->momWhale.v = 3.0;
219
220         ap->babyWhale.x = 60000.0;
221         ap->babyWhale.y = -2000.0;
222         ap->babyWhale.z = -2000.0;
223         ap->babyWhale.psi = (ap->whaledir) ? 90.0 : -90.0;
224         ap->babyWhale.theta = 0.0;
225         ap->babyWhale.v = 3.0;
226 }
227
228 static void
229 Init(ModeInfo *mi)
230 {
231         atlantisstruct *ap = &atlantis[MI_SCREEN(mi)];
232
233         static float ambient[] =
234         {0.1, 0.1, 0.1, 1.0};
235         static float diffuse[] =
236         {1.0, 1.0, 1.0, 1.0};
237         static float position[] =
238         {0.0, 1.0, 0.0, 0.0};
239         static float mat_shininess[] =
240         {90.0};
241         static float mat_specular[] =
242         {0.8, 0.8, 0.8, 1.0};
243         static float mat_diffuse[] =
244         {0.46, 0.66, 0.795, 1.0};
245         static float mat_ambient[] =
246         {0.0, 0.1, 0.2, 1.0};
247         static float lmodel_ambient[] =
248         {0.4, 0.4, 0.4, 1.0};
249         static float lmodel_localviewer[] =
250         {0.0};
251         float        fblue = 0.0, fgreen;
252
253         glFrontFace(GL_CCW);
254
255         if (ap->wire)
256           {
257             glDisable(GL_DEPTH_TEST);
258             glDisable(GL_CULL_FACE);
259             glDisable(GL_LIGHTING);
260             glDisable(GL_NORMALIZE);
261           }
262         else
263           {
264             glDepthFunc(GL_LEQUAL);
265             glEnable(GL_DEPTH_TEST);
266             glEnable(GL_CULL_FACE);
267             glEnable(GL_NORMALIZE);
268             glShadeModel(GL_SMOOTH);
269
270             glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);
271             glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
272             glLightfv(GL_LIGHT0, GL_POSITION, position);
273             glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
274             glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lmodel_localviewer);
275             glEnable(GL_LIGHTING);
276             glEnable(GL_LIGHT0);
277
278             glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
279             glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
280             glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse);
281             glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
282           }
283
284         if (ap->wire || !do_texture)
285           {
286             glDisable(GL_TEXTURE_2D);
287           }
288         else
289           {
290             GLfloat s_plane[] = { 1, 0, 0, 0 };
291             GLfloat t_plane[] = { 0, 0, 1, 0 };
292             GLfloat scale = 0.0005;
293
294             if (!ap->texture)
295               parse_image_data (mi);
296
297             clear_gl_error();
298             glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
299                          ap->texture->width, ap->texture->height, 0,
300                          GL_RGBA, GL_UNSIGNED_BYTE,
301                          ap->texture->data);
302             check_gl_error("texture");
303
304             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
305             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
306             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
307             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
308
309             glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
310
311             glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
312             glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
313             glTexGenfv(GL_S, GL_EYE_PLANE, s_plane);
314             glTexGenfv(GL_T, GL_EYE_PLANE, t_plane);
315
316             glEnable(GL_TEXTURE_GEN_S);
317             glEnable(GL_TEXTURE_GEN_T);
318             glEnable(GL_TEXTURE_2D);
319
320             glMatrixMode(GL_TEXTURE);
321             glLoadIdentity();
322             glScalef(scale, scale, 1);
323             glMatrixMode(GL_MODELVIEW);
324           }
325
326         InitFishs(ap);
327
328         /* Add a little randomness */
329         fblue = ((float) (NRAND(30)) / 100.0) + 0.70;
330         fgreen = fblue * 0.56;
331         glClearColor(0.0, fgreen, fblue, 0.0);
332 }
333
334 void
335 reshape_atlantis(ModeInfo * mi, int width, int height)
336 {
337         atlantisstruct *ap = &atlantis[MI_SCREEN(mi)];
338
339         glViewport(0, 0, ap->WinW = (GLint) width, ap->WinH = (GLint) height);
340
341         glMatrixMode(GL_PROJECTION);
342         glLoadIdentity();
343         gluPerspective(400.0, (GLdouble) width / (GLdouble) height, 1.0, 2000000.0);
344         glMatrixMode(GL_MODELVIEW);
345 }
346
347
348 /* jwz -- this doesn't really work very well.
349
350    All I want to do is give the tank a gradient-filled background, instead
351    of just solid blue.  The following was my guess as to how to do this,
352    but it kills my frame rate.  I guess there's a more efficient way to do
353    this, but I don't see it...
354
355    I mean, all I want to do is dump some non-projected bytes into the color
356    buffer, then zero out the depth buffer.  That *can't* be expensive, can
357    it?
358  */
359 static void
360 clear_tank (atlantisstruct * ap)
361 {
362   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
363
364   if (do_gradient && !ap->wire)
365     {
366       static GLuint gradient_list = 0;
367       static GLuint gradient_tex = 0;
368
369       if (gradient_list == 0)
370         {
371           unsigned char *pixels = 0;
372           int start = 64;
373           int end = start + 128;
374           int size = 4 * (end - start);
375           int i;
376
377           pixels = (unsigned char *) malloc (size);
378           i = 0;
379           while (i < size)
380             {
381               pixels[i] = 0; i++;
382               pixels[i] = (start + (i>>2)) * 0.56; i++;
383               pixels[i] = (start + (i>>2)); i++;
384               pixels[i] = 255; i++;
385             }
386
387           clear_gl_error();
388
389           glGenTextures(1, &gradient_tex);
390           glBindTexture(GL_TEXTURE_1D, gradient_tex);
391
392           glTexImage1D(GL_TEXTURE_1D, 0, 4,
393                        (end - start), 0,
394                        GL_RGBA, GL_UNSIGNED_BYTE, pixels);
395           check_gl_error ("gradient texture");
396           glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
397           glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
398
399
400           gradient_list = glGenLists(1);
401           glNewList(gradient_list, GL_COMPILE);
402
403           glDepthMask (False);
404           glDisable(GL_DEPTH_TEST);
405           glDisable(GL_LIGHTING);
406           glDisable(GL_TEXTURE_2D);
407           glEnable(GL_TEXTURE_1D);
408           glBindTexture(GL_TEXTURE_1D, gradient_tex);
409           glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); 
410           glTexParameterf(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
411
412           glMatrixMode(GL_PROJECTION);
413           glPushMatrix();
414           glLoadIdentity();
415           glRotatef(90, 0, 0, 1);
416           glTranslatef(-1, -1, 0);
417           glScalef(2, 2, 1);
418
419           glBegin(GL_QUADS);
420           glTexCoord1i(1); glVertex3i(1, 0, 0);
421           glTexCoord1i(0); glVertex3i(0, 0, 0);
422           glTexCoord1i(0); glVertex3i(0, 1, 0);
423           glTexCoord1i(1); glVertex3i(1, 1, 0);
424           glEnd();
425
426           glPopMatrix();
427
428           glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 
429           glDisable(GL_TEXTURE_1D);
430
431           glDepthMask (True);
432           glEnable(GL_DEPTH_TEST);
433           glEnable(GL_CULL_FACE);
434           glEnable(GL_LIGHTING);
435           if (do_texture)
436             glEnable(GL_TEXTURE_2D);
437
438           glEndList();
439           check_gl_error ("gradient list");
440         }
441
442       glCallList(gradient_list);
443     }
444 }
445
446
447 static void
448 Animate(atlantisstruct * ap)
449 {
450         int         i;
451
452         for (i = 0; i < ap->num_sharks; i++) {
453                 SharkPilot(&(ap->sharks[i]), ap->sharkspeed);
454                 SharkMiss(ap, i);
455         }
456         WhalePilot(&(ap->dolph), ap->whalespeed, ap->whaledir);
457         ap->dolph.phi++;
458         WhalePilot(&(ap->momWhale), ap->whalespeed, ap->whaledir);
459         ap->momWhale.phi++;
460         WhalePilot(&(ap->babyWhale), ap->whalespeed, ap->whaledir);
461         ap->babyWhale.phi++;
462 }
463
464 static void
465 AllDisplay(atlantisstruct * ap)
466 {
467         int         i;
468
469         clear_tank(ap);
470
471         for (i = 0; i < ap->num_sharks; i++) {
472                 glPushMatrix();
473                 FishTransform(&(ap->sharks[i]));
474                 DrawShark(&(ap->sharks[i]), ap->wire);
475                 glPopMatrix();
476         }
477
478         glPushMatrix();
479         FishTransform(&(ap->dolph));
480         DrawDolphin(&(ap->dolph), ap->wire);
481         glPopMatrix();
482
483         glPushMatrix();
484         FishTransform(&(ap->momWhale));
485         DrawWhale(&(ap->momWhale), ap->wire);
486         glPopMatrix();
487
488         glPushMatrix();
489         FishTransform(&(ap->babyWhale));
490         glScalef(0.45, 0.45, 0.3);
491         DrawWhale(&(ap->babyWhale), ap->wire);
492         glPopMatrix();
493 }
494
495 /*
496  *-----------------------------------------------------------------------------
497  *-----------------------------------------------------------------------------
498  *    Xlock hooks.
499  *-----------------------------------------------------------------------------
500  *-----------------------------------------------------------------------------
501  */
502
503 /*
504  *-----------------------------------------------------------------------------
505  *    Initialize atlantis.  Called each time the window changes.
506  *-----------------------------------------------------------------------------
507  */
508
509 void
510 init_atlantis(ModeInfo * mi)
511 {
512         int         screen = MI_SCREEN(mi);
513         atlantisstruct *ap;
514         Display    *display = MI_DISPLAY(mi);
515         Window      window = MI_WINDOW(mi);
516
517         if (atlantis == NULL) {
518                 if ((atlantis = (atlantisstruct *) calloc(MI_NUM_SCREENS(mi),
519                                            sizeof (atlantisstruct))) == NULL)
520                         return;
521         }
522         ap = &atlantis[screen];
523         ap->num_sharks = MI_COUNT(mi);
524         if (ap->sharks == NULL) {
525                 if ((ap->sharks = (fishRec *) calloc(ap->num_sharks,
526                                                 sizeof (fishRec))) == NULL) {
527                         /* free everything up to now */
528                         (void) free((void *) atlantis);
529                         atlantis = NULL;
530                         return;
531                 }
532         }
533         ap->sharkspeed = MI_CYCLES(mi);         /* has influence on the "width"
534                                                    of the movement */
535         ap->sharksize = MI_SIZE(mi);    /* has influence on the "distance"
536                                            of the sharks */
537         ap->whalespeed = whalespeed;
538         ap->wire = MI_IS_WIREFRAME(mi);
539
540         if (MI_IS_DEBUG(mi)) {
541                 (void) fprintf(stderr,
542                                "%s:\n\tnum_sharks=%d\n\tsharkspeed=%.1f\n\tsharksize=%d\n\twhalespeed=%.1f\n\twireframe=%s\n",
543                                MI_NAME(mi),
544                                ap->num_sharks,
545                                ap->sharkspeed,
546                                ap->sharksize,
547                                ap->whalespeed,
548                                ap->wire ? "yes" : "no"
549                         );
550         }
551         if ((ap->glx_context = init_GL(mi)) != NULL) {
552
553                 reshape_atlantis(mi, MI_WIDTH(mi), MI_HEIGHT(mi));
554                 glDrawBuffer(GL_BACK);
555                 Init(mi);
556                 AllDisplay(ap);
557                 glXSwapBuffers(display, window);
558
559         } else {
560                 MI_CLEARWINDOW(mi);
561         }
562 }
563
564 /*
565  *-----------------------------------------------------------------------------
566  *    Called by the mainline code periodically to update the display.
567  *-----------------------------------------------------------------------------
568  */
569 void
570 draw_atlantis(ModeInfo * mi)
571 {
572         atlantisstruct *ap = &atlantis[MI_SCREEN(mi)];
573
574         Display    *display = MI_DISPLAY(mi);
575         Window      window = MI_WINDOW(mi);
576
577         MI_IS_DRAWN(mi) = True;
578
579         if (!ap->glx_context)
580                 return;
581
582         glXMakeCurrent(display, window, *(ap->glx_context));
583
584         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
585
586         AllDisplay(ap);
587         Animate(ap);
588
589         if (mi->fps_p) do_fps (mi);
590         glXSwapBuffers(display, window);
591 }
592
593
594 /*
595  *-----------------------------------------------------------------------------
596  *    The display is being taken away from us.  Free up malloc'ed 
597  *      memory and X resources that we've alloc'ed.  Only called
598  *      once, we must zap everything for every screen.
599  *-----------------------------------------------------------------------------
600  */
601
602 void
603 release_atlantis(ModeInfo * mi)
604 {
605         int         screen;
606
607         if (atlantis != NULL) {
608                 for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++) {
609                         atlantisstruct *ap = &atlantis[screen];
610
611                         if (ap->sharks)
612                                 (void) free((void *) ap->sharks);
613                 }
614                 (void) free((void *) atlantis);
615                 atlantis = NULL;
616         }
617         FreeAllGL(mi);
618 }
619
620 void
621 refresh_atlantis(ModeInfo * mi)
622 {
623 }
624
625 void
626 change_atlantis(ModeInfo * mi)
627 {
628         atlantisstruct *ap = &atlantis[MI_SCREEN(mi)];
629
630         if (!ap->glx_context)
631                 return;
632
633         glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(ap->glx_context));
634         Init(mi);
635 }
636
637 #endif /* USE_GL */