aboutsummaryrefslogtreecommitdiff
path: root/src/render.c
diff options
context:
space:
mode:
authorweiss <weiss@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-19 14:16:43 +0000
committerweiss <weiss@84d2e878-0bd5-11dd-ad15-13eda11d74c5>2008-07-19 14:16:43 +0000
commitd55a4543b406c29e0a18cfd15082a3ddc06bf77c (patch)
tree17fbc1fc398b49a63076665b950b0823daf67f32 /src/render.c
parent23705de21cacd60e0dabe53a73454bcd28f8afad (diff)
Make the recharge ripple fade nicely
git-svn-id: svn://cook.msm.cam.ac.uk:745/thrust3d/thrust3d@144 84d2e878-0bd5-11dd-ad15-13eda11d74c5
Diffstat (limited to 'src/render.c')
-rw-r--r--src/render.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/render.c b/src/render.c
index 044dd42..e18b3a6 100644
--- a/src/render.c
+++ b/src/render.c
@@ -643,11 +643,28 @@ void render_draw(Game *game, Uint32 t) {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, r->swirly_fbo);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, 64, 64);
- if ( r->shaders ) glUseProgram(r->swirly_program);
- if ( r->shaders ) glUniform1f(glGetUniformLocation(game->render->swirly_program, "time"), t);
- if ( r->shaders ) glUniform1i(glGetUniformLocation(game->render->swirly_program, "landed"), game->lander->recharging);
- if ( r->shaders ) glUniform1i(glGetUniformLocation(game->render->swirly_program, "rechargeripple"), game->lander->recharging);
- if ( r->shaders ) glUniform2f(glGetUniformLocation(game->render->swirly_program, "lander"), game->platform_rel_x, game->platform_rel_y);
+ if ( r->shaders ) {
+
+ GLfloat rrb = 0.0;
+
+ glUseProgram(r->swirly_program);
+ glUniform1f(glGetUniformLocation(game->render->swirly_program, "time"), t);
+ glUniform1i(glGetUniformLocation(game->render->swirly_program, "landed"), game->lander->recharging);
+ if ( game->lander->recharging ) {
+ /* Fade in */
+ rrb = fminf(((GLfloat)t-game->time_of_landing_event)/1500.0, 1.0);
+ glUniform1i(glGetUniformLocation(game->render->swirly_program, "rechargeripple"), 1);
+ } else if ( game->time_of_landing_event - t < 750 ) {
+ /* Fade out */
+ rrb = fmaxf(1.0 - ((GLfloat)t-game->time_of_landing_event)/750.0, 0.0);
+ glUniform1i(glGetUniformLocation(game->render->swirly_program, "rechargeripple"), 1);
+ } else {
+ glUniform1i(glGetUniformLocation(game->render->swirly_program, "rechargeripple"), 0);
+ }
+ glUniform1f(glGetUniformLocation(game->render->swirly_program, "rrb"), rrb);
+ glUniform2f(glGetUniformLocation(game->render->swirly_program, "lander"), game->platform_rel_x, game->platform_rel_y);
+
+ } /* else this is all a little pointless... */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);