From http://www.jwz.org/xscreensaver/xscreensaver-5.16.tar.gz
[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@users.sourceforge.net
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
71 #ifdef HAVE_CONFIG_H
72 # include "config.h"
73 #endif /* HAVE_CONFIG_H */
74
75 #ifdef STANDALONE
76 # include <math.h>
77 # include "screenhackI.h"
78 # ifndef HAVE_COCOA
79 #  include <GL/gl.h>
80 #  include <GL/glx.h>
81 # endif
82 #else
83 # include "xlock.h"
84 #endif
85
86 #ifdef HAVE_JWZGLES
87 # include "jwzgles.h"
88 #endif /* HAVE_JWZGLES */
89
90 #define RAD 57.295
91 #define RRAD 0.01745
92
93 /* default values */
94 #define NUM_SHARKS 4
95 #define SHARKSPEED 100
96 #define SHARKSIZE 6000
97
98 typedef struct _fishRec {
99         float       x, y, z, phi, theta, psi, v;
100         float       xt, yt, zt;
101         float       htail, vtail;
102         float       dtheta;
103         int         spurt, attack;
104         int         sign;
105 } fishRec;
106
107 typedef struct {
108         GLint       WinH, WinW;
109         GLXContext *glx_context;
110         int         num_sharks;
111         float       sharkspeed, whalespeed;
112         int         sharksize;
113         int         wire;
114         Bool        whaledir;
115         fishRec    *sharks;
116         fishRec     momWhale;
117         fishRec     babyWhale;
118         fishRec     dolph;
119
120         XImage     *texture;       /* water distortion overlay bits */
121 } atlantisstruct;
122
123 extern void FishTransform(fishRec *);
124 extern void WhalePilot(fishRec *, float, Bool);
125 extern void SharkPilot(fishRec *, float);
126 extern void SharkMiss(atlantisstruct *, int);
127 extern void DrawWhale(fishRec *, int);
128 extern void DrawShark(fishRec *, int);
129 extern void DrawDolphin(fishRec *, int);