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 -*- */
47 #include "gltrackball.h"
49 typedef struct _global_info_t global_info_t;
50 typedef struct _flurry_info_t flurry_info_t;
52 #define sqr(X) ((X) * (X))
53 #define PI 3.14159265358979323846f
54 #define DEG2RAD(X) (PI*(X)/180.0)
55 #define RAD2DEG(X) ((X)*180.0/PI)
56 #define rnd() (frand(1.0))
58 /* fabs: Absolute function. */
60 /* #define abs(a) ( (a) > 0 ? (a) : -(a) ) */
62 /* Force sign clamping to (-1;0;1) */
63 #define sgn(a) ((a)<0?-1:((a)?1:0))
65 /* used to compute the min and max of two expresions */
66 #define MIN_(a, b) (((a) < (b)) ? (a) : (b))
67 #define MAX_(a, b) (((a) > (b)) ? (a) : (b))
79 vector unsigned int v;
83 typedef struct SmokeParticleV
85 floatToVector color[4];
86 floatToVector position[3];
87 floatToVector oldposition[3];
88 floatToVector delta[3];
91 intToVector animFrame;
94 #define NUMSMOKEPARTICLES 3600
98 SmokeParticleV p[NUMSMOKEPARTICLES/4];
101 float lastParticleTime;
105 floatToVector seraphimVertices[NUMSMOKEPARTICLES*2+1];
106 floatToVector seraphimColors[NUMSMOKEPARTICLES*4+1];
107 float seraphimTextures[NUMSMOKEPARTICLES*2*4];
110 void InitSmoke(SmokeV *s);
112 void UpdateSmoke_ScalarBase(global_info_t *global, flurry_info_t *flurry, SmokeV *s);
114 void UpdateSmoke_ScalarFrsqrte(global_info_t *global, flurry_info_t *flurry, SmokeV *s);
117 void UpdateSmoke_VectorBase(global_info_t *global, flurry_info_t *flurry, SmokeV *s);
118 void UpdateSmoke_VectorUnrolled(global_info_t *global, flurry_info_t *flurry, SmokeV *s);
121 void DrawSmoke_Scalar(global_info_t *global, flurry_info_t *flurry, SmokeV *s, float);
122 void DrawSmoke_Vector(global_info_t *global, flurry_info_t *flurry, SmokeV *s, float);
132 void UpdateStar(global_info_t *global, flurry_info_t *flurry, Star *s);
133 void InitStar(Star *s);
143 void UpdateSparkColour(global_info_t *info, flurry_info_t *flurry, Spark *s);
144 void InitSpark(Spark *s);
145 void UpdateSpark(global_info_t *info, flurry_info_t *flurry, Spark *s);
146 void DrawSpark(global_info_t *info, flurry_info_t *flurry, Spark *s);
148 /* #define FastDistance2D(x,y) hypot(x,y) */
150 /* UInt8 sys_glBPP=32; */
151 /* int SSMODE = FALSE; */
152 /* int currentVideoMode = 0; */
153 /* int cohesiveness = 7; */
154 /* int fieldStrength; */
155 /* int colorCoherence = 7; */
156 /* int fieldIncoherence = 0; */
157 /* int ifieldSpeed = 120; */
159 static inline float FastDistance2D(float x, float y)
161 /* this function computes the distance from 0,0 to x,y with ~3.5% error */
163 /* first compute the absolute value of x,y */
164 x = (x < 0.0f) ? -x : x;
165 y = (y < 0.0f) ? -y : y;
167 /* compute the minimum of x,y */
170 /* return the distance */
171 return(x+y-(mn*0.5f)-(mn*0.25f)+(mn*0.0625f));
176 static vector float FastDistance2DV(vector float x, vector float y) {
177 vector float mn, temp;
183 temp = vec_madd(mn, (vector float)(-0.6875), temp);
189 #define RandFlt(min, max) ((min) + frand((max) - (min)))
191 #define RandBell(scale) ((scale) * (-(frand(.5) + frand(.5) + frand(.5))))
193 extern GLuint theTexture;
195 void MakeTexture(void);
197 #define OPT_MODE_SCALAR_BASE 0x0
200 #define OPT_MODE_SCALAR_FRSQRTE 0x1
204 #define OPT_MODE_VECTOR_SIMPLE 0x2
205 #define OPT_MODE_VECTOR_UNROLLED 0x3
208 typedef enum _ColorModes
225 #define gravity 1500000.0f
227 #define incohesion 0.07f
228 #define colorIncoherence 0.15f
229 #define streamSpeed 450.0
230 #define fieldCoherence 0
231 #define fieldSpeed 12.0f
232 #define numParticles 250
234 #define seraphDistance 2000.0f
235 #define streamSize 25000.0f
236 #define fieldRange 1000.0f
237 #define streamBias 7.0f
239 #define MAX_SPARKS 64
241 struct _flurry_info_t {
243 ColorModes currentColorMode;
246 Spark *spark[MAX_SPARKS];
247 float streamExpansion;
249 double flurryRandomSeed;
258 struct _global_info_t {
260 GLXContext *glx_context;
267 flurry_info_t *flurry;
270 #define kNumSpectrumEntries 512
273 double TimeInSecondsSinceStart(void);
275 #endif /* Include/Define */