From: parasti Date: Mon, 18 Apr 2011 01:50:23 +0000 (+0000) Subject: Track material state in a structure X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=3cd3e2a53a5ccdaf73277dad2ed5d63da1d7dc08;p=neverball Track material state in a structure git-svn-id: https://s.snth.net/svn/neverball/branches/gles@3574 78b8d119-cf0a-0410-b17c-f493084dd1d7 --- diff --git a/ball/game_draw.c b/ball/game_draw.c index 0e71446..a9c8fa1 100644 --- a/ball/game_draw.c +++ b/ball/game_draw.c @@ -27,9 +27,9 @@ /*---------------------------------------------------------------------------*/ -static const struct d_mtrl *game_draw_balls(const struct d_mtrl *mq, - const struct s_vary *vary, - const float *bill_M, float t) +static void game_draw_balls(struct s_rend *rend, + const struct s_vary *vary, + const float *bill_M, float t) { float c[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; @@ -49,16 +49,14 @@ static const struct d_mtrl *game_draw_balls(const struct d_mtrl *mq, vary->uv[0].r); glColor4f(c[0], c[1], c[2], c[3]); - mq = ball_draw(mq, ball_M, pend_M, bill_M, t); + ball_draw(rend, ball_M, pend_M, bill_M, t); } glPopMatrix(); - - return mq; } -static const struct d_mtrl *game_draw_items(const struct d_mtrl *mq, - const struct s_vary *vary, - const float *bill_M, float t) +static void game_draw_items(struct s_rend *rend, + const struct s_vary *vary, + const float *bill_M, float t) { int hi; @@ -72,7 +70,7 @@ static const struct d_mtrl *game_draw_items(const struct d_mtrl *mq, glTranslatef(vary->hv[hi].p[0], vary->hv[hi].p[1], vary->hv[hi].p[2]); - mq = item_draw(mq, &vary->hv[hi], bill_M, t); + item_draw(rend, &vary->hv[hi], bill_M, t); } glPopMatrix(); } @@ -85,7 +83,7 @@ static const struct d_mtrl *game_draw_items(const struct d_mtrl *mq, glTranslatef(vary->hv[hi].p[0], vary->hv[hi].p[1], vary->hv[hi].p[2]); - mq = item_draw(mq, &vary->hv[hi], bill_M, t); + item_draw(rend, &vary->hv[hi], bill_M, t); } glPopMatrix(); } @@ -98,7 +96,7 @@ static const struct d_mtrl *game_draw_items(const struct d_mtrl *mq, glTranslatef(vary->hv[hi].p[0], vary->hv[hi].p[1], vary->hv[hi].p[2]); - mq = item_draw(mq, &vary->hv[hi], bill_M, t); + item_draw(rend, &vary->hv[hi], bill_M, t); } glPopMatrix(); } @@ -106,13 +104,11 @@ static const struct d_mtrl *game_draw_items(const struct d_mtrl *mq, glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glDisable(GL_COLOR_MATERIAL); - - return mq; } -static const struct d_mtrl *game_draw_goals(const struct d_mtrl *mq, - const struct game_draw *gd, - const float *M, float t) +static void game_draw_goals(struct s_rend *rend, + const struct game_draw *gd, + const float *M, float t) { const struct s_base *base = gd->vary.base; @@ -134,17 +130,16 @@ static const struct d_mtrl *game_draw_goals(const struct d_mtrl *mq, gd->goal_k, base->zv[zi].r); - mq = goal_draw(mq, t); + goal_draw(rend, t); } glPopMatrix(); } } - return mq; } -static const struct d_mtrl *game_draw_jumps(const struct d_mtrl *mq, - const struct game_draw *gd, - const float *M, float t) +static void game_draw_jumps(struct s_rend *rend, + const struct game_draw *gd, + const float *M, float t) { const struct s_base *base = gd->vary.base; @@ -161,15 +156,13 @@ static const struct d_mtrl *game_draw_jumps(const struct d_mtrl *mq, 1.0f, base->jv[ji].r); - mq = jump_draw(mq, t, !gd->jump_e); + jump_draw(rend, t, !gd->jump_e); } glPopMatrix(); } - return mq; } -static const struct d_mtrl *game_draw_swchs(const struct d_mtrl *mq, - const struct s_vary *vary) +static void game_draw_swchs(struct s_rend *rend, const struct s_vary *vary) { int xi; @@ -189,11 +182,10 @@ static const struct d_mtrl *game_draw_swchs(const struct d_mtrl *mq, 1.0f, xp->base->r); - mq = swch_draw(mq, xp->f, xp->e); + swch_draw(rend, xp->f, xp->e); } glPopMatrix(); } - return mq; } /*---------------------------------------------------------------------------*/ @@ -211,8 +203,7 @@ static void game_draw_tilt(const struct game_draw *gd, int d) glTranslatef(-ball_p[0], -ball_p[1] * d, -ball_p[2]); } -static const struct d_mtrl *game_refl_all(const struct d_mtrl *mq, - const struct game_draw *gd) +static void game_refl_all(struct s_rend *rend, const struct game_draw *gd) { glPushMatrix(); { @@ -220,11 +211,9 @@ static const struct d_mtrl *game_refl_all(const struct d_mtrl *mq, /* Draw the floor. */ - mq = sol_refl(&gd->draw, mq); + sol_refl(&gd->draw, rend); } glPopMatrix(); - - return mq; } /*---------------------------------------------------------------------------*/ @@ -253,12 +242,12 @@ static void game_draw_light(void) glLightfv(GL_LIGHT1, GL_SPECULAR, light_c[1]); } -static const struct d_mtrl *game_draw_back(const struct d_mtrl *mq, - const struct game_draw *gd, - int pose, int d, float t) +static void game_draw_back(struct s_rend *rend, + const struct game_draw *gd, + int pose, int d, float t) { if (pose == POSE_BALL) - return mq; + return; glPushMatrix(); { @@ -276,14 +265,12 @@ static const struct d_mtrl *game_draw_back(const struct d_mtrl *mq, if (config_get_d(CONFIG_BACKGROUND)) { - mq = back_draw(mq, 0); - mq = sol_back(&gd->back.draw, mq, 0, FAR_DIST, t); + back_draw(rend, 0); + sol_back(&gd->back.draw, rend, 0, FAR_DIST, t); } - else back_draw(mq, 0); + else back_draw(rend, 0); } glPopMatrix(); - - return mq; } static void game_clip_refl(int d) @@ -332,10 +319,10 @@ static void game_clip_ball(const struct game_draw *gd, int d, const float *p) glClipPlane4f(GL_CLIP_PLANE2, pz[0], pz[1], pz[2], pz[3]); } -static const struct d_mtrl *game_draw_fore(const struct d_mtrl *mq, - const struct game_draw *gd, - int pose, const float *M, - int d, float t) +static void game_draw_fore(struct s_rend *rend, + const struct game_draw *gd, + int pose, const float *M, + int d, float t) { const float *ball_p = gd->vary.uv[0].p; @@ -358,17 +345,17 @@ static const struct d_mtrl *game_draw_fore(const struct d_mtrl *mq, switch (pose) { case POSE_LEVEL: - mq = sol_draw(draw, mq, 0, 1); + sol_draw(draw, rend, 0, 1); break; case POSE_NONE: /* Draw the floor. */ - mq = sol_draw(draw, mq, 0, 1); + sol_draw(draw, rend, 0, 1); /* Draw the coins. */ - mq = game_draw_items(mq, draw->vary, M, t); + game_draw_items(rend, draw->vary, M, t); /* Fall through. */ @@ -376,7 +363,7 @@ static const struct d_mtrl *game_draw_fore(const struct d_mtrl *mq, /* Draw the ball. */ - mq = game_draw_balls(mq, draw->vary, M, t); + game_draw_balls(rend, draw->vary, M, t); break; } @@ -387,13 +374,13 @@ static const struct d_mtrl *game_draw_fore(const struct d_mtrl *mq, glDisable(GL_LIGHTING); glDepthMask(GL_FALSE); { - mq = sol_bill(draw, mq, M, t); + sol_bill(draw, rend, M, t); - mq = game_draw_goals(mq, gd, M, t); - mq = game_draw_jumps(mq, gd, M, t); - mq = game_draw_swchs(mq, draw->vary); + game_draw_goals(rend, gd, M, t); + game_draw_jumps(rend, gd, M, t); + game_draw_swchs(rend, draw->vary); - mq = part_draw_coin(mq); + part_draw_coin(rend); } glDepthMask(GL_TRUE); glEnable(GL_LIGHTING); @@ -403,8 +390,6 @@ static const struct d_mtrl *game_draw_fore(const struct d_mtrl *mq, glDisable(GL_CLIP_PLANE0); } glPopMatrix(); - - return mq; } /*---------------------------------------------------------------------------*/ @@ -418,7 +403,9 @@ void game_draw(const struct game_draw *gd, int pose, float t) if (gd->state) { const struct game_view *view = &gd->view; - const struct d_mtrl *mq = sol_draw_enable(); + struct s_rend rend; + + sol_draw_enable(&rend); video_push_persp(fov, 0.1f, FAR_DIST); glPushMatrix(); @@ -446,7 +433,7 @@ void game_draw(const struct game_draw *gd, int pose, float t) /* Draw the background. */ - mq = game_draw_back(mq, gd, pose, +1, t); + game_draw_back(&rend, gd, pose, +1, t); /* Draw the reflection. */ @@ -461,7 +448,7 @@ void game_draw(const struct game_draw *gd, int pose, float t) glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDepthMask(GL_FALSE); - mq = game_refl_all(mq, gd); + game_refl_all(&rend, gd); glDepthMask(GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); @@ -469,7 +456,7 @@ void game_draw(const struct game_draw *gd, int pose, float t) glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF); /* Draw the scene reflected into color and depth buffers. */ - + glFrontFace(GL_CW); glPushMatrix(); { @@ -477,8 +464,8 @@ void game_draw(const struct game_draw *gd, int pose, float t) game_draw_light(); - mq = game_draw_back(mq, gd, pose, -1, t); - mq = game_draw_fore(mq, gd, pose, U, -1, t); + game_draw_back(&rend, gd, pose, -1, t); + game_draw_fore(&rend, gd, pose, U, -1, t); } glPopMatrix(); glFrontFace(GL_CCW); @@ -500,7 +487,7 @@ void game_draw(const struct game_draw *gd, int pose, float t) glEnable(GL_COLOR_MATERIAL); { glColor4f(0.0f, 0.0f, 0.0f, 1.0f); - mq = game_refl_all(mq, gd); + game_refl_all(&rend, gd); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } glDisable(GL_COLOR_MATERIAL); @@ -508,8 +495,8 @@ void game_draw(const struct game_draw *gd, int pose, float t) /* Draw the mirrors and the rest of the foreground. */ - mq = game_refl_all (mq, gd); - mq = game_draw_fore(mq, gd, pose, T, +1, t); + game_refl_all (&rend, gd); + game_draw_fore(&rend, gd, pose, T, +1, t); } glPopMatrix(); video_pop_matrix(); @@ -517,7 +504,7 @@ void game_draw(const struct game_draw *gd, int pose, float t) /* Draw the fade overlay. */ sol_fade(&gd->draw, gd->fade_k); - sol_draw_disable(mq); + sol_draw_disable(&rend); } } diff --git a/putt/game.c b/putt/game.c index 84d3792..4092376 100644 --- a/putt/game.c +++ b/putt/game.c @@ -119,8 +119,7 @@ void game_free(void) /*---------------------------------------------------------------------------*/ -static const struct d_mtrl *game_draw_vect(const struct d_mtrl *mq, - const struct s_vary *fp) +static void game_draw_vect(struct s_rend *rend, const struct s_vary *fp) { if (view_m > 0.f) { @@ -134,17 +133,16 @@ static const struct d_mtrl *game_draw_vect(const struct d_mtrl *mq, glScalef(fp->uv[ball].r, fp->uv[ball].r * 0.1f, view_m); - mq = vect_draw(mq); + vect_draw(rend); } glPopMatrix(); glEnable(GL_LIGHTING); } - return mq; } -static const struct d_mtrl *game_draw_balls(const struct d_mtrl *mq, - const struct s_vary *fp, - const float *bill_M, float t) +static void game_draw_balls(struct s_rend *rend, + const struct s_vary *fp, + const float *bill_M, float t) { static const GLfloat color[5][4] = { { 1.0f, 1.0f, 1.0f, 0.7f }, @@ -181,7 +179,7 @@ static const struct d_mtrl *game_draw_balls(const struct d_mtrl *mq, color[ui][1], color[ui][2], color[ui][3]); - mq = ball_draw(mq, ball_M, pend_M, bill_M, t); + ball_draw(rend, ball_M, pend_M, bill_M, t); } glPopMatrix(); } @@ -200,7 +198,7 @@ static const struct d_mtrl *game_draw_balls(const struct d_mtrl *mq, color[ui][1], color[ui][2], 0.5f); - mq = mark_draw(mq); + mark_draw(rend); } glPopMatrix(); } @@ -208,12 +206,9 @@ static const struct d_mtrl *game_draw_balls(const struct d_mtrl *mq, glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glDisable(GL_COLOR_MATERIAL); - - return mq; } -static const struct d_mtrl *game_draw_goals(const struct d_mtrl *mq, - const struct s_base *fp) +static void game_draw_goals(struct s_rend *rend, const struct s_base *fp) { int zi; @@ -224,15 +219,13 @@ static const struct d_mtrl *game_draw_goals(const struct d_mtrl *mq, glTranslatef(fp->zv[zi].p[0], fp->zv[zi].p[1], fp->zv[zi].p[2]); - mq = flag_draw(mq); + flag_draw(rend); } glPopMatrix(); } - return mq; } -static const struct d_mtrl *game_draw_jumps(const struct d_mtrl *mq, - const struct s_base *fp) +static void game_draw_jumps(struct s_rend *rend, const struct s_base *fp) { float t = 0.001f * SDL_GetTicks(); int ji; @@ -246,15 +239,13 @@ static const struct d_mtrl *game_draw_jumps(const struct d_mtrl *mq, fp->jv[ji].p[2]); glScalef(fp->jv[ji].r, 1.f, fp->jv[ji].r); - mq = jump_draw(mq, t, !jump_e); + jump_draw(rend, t, !jump_e); } glPopMatrix(); } - return mq; } -static const struct d_mtrl *game_draw_swchs(const struct d_mtrl *mq, - const struct s_vary *fp) +static void game_draw_swchs(struct s_rend *rend, const struct s_vary *fp) { int xi; @@ -272,11 +263,10 @@ static const struct d_mtrl *game_draw_swchs(const struct d_mtrl *mq, xp->base->p[2]); glScalef(xp->base->r, 1.f, xp->base->r); - mq = swch_draw(mq, xp->f, xp->e); + swch_draw(rend, xp->f, xp->e); } glPopMatrix(); } - return mq; } /*---------------------------------------------------------------------------*/ @@ -286,10 +276,12 @@ 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; - const struct d_mtrl *mq = sol_draw_enable(); + struct s_rend rend = { NULL }; float fov = FOV; + sol_draw_enable(&rend); + if (jump_b) fov *= 2.0f * fabsf(jump_dt - 0.5f); video_push_persp(fov, 0.1f, FAR_DIST); @@ -314,7 +306,7 @@ void game_draw(int pose, float t) glPushMatrix(); { glTranslatef(view_p[0], view_p[1], view_p[2]); - mq = back_draw(mq, 0); + back_draw(&rend, 0); } glPopMatrix(); @@ -323,7 +315,7 @@ void game_draw(int pose, float t) /* Draw the floor. */ - mq = sol_draw(fp, mq, 0, 1); + sol_draw(fp, &rend, 0, 1); /* Draw the game elements. */ @@ -332,17 +324,17 @@ void game_draw(int pose, float t) if (pose == 0) { - mq = game_draw_balls(mq, fp->vary, T, t); - mq = game_draw_vect(mq, fp->vary); + game_draw_balls(&rend, fp->vary, T, t); + game_draw_vect(&rend, fp->vary); } glEnable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); glDepthMask(GL_FALSE); { - mq = game_draw_goals(mq, fp->base); - mq = game_draw_jumps(mq, fp->base); - mq = game_draw_swchs(mq, fp->vary); + game_draw_goals(&rend, fp->base); + game_draw_jumps(&rend, fp->base); + game_draw_swchs(&rend, fp->vary); } glDepthMask(GL_TRUE); glEnable(GL_LIGHTING); @@ -351,7 +343,7 @@ void game_draw(int pose, float t) glPopMatrix(); video_pop_matrix(); - sol_draw_disable(mq); + sol_draw_disable(&rend); } /*---------------------------------------------------------------------------*/ diff --git a/share/ball.c b/share/ball.c index 7897ee9..b564e82 100644 --- a/share/ball.c +++ b/share/ball.c @@ -119,9 +119,9 @@ void ball_free(void) /*---------------------------------------------------------------------------*/ -static const struct d_mtrl *ball_draw_solid(const struct d_mtrl *mq, - const float *ball_M, - const float *ball_bill_M, float t) +static void ball_draw_solid(struct s_rend *rend, + const float *ball_M, + const float *ball_bill_M, float t) { if (has_solid) { @@ -148,7 +148,7 @@ static const struct d_mtrl *ball_draw_solid(const struct d_mtrl *mq, if (mask == 0) glDepthMask(GL_FALSE); glDisable(GL_LIGHTING); { - mq = sol_bill(&solid.draw, mq, ball_bill_M, t); + sol_bill(&solid.draw, rend, ball_bill_M, t); } glEnable(GL_LIGHTING); if (mask == 0) glDepthMask(GL_TRUE); @@ -157,20 +157,19 @@ static const struct d_mtrl *ball_draw_solid(const struct d_mtrl *mq, /* Draw the solid opaque and transparent geometry. */ - mq = sol_draw(&solid.draw, mq, mask, test); + sol_draw(&solid.draw, rend, mask, test); } glPopMatrix(); if (solid_alpha < 1.0f) glDisable(GL_ALPHA_TEST); } - return mq; } -static const struct d_mtrl *ball_draw_inner(const struct d_mtrl *mq, - const float *pend_M, - const float *bill_M, - const float *pend_bill_M, float t) +static void ball_draw_inner(struct s_rend *rend, + const float *pend_M, + const float *bill_M, + const float *pend_bill_M, float t) { if (has_inner) { @@ -194,7 +193,7 @@ static const struct d_mtrl *ball_draw_inner(const struct d_mtrl *mq, /* Draw the inner opaque and transparent geometry. */ - mq = sol_draw(&inner.draw, mq, mask, test); + sol_draw(&inner.draw, rend, mask, test); /* Draw the inner billboard geometry. */ @@ -205,9 +204,9 @@ static const struct d_mtrl *ball_draw_inner(const struct d_mtrl *mq, glDisable(GL_LIGHTING); { if (pend) - mq = sol_bill(&inner.draw, mq, pend_bill_M, t); + sol_bill(&inner.draw, rend, pend_bill_M, t); else - mq = sol_bill(&inner.draw, mq, bill_M, t); + sol_bill(&inner.draw, rend, bill_M, t); } glEnable(GL_LIGHTING); @@ -221,13 +220,12 @@ static const struct d_mtrl *ball_draw_inner(const struct d_mtrl *mq, if (inner_alpha < 1.0f) glDisable(GL_ALPHA_TEST); } - return mq; } -static const struct d_mtrl *ball_draw_outer(const struct d_mtrl *mq, - const float *pend_M, - const float *bill_M, - const float *pend_bill_M, float t) +static void ball_draw_outer(struct s_rend *rend, + const float *pend_M, + const float *bill_M, + const float *pend_bill_M, float t) { if (has_outer) { @@ -241,7 +239,7 @@ static const struct d_mtrl *ball_draw_outer(const struct d_mtrl *mq, glAlphaFunc(GL_GEQUAL, outer_alpha); } - /* Apply the pendulum rotation. */ + /* Apply the pendulum rotation. */ if (pend) { @@ -251,7 +249,7 @@ static const struct d_mtrl *ball_draw_outer(const struct d_mtrl *mq, /* Draw the outer opaque and transparent geometry. */ - mq = sol_draw(&outer.draw, mq, mask, test); + sol_draw(&outer.draw, rend, mask, test); /* Draw the outer billboard geometry. */ @@ -262,9 +260,9 @@ static const struct d_mtrl *ball_draw_outer(const struct d_mtrl *mq, glDisable(GL_LIGHTING); { if (pend) - mq = sol_bill(&outer.draw, mq, pend_bill_M, t); + sol_bill(&outer.draw, rend, pend_bill_M, t); else - mq = sol_bill(&outer.draw, mq, bill_M, t); + sol_bill(&outer.draw, rend, bill_M, t); } glEnable(GL_LIGHTING); if (mask == 0) glDepthMask(GL_TRUE); @@ -277,28 +275,27 @@ static const struct d_mtrl *ball_draw_outer(const struct d_mtrl *mq, if (outer_alpha < 1.0f) glDisable(GL_ALPHA_TEST); } - return mq; } /*---------------------------------------------------------------------------*/ -static const struct d_mtrl *ball_pass_inner(const struct d_mtrl *mq, - const float *ball_M, - const float *pend_M, - const float *bill_M, - const float *ball_bill_M, - const float *pend_bill_M, float t) +static void ball_pass_inner(struct s_rend *rend, + const float *ball_M, + const float *pend_M, + const float *bill_M, + const float *ball_bill_M, + const float *pend_bill_M, float t) { /* Sort the inner ball using clip planes. */ if (inner_flags & F_DRAWCLIP) { glEnable(GL_CLIP_PLANE1); - mq = ball_draw_inner(mq, pend_M, bill_M, pend_bill_M, t); + ball_draw_inner(rend, pend_M, bill_M, pend_bill_M, t); glDisable(GL_CLIP_PLANE1); glEnable(GL_CLIP_PLANE2); - mq = ball_draw_inner(mq, pend_M, bill_M, pend_bill_M, t); + ball_draw_inner(rend, pend_M, bill_M, pend_bill_M, t); glDisable(GL_CLIP_PLANE2); } @@ -307,40 +304,38 @@ static const struct d_mtrl *ball_pass_inner(const struct d_mtrl *mq, else if (inner_flags & F_DRAWBACK) { glCullFace(GL_FRONT); - mq = ball_draw_inner(mq, pend_M, bill_M, pend_bill_M, t); + ball_draw_inner(rend, pend_M, bill_M, pend_bill_M, t); glCullFace(GL_BACK); - mq = ball_draw_inner(mq, pend_M, bill_M, pend_bill_M, t); + ball_draw_inner(rend, pend_M, bill_M, pend_bill_M, t); } /* Draw the inner ball normally. */ else { - mq = ball_draw_inner(mq, pend_M, bill_M, pend_bill_M, t); + ball_draw_inner(rend, pend_M, bill_M, pend_bill_M, t); } - - return mq; } -static const struct d_mtrl *ball_pass_solid(const struct d_mtrl *mq, - const float *ball_M, - const float *pend_M, - const float *bill_M, - const float *ball_bill_M, - const float *pend_bill_M, float t) +static void ball_pass_solid(struct s_rend *rend, + const float *ball_M, + const float *pend_M, + const float *bill_M, + const float *ball_bill_M, + const float *pend_bill_M, float t) { /* Sort the solid ball with the inner ball using clip planes. */ if (solid_flags & F_DRAWCLIP) { glEnable(GL_CLIP_PLANE1); - mq = ball_draw_solid(mq, ball_M, ball_bill_M, t); + ball_draw_solid(rend, ball_M, ball_bill_M, t); glDisable(GL_CLIP_PLANE1); - mq = ball_pass_inner(mq, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); + ball_pass_inner(rend, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); glEnable(GL_CLIP_PLANE2); - mq = ball_draw_solid(mq, ball_M, ball_bill_M, t); + ball_draw_solid(rend, ball_M, ball_bill_M, t); glDisable(GL_CLIP_PLANE2); } @@ -349,43 +344,41 @@ static const struct d_mtrl *ball_pass_solid(const struct d_mtrl *mq, else if (solid_flags & F_DRAWBACK) { glCullFace(GL_FRONT); - mq = ball_draw_solid(mq, ball_M, ball_bill_M, t); + ball_draw_solid(rend, ball_M, ball_bill_M, t); glCullFace(GL_BACK); - mq = ball_pass_inner(mq, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); - mq = ball_draw_solid(mq, ball_M, ball_bill_M, t); + ball_pass_inner(rend, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); + ball_draw_solid(rend, ball_M, ball_bill_M, t); } /* Draw the solid ball after the inner ball. */ else { - mq = ball_pass_inner(mq, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); - mq = ball_draw_solid(mq, ball_M, ball_bill_M, t); + ball_pass_inner(rend, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); + ball_draw_solid(rend, ball_M, ball_bill_M, t); } - - return mq; } -static const struct d_mtrl *ball_pass_outer(const struct d_mtrl *mq, - const float *ball_M, - const float *pend_M, - const float *bill_M, - const float *ball_bill_M, - const float *pend_bill_M, float t) +static void ball_pass_outer(struct s_rend *rend, + const float *ball_M, + const float *pend_M, + const float *bill_M, + const float *ball_bill_M, + const float *pend_bill_M, float t) { /* Sort the outer ball with the solid ball using clip planes. */ if (outer_flags & F_DRAWCLIP) { glEnable(GL_CLIP_PLANE1); - mq = ball_draw_outer(mq, pend_M, bill_M, pend_bill_M, t); + ball_draw_outer(rend, pend_M, bill_M, pend_bill_M, t); glDisable(GL_CLIP_PLANE1); - mq = ball_pass_solid(mq, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); + ball_pass_solid(rend, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); glEnable(GL_CLIP_PLANE2); - mq = ball_draw_outer(mq, pend_M, bill_M, pend_bill_M, t); + ball_draw_outer(rend, pend_M, bill_M, pend_bill_M, t); glDisable(GL_CLIP_PLANE2); } @@ -394,30 +387,28 @@ static const struct d_mtrl *ball_pass_outer(const struct d_mtrl *mq, else if (outer_flags & F_DRAWBACK) { glCullFace(GL_FRONT); - mq = ball_draw_outer(mq, pend_M, bill_M, pend_bill_M, t); + ball_draw_outer(rend, pend_M, bill_M, pend_bill_M, t); glCullFace(GL_BACK); - mq = ball_pass_solid(mq, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); - mq = ball_draw_outer(mq, pend_M, bill_M, pend_bill_M, t); + ball_pass_solid(rend, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); + ball_draw_outer(rend, pend_M, bill_M, pend_bill_M, t); } /* Draw the outer ball after the solid ball. */ else { - mq = ball_pass_solid(mq, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); - mq = ball_draw_outer(mq, pend_M, bill_M, pend_bill_M, t); + ball_pass_solid(rend, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); + ball_draw_outer(rend, pend_M, bill_M, pend_bill_M, t); } - - return mq; } /*---------------------------------------------------------------------------*/ -const struct d_mtrl *ball_draw(const struct d_mtrl *mq, - const float *ball_M, - const float *pend_M, - const float *bill_M, float t) +void ball_draw(struct s_rend *rend, + const float *ball_M, + const float *pend_M, + const float *bill_M, float t) { /* Compute transforms for ball and pendulum billboards. */ @@ -432,7 +423,7 @@ const struct d_mtrl *ball_draw(const struct d_mtrl *mq, /* Go to GREAT pains to ensure all layers are drawn back-to-front. */ - return ball_pass_outer(mq, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); + ball_pass_outer(rend, ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t); } /*---------------------------------------------------------------------------*/ diff --git a/share/ball.h b/share/ball.h index 76c778a..ac44494 100644 --- a/share/ball.h +++ b/share/ball.h @@ -15,6 +15,8 @@ #ifndef BALL_H #define BALL_H +#include "solid_draw.h" + /*---------------------------------------------------------------------------*/ #define BALL_FUDGE 0.001f @@ -22,10 +24,10 @@ void ball_init(void); void ball_free(void); -const struct d_mtrl *ball_draw(const struct d_mtrl *, - const float *, - const float *, - const float *, float); +void ball_draw(struct s_rend *, + const float *, + const float *, + const float *, float); /*---------------------------------------------------------------------------*/ diff --git a/share/geom.c b/share/geom.c index 958203f..5e7d4c0 100644 --- a/share/geom.c +++ b/share/geom.c @@ -83,53 +83,48 @@ void back_free(void) { if (back_state) sol_free_full(&back); - + back_state = 0; } /*---------------------------------------------------------------------------*/ -static const struct d_mtrl *jump_part_draw(const struct d_mtrl *mq, - GLfloat s, GLfloat a) +static void jump_part_draw(struct s_rend *rend, GLfloat s, GLfloat a) { glMatrixMode(GL_TEXTURE); glTranslatef(s, 0.0f, 0.0f); glMatrixMode(GL_MODELVIEW); glRotatef(a, 0.0f, 1.0f, 0.0f); - mq = sol_draw(&jump.draw, mq, 1, 1); + sol_draw(&jump.draw, rend, 1, 1); glScalef(0.9f, 0.9f, 0.9f); - - return mq; } -static const struct d_mtrl *goal_part_draw(const struct d_mtrl *mq, GLfloat s) +static void goal_part_draw(struct s_rend *rend, GLfloat s) { glMatrixMode(GL_TEXTURE); glTranslatef(0.0f, -s, 0.0f); glMatrixMode(GL_MODELVIEW); - mq = sol_draw(&goal.draw, mq, 1, 1); + sol_draw(&goal.draw, rend, 1, 1); glScalef(0.8f, 1.1f, 0.8f); - - return mq; } /*---------------------------------------------------------------------------*/ -const struct d_mtrl *goal_draw(const struct d_mtrl *mq, float t) +void goal_draw(struct s_rend *rend, float t) { glPushMatrix(); { glScalef(1.0f, 3.0f, 1.0f); glColor4f(1.0f, 1.0f, 0.0f, 0.5f); - mq = sol_draw(&beam.draw, mq, 1, 1); + sol_draw(&beam.draw, rend, 1, 1); - mq = goal_part_draw(mq, t * 0.10f); - mq = goal_part_draw(mq, t * 0.10f); - mq = goal_part_draw(mq, t * 0.10f); - mq = goal_part_draw(mq, t * 0.10f); + goal_part_draw(rend, t * 0.10f); + goal_part_draw(rend, t * 0.10f); + goal_part_draw(rend, t * 0.10f); + goal_part_draw(rend, t * 0.10f); glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -138,11 +133,9 @@ const struct d_mtrl *goal_draw(const struct d_mtrl *mq, float t) glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } glPopMatrix(); - - return mq; } -const struct d_mtrl *jump_draw(const struct d_mtrl *mq, float t, int h) +void jump_draw(struct s_rend *rend, float t, int h) { static GLfloat c[4][4] = { { 0.75f, 0.5f, 1.0f, 0.5f }, @@ -155,11 +148,11 @@ const struct d_mtrl *jump_draw(const struct d_mtrl *mq, float t, int h) glScalef(1.0f, 2.0f, 1.0f); - mq = sol_draw(&beam.draw, mq, 1, 1); + sol_draw(&beam.draw, rend, 1, 1); - mq = jump_part_draw(mq, t * 0.15f, t * 360.0f); - mq = jump_part_draw(mq, t * 0.20f, t * 360.0f); - mq = jump_part_draw(mq, t * 0.25f, t * 360.0f); + jump_part_draw(rend, t * 0.15f, t * 360.0f); + jump_part_draw(rend, t * 0.20f, t * 360.0f); + jump_part_draw(rend, t * 0.25f, t * 360.0f); glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -168,11 +161,9 @@ const struct d_mtrl *jump_draw(const struct d_mtrl *mq, float t, int h) glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } glPopMatrix(); - - return mq; } -const struct d_mtrl *swch_draw(const struct d_mtrl *mq, int b, int e) +void swch_draw(struct s_rend *rend, int b, int e) { static GLfloat c[4][4] = { { 1.0f, 0.0f, 0.0f, 0.5f }, /* red out */ @@ -188,33 +179,30 @@ const struct d_mtrl *swch_draw(const struct d_mtrl *mq, int b, int e) glScalef(1.0f, 2.0f, 1.0f); glColor4f(c[h][0], c[h][1], c[h][2], c[h][3]); - mq = sol_draw(&beam.draw, mq, 1, 1); + sol_draw(&beam.draw, rend, 1, 1); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } glPopMatrix(); - - return mq; } -const struct d_mtrl *flag_draw(const struct d_mtrl *mq) +void flag_draw(struct s_rend *rend) { glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - return sol_draw(&flag.draw, mq, 1, 1); + sol_draw(&flag.draw, rend, 1, 1); } -const struct d_mtrl *mark_draw(const struct d_mtrl *mq) +void mark_draw(struct s_rend *rend) { - return sol_draw(&mark.draw, mq, 1, 1); + sol_draw(&mark.draw, rend, 1, 1); } -const struct d_mtrl *vect_draw(const struct d_mtrl *mq) +void vect_draw(struct s_rend *rend) { - mq = sol_draw(&vect.draw, mq, 0, 1); - mq = sol_draw(&vect.draw, mq, 0, 0); - return mq; + sol_draw(&vect.draw, rend, 0, 1); + sol_draw(&vect.draw, rend, 0, 0); } -const struct d_mtrl *back_draw(const struct d_mtrl *mq, float t) +void back_draw(struct s_rend *rend, float t) { glPushMatrix(); { @@ -230,7 +218,7 @@ const struct d_mtrl *back_draw(const struct d_mtrl *mq, float t) if (t) glRotatef(dz, 0.0f, 0.0f, 1.0f); if (t) glRotatef(dx, 1.0f, 0.0f, 0.0f); - mq = sol_draw(&back.draw, mq, 1, 1); + sol_draw(&back.draw, rend, 1, 1); } glDepthMask(GL_TRUE); glEnable(GL_LIGHTING); @@ -238,13 +226,15 @@ const struct d_mtrl *back_draw(const struct d_mtrl *mq, float t) glEnable(GL_DEPTH_TEST); } glPopMatrix(); - - return mq; } void back_draw_easy(void) { - sol_draw_disable(back_draw(sol_draw_enable(), 0.0f)); + struct s_rend rend = { NULL }; + + sol_draw_enable(&rend); + back_draw(&rend, 0.0f); + sol_draw_disable(&rend); } /*---------------------------------------------------------------------------*/ diff --git a/share/geom.h b/share/geom.h index ebdd8a6..d5dfaf8 100644 --- a/share/geom.h +++ b/share/geom.h @@ -19,13 +19,13 @@ void geom_init(void); void geom_free(void); -const struct d_mtrl *goal_draw(const struct d_mtrl *, float); -const struct d_mtrl *jump_draw(const struct d_mtrl *, float, int); -const struct d_mtrl *swch_draw(const struct d_mtrl *, int, int); -const struct d_mtrl *flag_draw(const struct d_mtrl *); -const struct d_mtrl *mark_draw(const struct d_mtrl *); -const struct d_mtrl *vect_draw(const struct d_mtrl *); -const struct d_mtrl *back_draw(const struct d_mtrl *, float); +void goal_draw(struct s_rend *, float); +void jump_draw(struct s_rend *, float, int); +void swch_draw(struct s_rend *, int, int); +void flag_draw(struct s_rend *); +void mark_draw(struct s_rend *); +void vect_draw(struct s_rend *); +void back_draw(struct s_rend *, float); /*---------------------------------------------------------------------------*/ diff --git a/share/item.c b/share/item.c index d1b8aea..2cf8b12 100644 --- a/share/item.c +++ b/share/item.c @@ -98,9 +98,9 @@ void item_free(void) sol_free_full(&item_shrink_file); } -const struct d_mtrl *item_draw(const struct d_mtrl *mq, - const struct v_item *hp, - const GLfloat *M, float t) +void item_draw(struct s_rend *rend, + const struct v_item *hp, + const GLfloat *M, float t) { struct s_draw *draw = NULL; float c[4]; @@ -118,18 +118,16 @@ const struct d_mtrl *item_draw(const struct d_mtrl *mq, glDepthMask(GL_FALSE); { - mq = sol_bill(draw, mq, M, t); + sol_bill(draw, rend, M, t); } glDepthMask(GL_TRUE); glPushMatrix(); { glRotatef(360.0f * t, 0.0f, 1.0f, 0.0f); - mq = sol_draw(draw, mq, 0, 1); + sol_draw(draw, rend, 0, 1); } glPopMatrix(); - - return mq; } /*---------------------------------------------------------------------------*/ diff --git a/share/item.h b/share/item.h index d63edde..3450db2 100644 --- a/share/item.h +++ b/share/item.h @@ -16,6 +16,7 @@ #define ITEM_H #include "solid_vary.h" +#include "solid_draw.h" #define ITEM_RADIUS 0.15f @@ -23,7 +24,6 @@ void item_color(const struct v_item *, float *); void item_init(void); void item_free(void); -const struct d_mtrl *item_draw(const struct d_mtrl *, - const struct v_item *, const float *, float); +void item_draw(struct s_rend *, const struct v_item *, const float *, float); #endif diff --git a/share/part.c b/share/part.c index 387a7fd..141f7cd 100644 --- a/share/part.c +++ b/share/part.c @@ -225,12 +225,12 @@ void part_step(const float *g, float dt) /*---------------------------------------------------------------------------*/ -const struct d_mtrl *part_draw_coin(const struct d_mtrl *mq) +void part_draw_coin(struct s_rend *rend) { const GLfloat c[3] = { 0.0f, 1.0f, 0.0f }; GLint s = config_get_d(CONFIG_HEIGHT) / 8; - mq = sol_apply_mtrl(&coin_draw_mtrl, mq); + sol_apply_mtrl(&coin_draw_mtrl, rend); /* Draw the entire buffer. Dead particles have zero opacity anyway. */ @@ -275,8 +275,6 @@ const struct d_mtrl *part_draw_coin(const struct d_mtrl *mq) glClientActiveTexture_(GL_TEXTURE1); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glClientActiveTexture_(GL_TEXTURE0); - - return mq; } /*---------------------------------------------------------------------------*/ diff --git a/share/part.h b/share/part.h index 78b4da7..23b7855 100644 --- a/share/part.h +++ b/share/part.h @@ -23,7 +23,7 @@ void part_free(void); void part_burst(const float *, const float *); void part_step(const float *, float); -const struct d_mtrl *part_draw_coin(const struct d_mtrl *); +void part_draw_coin(struct s_rend *); void part_lerp_apply(float); diff --git a/share/solid_draw.c b/share/solid_draw.c index edcadb8..faa8b56 100644 --- a/share/solid_draw.c +++ b/share/solid_draw.c @@ -212,10 +212,10 @@ static struct d_mtrl default_draw_mtrl = &default_base_mtrl, 0 }; -const struct d_mtrl *sol_apply_mtrl(const struct d_mtrl *mp_draw, - const struct d_mtrl *mq_draw) +void sol_apply_mtrl(const struct d_mtrl *mp_draw, struct s_rend *rend) { const struct b_mtrl *mp_base = mp_draw->base; + const struct d_mtrl *mq_draw = rend->mp; const struct b_mtrl *mq_base = mq_draw->base; /* Bind the texture. */ @@ -306,7 +306,7 @@ const struct d_mtrl *sol_apply_mtrl(const struct d_mtrl *mp_draw, glDisable(GL_POLYGON_OFFSET_FILL); } - return mp_draw; + rend->mp = mp_draw; } static GLuint sol_find_texture(const char *name) @@ -335,7 +335,7 @@ static GLuint sol_find_texture(const char *name) } static void sol_load_mtrl(struct d_mtrl *mp, - const struct b_mtrl *mq, + const struct b_mtrl *mq, struct s_draw *draw) { mp->base = mq; @@ -446,7 +446,7 @@ static int sol_count_mesh(const struct d_body *bp, int p) /*---------------------------------------------------------------------------*/ static void sol_mesh_vert(struct d_vert *vp, - const struct s_base *base, int oi) + const struct s_base *base, int oi) { /* Gather all vertex attributes for the given offs. */ @@ -468,7 +468,7 @@ static void sol_mesh_vert(struct d_vert *vp, static void sol_mesh_geom(struct d_vert *vv, int *vn, struct d_geom *gv, int *gn, - const struct s_base *base, int *iv, int g0, int gc, int mi) + const struct s_base *base, int *iv, int g0, int gc, int mi) { int gi; @@ -510,8 +510,8 @@ static void sol_mesh_geom(struct d_vert *vv, int *vn, } static void sol_load_mesh(struct d_mesh *mp, - const struct b_body *bp, - const struct s_draw *draw, int mi) + const struct b_body *bp, + const struct s_draw *draw, int mi) { const size_t vs = sizeof (struct d_vert); const size_t gs = sizeof (struct d_geom); @@ -578,8 +578,7 @@ static void sol_free_mesh(struct d_mesh *mp) glDeleteBuffers_(1, &mp->vbo); } -static const struct d_mtrl *sol_draw_mesh(const struct d_mesh *mp, - const struct d_mtrl *mq, int p) +void sol_draw_mesh(const struct d_mesh *mp, struct s_rend *rend, int p) { /* If this mesh has material matching the given flags... */ @@ -590,7 +589,7 @@ static const struct d_mtrl *sol_draw_mesh(const struct d_mesh *mp, /* Apply the material state. */ - mq = sol_apply_mtrl(mp->mp, mq); + sol_apply_mtrl(mp->mp, rend); /* Bind the mesh data. */ @@ -609,15 +608,13 @@ static const struct d_mtrl *sol_draw_mesh(const struct d_mesh *mp, glDrawElements(GL_TRIANGLES, mp->ebc, GL_UNSIGNED_SHORT, 0); } - - return mq; } /*---------------------------------------------------------------------------*/ static void sol_load_body(struct d_body *bp, - const struct b_body *bq, - const struct s_draw *draw) + const struct b_body *bq, + const struct s_draw *draw) { int mi; @@ -660,15 +657,12 @@ static void sol_free_body(struct d_body *bp) free(bp->mv); } -static const struct d_mtrl *sol_draw_body(const struct d_body *bp, - const struct d_mtrl *mq, int p) +static void sol_draw_body(const struct d_body *bp, struct s_rend *rend, int p) { int i; for (i = 0; i < bp->mc; ++i) - mq = sol_draw_mesh(bp->mv + i, mq, p); - - return mq; + sol_draw_mesh(bp->mv + i, rend, p); } /*---------------------------------------------------------------------------*/ @@ -727,8 +721,7 @@ void sol_free_draw(struct s_draw *draw) /*---------------------------------------------------------------------------*/ -static const struct d_mtrl *sol_draw_all(const struct s_draw *draw, - const struct d_mtrl *mq, int p) +static void sol_draw_all(const struct s_draw *draw, struct s_rend *rend, int p) { int bi; @@ -741,15 +734,13 @@ static const struct d_mtrl *sol_draw_all(const struct s_draw *draw, glPushMatrix(); { sol_transform(draw->vary, draw->vary->bv + bi); - mq = sol_draw_body(draw->bv + bi, mq, p); + sol_draw_body(draw->bv + bi, rend, p); } glPopMatrix(); } - - return mq; } -const struct d_mtrl *sol_draw_enable(void) +void sol_draw_enable(struct s_rend *rend) { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); @@ -759,12 +750,12 @@ const struct d_mtrl *sol_draw_enable(void) glClientActiveTexture_(GL_TEXTURE0); glEnableClientState(GL_TEXTURE_COORD_ARRAY); - return &default_draw_mtrl; + rend->mp = &default_draw_mtrl; } -void sol_draw_disable(const struct d_mtrl *mq) +void sol_draw_disable(struct s_rend *rend) { - sol_apply_mtrl(&default_draw_mtrl, mq); + sol_apply_mtrl(&default_draw_mtrl, rend); glClientActiveTexture_(GL_TEXTURE1); glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -777,21 +768,20 @@ void sol_draw_disable(const struct d_mtrl *mq) /*---------------------------------------------------------------------------*/ -const struct d_mtrl *sol_draw(const struct s_draw *draw, - const struct d_mtrl *mq, int mask, int test) +void sol_draw(const struct s_draw *draw, struct s_rend *rend, int mask, int test) { /* Render all opaque geometry, decals last. */ - mq = sol_draw_all(draw, mq, 0); - mq = sol_draw_all(draw, mq, 1); + sol_draw_all(draw, rend, 0); + sol_draw_all(draw, rend, 1); /* Render all transparent geometry, decals first. */ if (!test) glDisable(GL_DEPTH_TEST); if (!mask) glDepthMask(GL_FALSE); { - mq = sol_draw_all(draw, mq, 2); - mq = sol_draw_all(draw, mq, 3); + sol_draw_all(draw, rend, 2); + sol_draw_all(draw, rend, 3); } if (!mask) glDepthMask(GL_TRUE); if (!test) glEnable(GL_DEPTH_TEST); @@ -800,28 +790,23 @@ const struct d_mtrl *sol_draw(const struct s_draw *draw, glBindBuffer_(GL_ARRAY_BUFFER, 0); glBindBuffer_(GL_ELEMENT_ARRAY_BUFFER, 0); - - return mq; } -const struct d_mtrl *sol_refl(const struct s_draw *draw, - const struct d_mtrl *mq) +void sol_refl(const struct s_draw *draw, struct s_rend *rend) { /* Render all reflective geometry. */ - mq = sol_draw_all(draw, mq, 4); + sol_draw_all(draw, rend, 4); /* Revert the buffer object state. */ glBindBuffer_(GL_ARRAY_BUFFER, 0); glBindBuffer_(GL_ELEMENT_ARRAY_BUFFER, 0); - - return mq; } -const struct d_mtrl *sol_back(const struct s_draw *draw, - const struct d_mtrl *mq, - float n, float f, float t) +void sol_back(const struct s_draw *draw, + struct s_rend *rend, + float n, float f, float t) { glDisable(GL_LIGHTING); glDepthMask(GL_FALSE); @@ -872,7 +857,7 @@ const struct d_mtrl *sol_back(const struct s_draw *draw, glScalef(w, h, 1.0f); - mq = sol_apply_mtrl(draw->mv + rp->mi, mq); + sol_apply_mtrl(draw->mv + rp->mi, rend); if (rp->fl & B_EDGE) glDrawArrays(GL_TRIANGLE_STRIP, 4, 4); @@ -888,12 +873,10 @@ const struct d_mtrl *sol_back(const struct s_draw *draw, glDepthMask(GL_TRUE); glEnable(GL_LIGHTING); - - return mq; } -const struct d_mtrl *sol_bill(const struct s_draw *draw, - const struct d_mtrl *mq, const float *M, float t) +void sol_bill(const struct s_draw *draw, + struct s_rend *rend, const float *M, float t) { sol_bill_enable(draw); { @@ -912,7 +895,7 @@ const struct d_mtrl *sol_bill(const struct s_draw *draw, float ry = rp->ry[0] + rp->ry[1] * T + rp->ry[2] * S; float rz = rp->rz[0] + rp->rz[1] * T + rp->rz[2] * S; - mq = sol_apply_mtrl(draw->mv + rp->mi, mq); + sol_apply_mtrl(draw->mv + rp->mi, rend); glPushMatrix(); { @@ -930,8 +913,6 @@ const struct d_mtrl *sol_bill(const struct s_draw *draw, } } sol_bill_disable(); - - return mq; } void sol_fade(const struct s_draw *draw, float k) diff --git a/share/solid_draw.h b/share/solid_draw.h index 9f1fe59..0cef38c 100644 --- a/share/solid_draw.h +++ b/share/solid_draw.h @@ -90,23 +90,30 @@ struct s_draw /*---------------------------------------------------------------------------*/ +/* + * This structure holds rendering state shared between separate + * SOLs. I am aware that the name leaves much to be desired. + */ + +struct s_rend +{ + const struct d_mtrl *mp; +}; + +/*---------------------------------------------------------------------------*/ + int sol_load_draw(struct s_draw *, const struct s_vary *, int); void sol_free_draw(struct s_draw *); -const struct d_mtrl *sol_draw_enable(void); -void sol_draw_disable(const struct d_mtrl *); +void sol_draw_enable(struct s_rend *); +void sol_draw_disable(struct s_rend *); -const struct d_mtrl *sol_apply_mtrl(const struct d_mtrl *, - const struct d_mtrl *); +void sol_apply_mtrl(const struct d_mtrl *, struct s_rend *); -const struct d_mtrl *sol_back(const struct s_draw *, - const struct d_mtrl *, float, float, float); -const struct d_mtrl *sol_refl(const struct s_draw *, - const struct d_mtrl *); -const struct d_mtrl *sol_draw(const struct s_draw *, - const struct d_mtrl *, int, int); -const struct d_mtrl *sol_bill(const struct s_draw *, - const struct d_mtrl *, const float *, float); +void sol_back(const struct s_draw *, struct s_rend *, float, float, float); +void sol_refl(const struct s_draw *, struct s_rend *); +void sol_draw(const struct s_draw *, struct s_rend *, int, int); +void sol_bill(const struct s_draw *, struct s_rend *, const float *, float); void sol_fade(const struct s_draw *, float);