xref: /haiku/src/add-ons/screen_savers/flurry/Shared.h (revision b55a57da7173b9af0432bd3e148d03f06161d036)
1 /*
2 
3 Copyright (c) 2002, Calum Robinson
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8 
9 * Redistributions of source code must retain the above copyright notice, this
10   list of conditions and the following disclaimer.
11 
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.
15 
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.
19 
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.
30 
31 */
32 #ifndef _SHARED_H_
33 #define _SHARED_H_
34 
35 #include <math.h>
36 #include <stdio.h>
37 
38 #include <GL/gl.h>
39 #include <GL/glu.h>
40 
41 struct SmokeV;
42 struct Spark;
43 struct Star;
44 
45 #define MAX_SPARKS 64
46 #define seraphDistance 2000.0f
47 
48 /* used to compute the min and max of two expresions */
49 #define MIN_(a, b)  (((a) < (b)) ? (a) : (b))
50 #define MAX_(a, b)  (((a) > (b)) ? (a) : (b))
51 
52 #define random() rand()
53 #define RandFlt(min, max) (min + (max - min) * rand() / (float) RAND_MAX)
54 #define RandBell(scale) (scale * (1.0f - (rand() + rand() + rand()) / ((float) RAND_MAX * 1.5f)))
55 
56 typedef enum _ColorModes
57 {
58 	redColorMode = 0,
59 	magentaColorMode,
60 	blueColorMode,
61 	cyanColorMode,
62 	greenColorMode,
63 	yellowColorMode,
64 	slowCyclicColorMode,
65 	cyclicColorMode,
66 	tiedyeColorMode,
67 	rainbowColorMode,
68 	whiteColorMode,
69 	multiColorMode,
70 	darkColorMode
71 } ColorModes;
72 
73 typedef struct flurry_info_t {
74 	flurry_info_t *next;
75 	ColorModes currentColorMode;
76 	SmokeV *s;
77 	Star *star;
78 	Spark *spark[MAX_SPARKS];
79 	float streamExpansion;
80 	int numStreams;
81 	double randomSeed;
82 	double fTime;
83 	double fOldTime;
84 	double fDeltaTime;
85 	double briteFactor;
86 	float drag;
87 	int dframe;
88 	float sys_glWidth;
89 	float sys_glHeight;
90 } flurry_info_t;
91 
92 
93 #endif	// _SHARED_H_
94