be07c963367a1e03ca53eb90682f6484c183d2f6
[xscreensaver] / hacks / glx / atlantis.h
1 /* atlantis --- Shows moving 3D sea animals */
2
3 /* Copyright (c) E. Lassauge, 1998. */
4
5 /*
6  * Permission to use, copy, modify, and distribute this software and its
7  * documentation for any purpose and without fee is hereby granted,
8  * provided that the above copyright notice appear in all copies and that
9  * both that copyright notice and this permission notice appear in
10  * supporting documentation.
11  *
12  * This file is provided AS IS with no warranties of any kind.  The author
13  * shall have no liability with respect to the infringement of copyrights,
14  * trade secrets or any patents by this file or any part thereof.  In no
15  * event will the author be liable for any lost revenue or profits or
16  * other special, indirect and consequential damages.
17  *
18  * The original code for this mode was written by Mark J. Kilgard
19  * as a demo for openGL programming.
20  * 
21  * Porting it to xlock  was possible by comparing the original Mesa's morph3d 
22  * demo with it's ported version to xlock, so thanks for Marcelo F. Vianna 
23  * (look at morph3d.c) for his indirect help.
24  *
25  * Thanks goes also to Brian Paul for making it possible and inexpensive
26  * to use OpenGL at home.
27  *
28  * My e-mail address is lassauge@sagem.fr
29  *
30  * Eric Lassauge  (May-13-1998)
31  *
32  */
33
34 /**
35  * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
36  * ALL RIGHTS RESERVED
37  * Permission to use, copy, modify, and distribute this software for
38  * any purpose and without fee is hereby granted, provided that the above
39  * copyright notice appear in all copies and that both the copyright notice
40  * and this permission notice appear in supporting documentation, and that
41  * the name of Silicon Graphics, Inc. not be used in advertising
42  * or publicity pertaining to distribution of the software without specific,
43  * written prior permission.
44  *
45  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
46  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
47  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
48  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
49  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
50  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
51  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
52  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
53  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
54  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
55  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
56  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
57  *
58  * US Government Users Restricted Rights
59  * Use, duplication, or disclosure by the Government is subject to
60  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
61  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
62  * clause at DFARS 252.227-7013 and/or in similar or successor
63  * clauses in the FAR or the DOD or NASA FAR Supplement.
64  * Unpublished-- rights reserved under the copyright laws of the
65  * United States.  Contractor/manufacturer is Silicon Graphics,
66  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
67  *
68  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
69  */
70 #include <GL/gl.h>
71 #include <GL/glx.h>
72
73 #define RAD 57.295
74 #define RRAD 0.01745
75
76 /* default values */
77 #define NUM_SHARKS 4
78 #define SHARKSPEED 100
79 #define SHARKSIZE 6000
80
81 typedef struct _fishRec {
82         float       x, y, z, phi, theta, psi, v;
83         float       xt, yt, zt;
84         float       htail, vtail;
85         float       dtheta;
86         int         spurt, attack;
87 } fishRec;
88
89 typedef struct {
90         GLint       WinH, WinW;
91         GLXContext *glx_context;
92         int         num_sharks;
93         float       sharkspeed, whalespeed;
94         int         sharksize;
95         int         wire;
96         Bool        whaledir;
97         fishRec    *sharks;
98         fishRec     momWhale;
99         fishRec     babyWhale;
100         fishRec     dolph;
101
102         XImage     *texture;       /* water distortion overlay bits */
103 } atlantisstruct;
104
105 extern void FishTransform(fishRec *);
106 extern void WhalePilot(fishRec *, float, Bool);
107 extern void SharkPilot(fishRec *, float);
108 extern void SharkMiss(atlantisstruct *, int);
109 extern void DrawWhale(fishRec *, int);
110 extern void DrawShark(fishRec *, int);
111 extern void DrawDolphin(fishRec *, int);