+static struct s_mtrl default_mtrl =
+{
+ { 0.8f, 0.8f, 0.8f, 1.0f },
+ { 0.2f, 0.2f, 0.2f, 1.0f },
+ { 0.0f, 0.0f, 0.0f, 1.0f },
+ { 0.0f, 0.0f, 0.0f, 1.0f },
+ { 0.0f, }, 0.0f, M_OPAQUE, 0, ""
+};
+
+static const struct s_mtrl *sol_draw_mtrl(const struct s_file *fp,
+ const struct s_mtrl *mp,
+ const struct s_mtrl *mq)
+{
+ /* Change material properties only as needed. */
+
+ if (!color_cmp(mp->a, mq->a))
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mp->a);
+ if (!color_cmp(mp->d, mq->d))
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mp->d);
+ if (!color_cmp(mp->s, mq->s))
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mp->s);
+ if (!color_cmp(mp->e, mq->e))
+ glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, mp->e);
+ if (tobyte(mp->h[0]) != tobyte(mq->h[0]))
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mp->h);
+
+ /* Bind the texture. */
+
+ if (mp->o != mq->o)
+ glBindTexture(GL_TEXTURE_2D, mp->o);
+
+ /* Enable environment mapping. */
+
+ if ((mp->fl & M_ENVIRONMENT) && !(mq->fl & M_ENVIRONMENT))