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!
38 #include "Displayer.h"
39 #include "SparkleManager.h"
40 #include "SignManager.h"
42 const GLfloat mote_colors
[12][3]
43 = { { 1.0f
, 0.0f
, 0.0f
}, // normal
44 { 0.9f
, 0.4f
, 0.0f
}, // yellow flare
45 { 0.8f
, 0.8f
, 0.0f
}, // orange flare
46 { 0.3f
, 0.3f
, 1.0f
}, // blue flare
47 { 0.4f
, 0.4f
, 0.4f
}, // gray
48 { 0.0f
, 0.0f
, 0.0f
}, // black
49 { 0.9f
, 0.9f
, 0.9f
}, // white
50 { 0.73f
, 0.0f
, 0.73f
}, // purple
51 { 0.2f
, 0.2f
, 0.8f
}, // blue
52 { 0.0f
, 0.6f
, 0.05f
}, // green
53 { 0.85f
, 0.85f
, 0.0f
}, // yellow
54 { 1.0f
, 0.4f
, 0.0f
} }; // orange
56 GLfloat sign_colors
[8][4]
57 = { { 1.0f
, 1.0f
, 1.0f
, 0.0f
}, // normal
58 { 0.2f
, 0.2f
, 0.2f
, 0.0f
}, // black
59 { 1.0f
, 1.0f
, 1.0f
, 0.0f
}, // white
60 { 0.933f
, 0.75f
, 0.933f
, 0.0f
}, // purple
61 { 0.8f
, 0.8f
, 0.95f
, 0.0f
}, // blue
62 { 0.75f
, 0.9f
, 0.75f
, 0.0f
}, // green
63 { 0.963f
, 0.963f
, 0.75f
, 0.0f
}, // yellow
64 { 1.0f
, 0.85f
, 0.75f
, 0.0f
} }; // orange
66 // note that mote_light_colors[0] is hard coded into LightManager.h
67 const GLfloat
Displayer::mote_light_colors
[7][3]
68 = { { 1.0f
, 1.0f
, 1.0f
}, // normal
69 { -1.0f
, -1.0f
, -1.0f
}, // black
70 { 0.8f
, 0.0f
, 0.8f
}, // purple
71 { 0.0f
, 0.0f
, 1.0f
}, // blue
72 { 0.0f
, 1.0f
, 0.0f
}, // green
73 { 0.8f
, 0.8f
, 0.0f
}, // yellow
74 { 1.0f
, 0.7f
, 0.0f
} }; // orange
76 inline void Displayer::drawSign ( Sign
&sign
, int texture
)
80 glTranslatef(sign
.x
, sign
.y
, DC_PLAY_OFFSET_Z
);
83 if (sign
.life_time
< DC_SIGN_HOLD_TIME
) {
84 sign_colors
[sign
.color
][3] = DC_SIGN_ALPHA
;
86 // then fade, grow, and float
88 GLfloat fade
= (DC_SIGN_LIFE_TIME
- sign
.life_time
)
89 * (1.0f
/ (GLfloat
) DC_SIGN_FADE_TIME
);
90 sign_colors
[sign
.color
][3] = DC_SIGN_ALPHA
* fade
* fade
;
93 + (DC_FINAL_INFLATE_SIZE
- 1.0f
) * (1.0f
- fade
) * (1.0f
- fade
);
94 glScalef(size
, size
, 1.0f
);
97 glColor4fv(sign_colors
[sign
.color
]);
99 glMatrixMode(GL_TEXTURE
);
102 glTranslatef(sign
.subtexture_t
, sign
.subtexture_s
, 0.0f
);
104 if (texture
== ST_SMALL_TEXTURE
)
105 glCallList(sign_small_list
);
107 glCallList(sign_large_list
);
110 glMatrixMode(GL_MODELVIEW
);
115 void Displayer::drawCandy ( )
117 glBindTexture(GL_TEXTURE_2D
, spark_texture
);
119 int c
= SparkleManager::spark_count
;
120 for (int n
= 0; c
; n
++)
121 if (SparkleManager::sparks
[n
].active
) {
122 Spark
&spark
= SparkleManager::sparks
[n
];
127 if (spark
.life_time
< DC_SPARK_FADE_TIME
)
128 glColor4f(block_colors
[spark
.color
][0],
129 block_colors
[spark
.color
][1], block_colors
[spark
.color
][2],
130 spark
.life_time
* (1.0f
/ (GLfloat
) DC_SPARK_FADE_TIME
));
132 else if (spark
.life_time
< DC_SPARK_FADE_TIME
133 + DC_SPARK_PULSE_TIME
) {
134 GLfloat pulse
= (spark
.life_time
- DC_SPARK_FADE_TIME
)
135 * (2.0f
/ (GLfloat
) DC_SPARK_PULSE_TIME
);
136 if (pulse
> 1.0f
) pulse
= 2.0f
- pulse
;
138 glColor3f(pulse
+ (1.0f
- pulse
) * block_colors
[spark
.color
][0],
139 pulse
+ (1.0f
- pulse
) * block_colors
[spark
.color
][1],
140 pulse
+ (1.0f
- pulse
) * block_colors
[spark
.color
][2]);
143 glColor3fv(block_colors
[spark
.color
]);
145 glTranslatef(spark
.x
, spark
.y
, DC_PLAY_OFFSET_Z
);
146 glRotatef(spark
.a
, 0.0f
, 0.0f
, 1.0f
);
147 if (spark
.size
!= 1.0f
)
148 glScalef(spark
.size
, spark
.size
, 1.0f
);
150 glCallList(sparkle_list
);
155 c
= SparkleManager::mote_count
;
156 GLuint last_type
= MT_FOUR_POINTED_STAR
;
157 for (int n
= 0; c
; n
++)
158 if (SparkleManager::motes
[n
].active
) {
159 Mote
&mote
= SparkleManager::motes
[n
];
164 if (mote_textures
[mote
.type
] != last_type
) {
165 glBindTexture(GL_TEXTURE_2D
, mote_textures
[mote
.type
]);
166 last_type
= mote_textures
[mote
.type
];
169 // if an abnormal color
170 if (mote
.color
> 0 && mote
.color
< DC_FIRST_SPECIAL_MOTE_COLOR
)
172 // fade in as color 0
173 if (mote
.life_time
>= 0 && mote
.life_time
< GC_DYING_DELAY
)
174 glColor4f(mote_colors
[0][0],
175 mote_colors
[0][1], mote_colors
[0][2],
176 mote
.life_time
* (1.0f
/ (GLfloat
) GC_DYING_DELAY
));
178 // later fade to our color
179 else if (mote
.life_time
> -DC_MOTE_COLOR_FADE_TIME
) {
181 = -mote
.life_time
* (1.0f
/ (GLfloat
) DC_MOTE_COLOR_FADE_TIME
);
182 glColor3f((1.0f
- fade
) * mote_colors
[0][0]
183 + fade
* mote_colors
[mote
.color
][0],
184 (1.0f
- fade
) * mote_colors
[0][1]
185 + fade
* mote_colors
[mote
.color
][1],
186 (1.0f
- fade
) * mote_colors
[0][2]
187 + fade
* mote_colors
[mote
.color
][2]);
191 glColor3fv(mote_colors
[mote
.color
]);
193 // if normal color and new, fade in
194 else if (mote
.life_time
>= 0 && mote
.life_time
< GC_DYING_DELAY
)
195 glColor4f(mote_colors
[mote
.color
][0],
196 mote_colors
[mote
.color
][1], mote_colors
[mote
.color
][2],
197 mote
.life_time
* (1.0f
/ (GLfloat
) GC_DYING_DELAY
));
199 // otherwise, nothing special
201 glColor3fv(mote_colors
[mote
.color
]);
203 glTranslatef(mote
.x
, mote
.y
, DC_PLAY_OFFSET_Z
);
204 glRotatef(mote
.a
, 0.0f
, 0.0f
, 1.0f
);
205 glScalef(mote
.size
, mote
.size
, 1.0f
);
207 glCallList(sparkle_list
);
212 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_MODULATE
);
214 glBindTexture(GL_TEXTURE_2D
, sign_large_texture
);
216 c
= SignManager::sign_count
;
217 for (int n
= 0; c
; n
++)
218 if (SignManager::signs
[n
].active
) {
219 Sign
&sign
= SignManager::signs
[n
];
222 if (sign
.texture
== ST_SMALL_TEXTURE
) continue;
224 drawSign(sign
, ST_LARGE_TEXTURE
);
227 glBindTexture(GL_TEXTURE_2D
, sign_small_texture
);
229 c
= SignManager::sign_count
;
230 for (int n
= 0; c
; n
++)
231 if (SignManager::signs
[n
].active
) {
232 Sign
&sign
= SignManager::signs
[n
];
235 if (sign
.texture
== ST_LARGE_TEXTURE
) continue;
237 drawSign(sign
, ST_SMALL_TEXTURE
);