3 Copyright (c) 2002, Calum Robinson
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 * Redistributions of source code must retain the above copyright notice, this
10 list of conditions and the following disclaimer.
12 * Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
16 * Neither the name of the author nor the names of its contributors may be used
17 to endorse or promote products derived from this software without specific
18 prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
24 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 /* -*- Mode: C; tab-width: 4 c-basic-offset: 4 indent-tabs-mode: t -*- */
40 #endif /* HAVE_CONFIG_H */
50 #endif /* HAVE_JWZGLES */
58 #include "gltrackball.h"
60 typedef struct _global_info_t global_info_t;
61 typedef struct _flurry_info_t flurry_info_t;
63 #define sqr(X) ((X) * (X))
64 #define PI 3.14159265358979323846f
65 #define DEG2RAD(X) (PI*(X)/180.0)
66 #define RAD2DEG(X) ((X)*180.0/PI)
67 #define rnd() (frand(1.0))
69 /* fabs: Absolute function. */
71 /* #define abs(a) ( (a) > 0 ? (a) : -(a) ) */
73 /* Force sign clamping to (-1;0;1) */
74 #define sgn(a) ((a)<0?-1:((a)?1:0))
76 /* used to compute the min and max of two expresions */
77 #define MIN_(a, b) (((a) < (b)) ? (a) : (b))
78 #define MAX_(a, b) (((a) > (b)) ? (a) : (b))
93 vector unsigned int v;
98 typedef struct SmokeParticleV
100 floatToVector color[4];
101 floatToVector position[3];
102 floatToVector oldposition[3];
103 floatToVector delta[3];
106 intToVector animFrame;
109 #define NUMSMOKEPARTICLES 3600
111 typedef struct SmokeV
113 SmokeParticleV p[NUMSMOKEPARTICLES/4];
116 float lastParticleTime;
120 floatToVector seraphimVertices[NUMSMOKEPARTICLES*2+1];
121 floatToVector seraphimColors[NUMSMOKEPARTICLES*4+1];
122 float seraphimTextures[NUMSMOKEPARTICLES*2*4];
125 void InitSmoke(SmokeV *s);
127 void UpdateSmoke_ScalarBase(global_info_t *global, flurry_info_t *flurry, SmokeV *s);
130 void UpdateSmoke_ScalarFrsqrte(global_info_t *global, flurry_info_t *flurry, SmokeV *s);
133 void UpdateSmoke_VectorBase(global_info_t *global, flurry_info_t *flurry, SmokeV *s);
134 void UpdateSmoke_VectorUnrolled(global_info_t *global, flurry_info_t *flurry, SmokeV *s);
138 void DrawSmoke_Scalar(global_info_t *global, flurry_info_t *flurry, SmokeV *s, float);
139 void DrawSmoke_Vector(global_info_t *global, flurry_info_t *flurry, SmokeV *s, float);
149 void UpdateStar(global_info_t *global, flurry_info_t *flurry, Star *s);
150 void InitStar(Star *s);
160 void UpdateSparkColour(global_info_t *info, flurry_info_t *flurry, Spark *s);
161 void InitSpark(Spark *s);
162 void UpdateSpark(global_info_t *info, flurry_info_t *flurry, Spark *s);
163 void DrawSpark(global_info_t *info, flurry_info_t *flurry, Spark *s);
165 /* #define FastDistance2D(x,y) hypot(x,y) */
167 /* UInt8 sys_glBPP=32; */
168 /* int SSMODE = FALSE; */
169 /* int currentVideoMode = 0; */
170 /* int cohesiveness = 7; */
171 /* int fieldStrength; */
172 /* int colorCoherence = 7; */
173 /* int fieldIncoherence = 0; */
174 /* int ifieldSpeed = 120; */
176 static inline float FastDistance2D(float x, float y)
178 /* this function computes the distance from 0,0 to x,y with ~3.5% error */
180 /* first compute the absolute value of x,y */
181 x = (x < 0.0f) ? -x : x;
182 y = (y < 0.0f) ? -y : y;
184 /* compute the minimum of x,y */
187 /* return the distance */
188 return(x+y-(mn*0.5f)-(mn*0.25f)+(mn*0.0625f));
194 static vector float FastDistance2DV(vector float x, vector float y) {
195 vector float mn, temp;
201 temp = vec_madd(mn, (vector float)(-0.6875), temp);
208 #define RandFlt(min, max) ((min) + frand((max) - (min)))
210 #define RandBell(scale) ((scale) * (-(frand(.5) + frand(.5) + frand(.5))))
212 extern GLuint theTexture;
214 void MakeTexture(void);
216 #define OPT_MODE_SCALAR_BASE 0x0
220 #define OPT_MODE_SCALAR_FRSQRTE 0x1
224 #define OPT_MODE_VECTOR_SIMPLE 0x2
225 #define OPT_MODE_VECTOR_UNROLLED 0x3
229 typedef enum _ColorModes
246 #define gravity 1500000.0f
248 #define incohesion 0.07f
249 #define colorIncoherence 0.15f
250 #define streamSpeed 450.0
251 #define fieldCoherence 0
252 #define fieldSpeed 12.0f
253 #define numParticles 250
255 #define seraphDistance 2000.0f
256 #define streamSize 25000.0f
257 #define fieldRange 1000.0f
258 #define streamBias 7.0f
260 #define MAX_SPARKS 64
262 struct _flurry_info_t {
264 ColorModes currentColorMode;
267 Spark *spark[MAX_SPARKS];
268 float streamExpansion;
270 double flurryRandomSeed;
279 struct _global_info_t {
281 GLXContext *glx_context;
288 flurry_info_t *flurry;
291 #define kNumSpectrumEntries 512
294 double TimeInSecondsSinceStart(void);
296 #endif /* Include/Define */