/*---------------------------------------------------------------------------*/
-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 };
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;
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();
}
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();
}
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();
}
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;
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;
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;
1.0f,
xp->base->r);
- mq = swch_draw(mq, xp->f, xp->e);
+ swch_draw(rend, xp->f, xp->e);
}
glPopMatrix();
}
- return mq;
}
/*---------------------------------------------------------------------------*/
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();
{
/* Draw the floor. */
- mq = sol_refl(&gd->draw, mq);
+ sol_refl(&gd->draw, rend);
}
glPopMatrix();
-
- return mq;
}
/*---------------------------------------------------------------------------*/
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();
{
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)
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;
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. */
/* Draw the ball. */
- mq = game_draw_balls(mq, draw->vary, M, t);
+ game_draw_balls(rend, draw->vary, M, t);
break;
}
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);
glDisable(GL_CLIP_PLANE0);
}
glPopMatrix();
-
- return mq;
}
/*---------------------------------------------------------------------------*/
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();
/* Draw the background. */
- mq = game_draw_back(mq, gd, pose, +1, t);
+ game_draw_back(&rend, gd, pose, +1, t);
/* Draw the reflection. */
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);
glStencilFunc(GL_EQUAL, 1, 0xFFFFFFFF);
/* Draw the scene reflected into color and depth buffers. */
-
+
glFrontFace(GL_CW);
glPushMatrix();
{
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);
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);
/* 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();
/* Draw the fade overlay. */
sol_fade(&gd->draw, gd->fade_k);
- sol_draw_disable(mq);
+ sol_draw_disable(&rend);
}
}
/*---------------------------------------------------------------------------*/
-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)
{
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 },
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();
}
color[ui][1],
color[ui][2], 0.5f);
- mq = mark_draw(mq);
+ mark_draw(rend);
}
glPopMatrix();
}
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;
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;
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;
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;
}
/*---------------------------------------------------------------------------*/
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);
glPushMatrix();
{
glTranslatef(view_p[0], view_p[1], view_p[2]);
- mq = back_draw(mq, 0);
+ back_draw(&rend, 0);
}
glPopMatrix();
/* Draw the floor. */
- mq = sol_draw(fp, mq, 0, 1);
+ sol_draw(fp, &rend, 0, 1);
/* Draw the game elements. */
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);
glPopMatrix();
video_pop_matrix();
- sol_draw_disable(mq);
+ sol_draw_disable(&rend);
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
-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)
{
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);
/* 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)
{
/* 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. */
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);
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)
{
glAlphaFunc(GL_GEQUAL, outer_alpha);
}
- /* Apply the pendulum rotation. */
+ /* Apply the pendulum rotation. */
if (pend)
{
/* 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. */
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);
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);
}
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);
}
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);
}
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. */
/* 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);
}
/*---------------------------------------------------------------------------*/
#ifndef BALL_H
#define BALL_H
+#include "solid_draw.h"
+
/*---------------------------------------------------------------------------*/
#define BALL_FUDGE 0.001f
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);
/*---------------------------------------------------------------------------*/
{
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();
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 },
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();
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 */
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();
{
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);
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);
}
/*---------------------------------------------------------------------------*/
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);
/*---------------------------------------------------------------------------*/
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];
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;
}
/*---------------------------------------------------------------------------*/
#define ITEM_H
#include "solid_vary.h"
+#include "solid_draw.h"
#define ITEM_RADIUS 0.15f
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
/*---------------------------------------------------------------------------*/
-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. */
glClientActiveTexture_(GL_TEXTURE1);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture_(GL_TEXTURE0);
-
- return mq;
}
/*---------------------------------------------------------------------------*/
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);
&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. */
glDisable(GL_POLYGON_OFFSET_FILL);
}
- return mp_draw;
+ rend->mp = mp_draw;
}
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;
/*---------------------------------------------------------------------------*/
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. */
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;
}
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);
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... */
/* Apply the material state. */
- mq = sol_apply_mtrl(mp->mp, mq);
+ sol_apply_mtrl(mp->mp, rend);
/* Bind the mesh data. */
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;
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);
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
-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;
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);
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);
/*---------------------------------------------------------------------------*/
-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);
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);
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);
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);
{
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();
{
}
}
sol_bill_disable();
-
- return mq;
}
void sol_fade(const struct s_draw *draw, float k)
/*---------------------------------------------------------------------------*/
+/*
+ * 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);