void shad_draw_set(const float *p, float r)
{
+ glBindTexture(GL_TEXTURE_2D, shad_text);
+
glMatrixMode(GL_TEXTURE);
{
float k = 0.25f / r;
- glBindTexture(GL_TEXTURE_2D, shad_text);
-
glLoadIdentity();
glTranslatef(0.5f - k * p[0],
0.5f - k * p[2], 0.f);
glScalef(k, k, 1.0f);
}
glMatrixMode(GL_MODELVIEW);
+
+ glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+ glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+
+ glEnable(GL_TEXTURE_GEN_S);
+ glEnable(GL_TEXTURE_GEN_T);
}
void shad_draw_clr(void)
glLoadIdentity();
}
glMatrixMode(GL_MODELVIEW);
+
+ glDisable(GL_TEXTURE_GEN_S);
+ glDisable(GL_TEXTURE_GEN_T);
}
/*---------------------------------------------------------------------------*/
glTexGenfv(GL_S, GL_OBJECT_PLANE, X);
glTexGenfv(GL_T, GL_OBJECT_PLANE, Z);
- glPushMatrix();
+ /* Translate the shadow on a moving body. */
+
+ glMatrixMode(GL_TEXTURE);
{
- /* Translate and rotate a moving body. */
+ glPushMatrix();
+ glTranslatef(p[0], p[2], 0.0f);
+ }
+ glMatrixMode(GL_MODELVIEW);
+
+ /* Draw the body. */
+ glPushMatrix();
+ {
glTranslatef(p[0], p[1], p[2]);
glRotatef(a, u[0], u[1], u[2]);
- /* Translate the shadow on a moving body. */
-
- glMatrixMode(GL_TEXTURE);
- {
- glPushMatrix();
- glTranslatef(p[0], p[2], 0.0f);
- }
- glMatrixMode(GL_MODELVIEW);
-
- /* Draw the body. */
-
glCallList(list);
+ }
+ glPopMatrix();
- /* Pop the shadow translation. */
+ /* Pop the shadow translation. */
- glMatrixMode(GL_TEXTURE);
- {
- glPopMatrix();
- }
- glMatrixMode(GL_MODELVIEW);
+ glMatrixMode(GL_TEXTURE);
+ {
+ glPopMatrix();
}
- glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
}
void sol_shad(const struct s_draw *draw)
/* Render all shadowed geometry. */
- glEnable(GL_TEXTURE_GEN_S);
- glEnable(GL_TEXTURE_GEN_T);
-
- glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
- glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-
glDepthMask(GL_FALSE);
{
for (bi = 0; bi < draw->bc; bi++)
sol_shad_list(draw->vary, draw->vary->bv + bi, draw->bv[bi].sl);
}
glDepthMask(GL_TRUE);
-
- glDisable(GL_TEXTURE_GEN_T);
- glDisable(GL_TEXTURE_GEN_S);
}
/*---------------------------------------------------------------------------*/