From db2cdf2edc9ed070685e8eda18e5e6db1fb4e8b2 Mon Sep 17 00:00:00 2001 From: parasti Date: Wed, 25 May 2011 16:46:27 +0000 Subject: [PATCH] Fix shadow in Neverputt git-svn-id: https://s.snth.net/svn/neverball/branches/gles@3581 78b8d119-cf0a-0410-b17c-f493084dd1d7 --- ball/game_draw.c | 8 +++++--- ball/game_draw.h | 2 +- putt/game.c | 4 +++- share/solid_draw.c | 14 +++++++------- share/solid_draw.h | 1 + 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ball/game_draw.c b/ball/game_draw.c index da0e2e7..23f63da 100644 --- a/ball/game_draw.c +++ b/ball/game_draw.c @@ -320,13 +320,13 @@ static void game_clip_ball(const struct game_draw *gd, int d, const float *p) } static void game_draw_fore(struct s_rend *rend, - const struct game_draw *gd, + struct game_draw *gd, int pose, const float *M, int d, float t) { const float *ball_p = gd->vary.uv[0].p; - const struct s_draw *draw = &gd->draw; + struct s_draw *draw = &gd->draw; glPushMatrix(); { @@ -395,7 +395,7 @@ static void game_draw_fore(struct s_rend *rend, /*---------------------------------------------------------------------------*/ -void game_draw(const struct game_draw *gd, int pose, float t) +void game_draw(struct game_draw *gd, int pose, float t) { float fov = (float) config_get_d(CONFIG_VIEW_FOV); @@ -406,6 +406,8 @@ void game_draw(const struct game_draw *gd, int pose, float t) const struct game_view *view = &gd->view; struct s_rend rend; + gd->draw.shadow = 0; + sol_draw_enable(&rend); video_push_persp(fov, 0.1f, FAR_DIST); diff --git a/ball/game_draw.h b/ball/game_draw.h index f2d1744..2559590 100644 --- a/ball/game_draw.h +++ b/ball/game_draw.h @@ -32,7 +32,7 @@ struct game_draw /* FIXME: this is just for POSE_* constants. */ #include "game_client.h" -void game_draw(const struct game_draw *, int, float); +void game_draw(struct game_draw *, int, float); /*---------------------------------------------------------------------------*/ diff --git a/putt/game.c b/putt/game.c index 4092376..e8f71d4 100644 --- a/putt/game.c +++ b/putt/game.c @@ -275,11 +275,13 @@ void game_draw(int pose, float t) { const float light_p[4] = { 8.f, 32.f, 8.f, 0.f }; - const struct s_draw *fp = &file.draw; + struct s_draw *fp = &file.draw; struct s_rend rend = { NULL }; float fov = FOV; + fp->shadow = ball; + sol_draw_enable(&rend); if (jump_b) fov *= 2.0f * fabsf(jump_dt - 0.5f); diff --git a/share/solid_draw.c b/share/solid_draw.c index bc36334..38af14d 100644 --- a/share/solid_draw.c +++ b/share/solid_draw.c @@ -56,7 +56,7 @@ static const int pass_in[] = { /*---------------------------------------------------------------------------*/ static void sol_transform(const struct s_vary *vary, - const struct v_body *bp) + const struct v_body *bp, int ui) { float a; float e[4]; @@ -75,12 +75,14 @@ static void sol_transform(const struct s_vary *vary, /* Apply the shadow transform to the texture matrix. */ - if (vary->uc && vary->uv->r > 0.0) + if (ui >= 0 && ui < vary->uc && vary->uv[ui].r > 0.0f) { + struct v_ball *up = vary->uv + ui; + glActiveTexture_(GL_TEXTURE1); glMatrixMode(GL_TEXTURE); { - float k = 0.25f / vary->uv->r; + float k = 0.25f / up->r; glLoadIdentity(); @@ -98,9 +100,7 @@ static void sol_transform(const struct s_vary *vary, /* Move the shadow texture under the ball. */ - glTranslatef(-vary->uv->p[0], - -vary->uv->p[1], - -vary->uv->p[2]); + glTranslatef(-up->p[0], -up->p[1], -up->p[2]); /* Apply the body position and rotation. */ @@ -741,7 +741,7 @@ static void sol_draw_all(const struct s_draw *draw, struct s_rend *rend, int p) { glPushMatrix(); { - sol_transform(draw->vary, draw->vary->bv + bi); + sol_transform(draw->vary, draw->vary->bv + bi, draw->shadow); sol_draw_body(draw->bv + bi, rend, p); } glPopMatrix(); diff --git a/share/solid_draw.h b/share/solid_draw.h index c7833fa..ecc62b8 100644 --- a/share/solid_draw.h +++ b/share/solid_draw.h @@ -86,6 +86,7 @@ struct s_draw GLuint bill; int reflective; + int shadow; }; /*---------------------------------------------------------------------------*/ -- 1.7.9.5