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!
35 #include "Displayer.h"
36 #include "SparkleManager.h"
37 #include "SignManager.h"
39 const GLfloat mote_colors
[12][3]
40 = { { 1.0f
, 0.0f
, 0.0f
}, // normal
41 { 0.9f
, 0.4f
, 0.0f
}, // yellow flare
42 { 0.8f
, 0.8f
, 0.0f
}, // orange flare
43 { 0.3f
, 0.3f
, 1.0f
}, // blue flare
44 { 0.4f
, 0.4f
, 0.4f
}, // gray
45 { 0.0f
, 0.0f
, 0.0f
}, // black
46 { 0.9f
, 0.9f
, 0.9f
}, // white
47 { 0.73f
, 0.0f
, 0.73f
}, // purple
48 { 0.2f
, 0.2f
, 0.8f
}, // blue
49 { 0.0f
, 0.6f
, 0.05f
}, // green
50 { 0.85f
, 0.85f
, 0.0f
}, // yellow
51 { 1.0f
, 0.4f
, 0.0f
} }; // orange
53 GLfloat sign_colors
[8][4]
54 = { { 1.0f
, 1.0f
, 1.0f
, 0.0f
}, // normal
55 { 0.2f
, 0.2f
, 0.2f
, 0.0f
}, // black
56 { 1.0f
, 1.0f
, 1.0f
, 0.0f
}, // white
57 { 0.933f
, 0.75f
, 0.933f
, 0.0f
}, // purple
58 { 0.8f
, 0.8f
, 0.95f
, 0.0f
}, // blue
59 { 0.75f
, 0.9f
, 0.75f
, 0.0f
}, // green
60 { 0.963f
, 0.963f
, 0.75f
, 0.0f
}, // yellow
61 { 1.0f
, 0.85f
, 0.75f
, 0.0f
} }; // orange
63 // note that mote_light_colors[0] is hard coded into LightManager.h
64 const GLfloat
Displayer::mote_light_colors
[7][3]
65 = { { 1.0f
, 1.0f
, 1.0f
}, // normal
66 { -1.0f
, -1.0f
, -1.0f
}, // black
67 { 0.8f
, 0.0f
, 0.8f
}, // purple
68 { 0.0f
, 0.0f
, 1.0f
}, // blue
69 { 0.0f
, 1.0f
, 0.0f
}, // green
70 { 0.8f
, 0.8f
, 0.0f
}, // yellow
71 { 1.0f
, 0.7f
, 0.0f
} }; // orange
73 inline void Displayer::drawSign ( Sign
&sign
, int texture
)
77 glTranslatef(sign
.x
, sign
.y
, DC_PLAY_OFFSET_Z
);
80 if (sign
.life_time
< DC_SIGN_HOLD_TIME
) {
81 sign_colors
[sign
.color
][3] = DC_SIGN_ALPHA
;
83 // then fade, grow, and float
85 GLfloat fade
= (DC_SIGN_LIFE_TIME
- sign
.life_time
)
86 * (1.0f
/ (GLfloat
) DC_SIGN_FADE_TIME
);
87 sign_colors
[sign
.color
][3] = DC_SIGN_ALPHA
* fade
* fade
;
90 + (DC_FINAL_INFLATE_SIZE
- 1.0f
) * (1.0f
- fade
) * (1.0f
- fade
);
91 glScalef(size
, size
, 1.0f
);
94 glColor4fv(sign_colors
[sign
.color
]);
96 glMatrixMode(GL_TEXTURE
);
99 glTranslatef(sign
.subtexture_t
, sign
.subtexture_s
, 0.0f
);
101 if (texture
== ST_SMALL_TEXTURE
)
102 glCallList(sign_small_list
);
104 glCallList(sign_large_list
);
107 glMatrixMode(GL_MODELVIEW
);
112 void Displayer::drawCandy ( )
114 glBindTexture(GL_TEXTURE_2D
, spark_texture
);
116 int c
= SparkleManager::spark_count
;
117 for (int n
= 0; c
; n
++)
118 if (SparkleManager::sparks
[n
].active
) {
119 Spark
&spark
= SparkleManager::sparks
[n
];
124 if (spark
.life_time
< DC_SPARK_FADE_TIME
)
125 glColor4f(block_colors
[spark
.color
][0],
126 block_colors
[spark
.color
][1], block_colors
[spark
.color
][2],
127 spark
.life_time
* (1.0f
/ (GLfloat
) DC_SPARK_FADE_TIME
));
129 else if (spark
.life_time
< DC_SPARK_FADE_TIME
130 + DC_SPARK_PULSE_TIME
) {
131 GLfloat pulse
= (spark
.life_time
- DC_SPARK_FADE_TIME
)
132 * (2.0f
/ (GLfloat
) DC_SPARK_PULSE_TIME
);
133 if (pulse
> 1.0f
) pulse
= 2.0f
- pulse
;
135 glColor3f(pulse
+ (1.0f
- pulse
) * block_colors
[spark
.color
][0],
136 pulse
+ (1.0f
- pulse
) * block_colors
[spark
.color
][1],
137 pulse
+ (1.0f
- pulse
) * block_colors
[spark
.color
][2]);
140 glColor3fv(block_colors
[spark
.color
]);
142 glTranslatef(spark
.x
, spark
.y
, DC_PLAY_OFFSET_Z
);
143 glRotatef(spark
.a
, 0.0f
, 0.0f
, 1.0f
);
144 if (spark
.size
!= 1.0f
)
145 glScalef(spark
.size
, spark
.size
, 1.0f
);
147 glCallList(sparkle_list
);
152 c
= SparkleManager::mote_count
;
153 GLuint last_type
= MT_FOUR_POINTED_STAR
;
154 for (int n
= 0; c
; n
++)
155 if (SparkleManager::motes
[n
].active
) {
156 Mote
&mote
= SparkleManager::motes
[n
];
161 if (mote_textures
[mote
.type
] != last_type
) {
162 glBindTexture(GL_TEXTURE_2D
, mote_textures
[mote
.type
]);
163 last_type
= mote_textures
[mote
.type
];
166 // if an abnormal color
167 if (mote
.color
> 0 && mote
.color
< DC_FIRST_SPECIAL_MOTE_COLOR
)
169 // fade in as color 0
170 if (mote
.life_time
>= 0 && mote
.life_time
< GC_DYING_DELAY
)
171 glColor4f(mote_colors
[0][0],
172 mote_colors
[0][1], mote_colors
[0][2],
173 mote
.life_time
* (1.0f
/ (GLfloat
) GC_DYING_DELAY
));
175 // later fade to our color
176 else if (mote
.life_time
> -DC_MOTE_COLOR_FADE_TIME
) {
178 = -mote
.life_time
* (1.0f
/ (GLfloat
) DC_MOTE_COLOR_FADE_TIME
);
179 glColor3f((1.0f
- fade
) * mote_colors
[0][0]
180 + fade
* mote_colors
[mote
.color
][0],
181 (1.0f
- fade
) * mote_colors
[0][1]
182 + fade
* mote_colors
[mote
.color
][1],
183 (1.0f
- fade
) * mote_colors
[0][2]
184 + fade
* mote_colors
[mote
.color
][2]);
188 glColor3fv(mote_colors
[mote
.color
]);
190 // if normal color and new, fade in
191 else if (mote
.life_time
>= 0 && mote
.life_time
< GC_DYING_DELAY
)
192 glColor4f(mote_colors
[mote
.color
][0],
193 mote_colors
[mote
.color
][1], mote_colors
[mote
.color
][2],
194 mote
.life_time
* (1.0f
/ (GLfloat
) GC_DYING_DELAY
));
196 // otherwise, nothing special
198 glColor3fv(mote_colors
[mote
.color
]);
200 glTranslatef(mote
.x
, mote
.y
, DC_PLAY_OFFSET_Z
);
201 glRotatef(mote
.a
, 0.0f
, 0.0f
, 1.0f
);
202 glScalef(mote
.size
, mote
.size
, 1.0f
);
204 glCallList(sparkle_list
);
209 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_MODULATE
);
211 glBindTexture(GL_TEXTURE_2D
, sign_large_texture
);
213 c
= SignManager::sign_count
;
214 for (int n
= 0; c
; n
++)
215 if (SignManager::signs
[n
].active
) {
216 Sign
&sign
= SignManager::signs
[n
];
219 if (sign
.texture
== ST_SMALL_TEXTURE
) continue;
221 drawSign(sign
, ST_LARGE_TEXTURE
);
224 glBindTexture(GL_TEXTURE_2D
, sign_small_texture
);
226 c
= SignManager::sign_count
;
227 for (int n
= 0; c
; n
++)
228 if (SignManager::signs
[n
].active
) {
229 Sign
&sign
= SignManager::signs
[n
];
232 if (sign
.texture
== ST_LARGE_TEXTURE
) continue;
234 drawSign(sign
, ST_SMALL_TEXTURE
);