3 * Daniel Nelson - 9/4/0
5 * Copyright (C) 2000 Daniel Nelson
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * Daniel Nelson - aluminumangel.org
25 * Draws all the sparkles and signs!
33 #include "Displayer.h"
34 #include "SparkleManager.h"
35 #include "SignManager.h"
37 const GLfloat mote_colors
[12][3]
38 = { { 1.0f
, 0.0f
, 0.0f
}, // normal
39 { 0.9f
, 0.4f
, 0.0f
}, // yellow flare
40 { 0.8f
, 0.8f
, 0.0f
}, // orange flare
41 { 0.3f
, 0.3f
, 1.0f
}, // blue flare
42 { 0.4f
, 0.4f
, 0.4f
}, // gray
43 { 0.0f
, 0.0f
, 0.0f
}, // black
44 { 0.9f
, 0.9f
, 0.9f
}, // white
45 { 0.73f
, 0.0f
, 0.73f
}, // purple
46 { 0.2f
, 0.2f
, 0.8f
}, // blue
47 { 0.0f
, 0.6f
, 0.05f
}, // green
48 { 0.85f
, 0.85f
, 0.0f
}, // yellow
49 { 1.0f
, 0.4f
, 0.0f
} }; // orange
51 GLfloat sign_colors
[8][4]
52 = { { 1.0f
, 1.0f
, 1.0f
, 0.0f
}, // normal
53 { 0.2f
, 0.2f
, 0.2f
, 0.0f
}, // black
54 { 1.0f
, 1.0f
, 1.0f
, 0.0f
}, // white
55 { 0.933f
, 0.75f
, 0.933f
, 0.0f
}, // purple
56 { 0.8f
, 0.8f
, 0.95f
, 0.0f
}, // blue
57 { 0.75f
, 0.9f
, 0.75f
, 0.0f
}, // green
58 { 0.963f
, 0.963f
, 0.75f
, 0.0f
}, // yellow
59 { 1.0f
, 0.85f
, 0.75f
, 0.0f
} }; // orange
61 // note that mote_light_colors[0] is hard coded into LightManager.h
62 const GLfloat
Displayer::mote_light_colors
[7][3]
63 = { { 1.0f
, 1.0f
, 1.0f
}, // normal
64 { -1.0f
, -1.0f
, -1.0f
}, // black
65 { 0.8f
, 0.0f
, 0.8f
}, // purple
66 { 0.0f
, 0.0f
, 1.0f
}, // blue
67 { 0.0f
, 1.0f
, 0.0f
}, // green
68 { 0.8f
, 0.8f
, 0.0f
}, // yellow
69 { 1.0f
, 0.7f
, 0.0f
} }; // orange
71 inline void Displayer::drawSign ( Sign
&sign
, int texture
)
75 glTranslatef(sign
.x
, sign
.y
, DC_PLAY_OFFSET_Z
);
78 if (sign
.life_time
< DC_SIGN_HOLD_TIME
) {
79 sign_colors
[sign
.color
][3] = DC_SIGN_ALPHA
;
81 // then fade, grow, and float
83 GLfloat fade
= (DC_SIGN_LIFE_TIME
- sign
.life_time
)
84 * (1.0f
/ (GLfloat
) DC_SIGN_FADE_TIME
);
85 sign_colors
[sign
.color
][3] = DC_SIGN_ALPHA
* fade
* fade
;
88 + (DC_FINAL_INFLATE_SIZE
- 1.0f
) * (1.0f
- fade
) * (1.0f
- fade
);
89 glScalef(size
, size
, 1.0f
);
92 glColor4fv(sign_colors
[sign
.color
]);
94 glMatrixMode(GL_TEXTURE
);
97 glTranslatef(sign
.subtexture_t
, sign
.subtexture_s
, 0.0f
);
99 if (texture
== ST_SMALL_TEXTURE
)
100 glCallList(sign_small_list
);
102 glCallList(sign_large_list
);
105 glMatrixMode(GL_MODELVIEW
);
110 void Displayer::drawCandy ( )
112 glBindTexture(GL_TEXTURE_2D
, spark_texture
);
114 int c
= SparkleManager::spark_count
;
115 for (int n
= 0; c
; n
++)
116 if (SparkleManager::sparks
[n
].active
) {
117 Spark
&spark
= SparkleManager::sparks
[n
];
122 if (spark
.life_time
< DC_SPARK_FADE_TIME
)
123 glColor4f(block_colors
[spark
.color
][0],
124 block_colors
[spark
.color
][1], block_colors
[spark
.color
][2],
125 spark
.life_time
* (1.0f
/ (GLfloat
) DC_SPARK_FADE_TIME
));
127 else if (spark
.life_time
< DC_SPARK_FADE_TIME
128 + DC_SPARK_PULSE_TIME
) {
129 GLfloat pulse
= (spark
.life_time
- DC_SPARK_FADE_TIME
)
130 * (2.0f
/ (GLfloat
) DC_SPARK_PULSE_TIME
);
131 if (pulse
> 1.0f
) pulse
= 2.0f
- pulse
;
133 glColor3f(pulse
+ (1.0f
- pulse
) * block_colors
[spark
.color
][0],
134 pulse
+ (1.0f
- pulse
) * block_colors
[spark
.color
][1],
135 pulse
+ (1.0f
- pulse
) * block_colors
[spark
.color
][2]);
138 glColor3fv(block_colors
[spark
.color
]);
140 glTranslatef(spark
.x
, spark
.y
, DC_PLAY_OFFSET_Z
);
141 glRotatef(spark
.a
, 0.0f
, 0.0f
, 1.0f
);
142 if (spark
.size
!= 1.0f
)
143 glScalef(spark
.size
, spark
.size
, 1.0f
);
145 glCallList(sparkle_list
);
150 c
= SparkleManager::mote_count
;
151 GLuint last_type
= MT_FOUR_POINTED_STAR
;
152 for (int n
= 0; c
; n
++)
153 if (SparkleManager::motes
[n
].active
) {
154 Mote
&mote
= SparkleManager::motes
[n
];
159 if (mote_textures
[mote
.type
] != last_type
) {
160 glBindTexture(GL_TEXTURE_2D
, mote_textures
[mote
.type
]);
161 last_type
= mote_textures
[mote
.type
];
164 // if an abnormal color
165 if (mote
.color
> 0 && mote
.color
< DC_FIRST_SPECIAL_MOTE_COLOR
)
167 // fade in as color 0
168 if (mote
.life_time
>= 0 && mote
.life_time
< GC_DYING_DELAY
)
169 glColor4f(mote_colors
[0][0],
170 mote_colors
[0][1], mote_colors
[0][2],
171 mote
.life_time
* (1.0f
/ (GLfloat
) GC_DYING_DELAY
));
173 // later fade to our color
174 else if (mote
.life_time
> -DC_MOTE_COLOR_FADE_TIME
) {
176 = -mote
.life_time
* (1.0f
/ (GLfloat
) DC_MOTE_COLOR_FADE_TIME
);
177 glColor3f((1.0f
- fade
) * mote_colors
[0][0]
178 + fade
* mote_colors
[mote
.color
][0],
179 (1.0f
- fade
) * mote_colors
[0][1]
180 + fade
* mote_colors
[mote
.color
][1],
181 (1.0f
- fade
) * mote_colors
[0][2]
182 + fade
* mote_colors
[mote
.color
][2]);
186 glColor3fv(mote_colors
[mote
.color
]);
188 // if normal color and new, fade in
189 else if (mote
.life_time
>= 0 && mote
.life_time
< GC_DYING_DELAY
)
190 glColor4f(mote_colors
[mote
.color
][0],
191 mote_colors
[mote
.color
][1], mote_colors
[mote
.color
][2],
192 mote
.life_time
* (1.0f
/ (GLfloat
) GC_DYING_DELAY
));
194 // otherwise, nothing special
196 glColor3fv(mote_colors
[mote
.color
]);
198 glTranslatef(mote
.x
, mote
.y
, DC_PLAY_OFFSET_Z
);
199 glRotatef(mote
.a
, 0.0f
, 0.0f
, 1.0f
);
200 glScalef(mote
.size
, mote
.size
, 1.0f
);
202 glCallList(sparkle_list
);
207 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_MODULATE
);
209 glBindTexture(GL_TEXTURE_2D
, sign_large_texture
);
211 c
= SignManager::sign_count
;
212 for (int n
= 0; c
; n
++)
213 if (SignManager::signs
[n
].active
) {
214 Sign
&sign
= SignManager::signs
[n
];
217 if (sign
.texture
== ST_SMALL_TEXTURE
) continue;
219 drawSign(sign
, ST_LARGE_TEXTURE
);
222 glBindTexture(GL_TEXTURE_2D
, sign_small_texture
);
224 c
= SignManager::sign_count
;
225 for (int n
= 0; c
; n
++)
226 if (SignManager::signs
[n
].active
) {
227 Sign
&sign
= SignManager::signs
[n
];
230 if (sign
.texture
== ST_LARGE_TEXTURE
) continue;
232 drawSign(sign
, ST_SMALL_TEXTURE
);