static void size_image(const char *name, int *w, int *h)
{
char jpg[MAXSTR];
- char tga[MAXSTR];
char png[MAXSTR];
int i;
*h = 0;
strcpy(jpg, name); strcat(jpg, ".jpg");
- strcpy(tga, name); strcat(tga, ".tga");
strcpy(png, name); strcat(png, ".png");
if (size_load(config_data(png), w, h) ||
- size_load(config_data(tga), w, h) ||
size_load(config_data(jpg), w, h))
{
static void uniq_file(struct s_file *fp)
{
- if (debug_output)
- return;
+ /* Debug mode skips optimization, producing oversized output files. */
- uniq_mtrl(fp);
- uniq_vert(fp);
- uniq_edge(fp);
- uniq_side(fp);
- uniq_texc(fp);
- uniq_geom(fp);
+ if (debug_output == 0)
+ {
+ uniq_mtrl(fp);
+ uniq_vert(fp);
+ uniq_edge(fp);
+ uniq_side(fp);
+ uniq_texc(fp);
+ uniq_geom(fp);
+ }
}
/*---------------------------------------------------------------------------*/
p->rc, p->uc, p->ac, p->dc, p->ic);
}
-/* Skip the ugly SDL main substitution since we only need sdl_image. */
-#ifdef main
-# undef main
-#endif
-
int main(int argc, char *argv[])
{
char src[MAXSTR];
glBlendFunc(GL_ONE, GL_ONE);
else
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- if (mp->fl & M_DECAL)
- {
- glEnable(GL_POLYGON_OFFSET_FILL);
- glPolygonOffset(-1.0f, -1.0f);
- }
- else
- glDisable(GL_POLYGON_OFFSET_FILL);
}
static void sol_draw_bill(const struct s_file *fp,
}
static void sol_draw_body(const struct s_file *fp,
- const struct s_body *bp, int fl)
+ const struct s_body *bp, int fl, int decal)
{
int mi, li, gi;
+ if (decal)
+ {
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(-1.0f, -2.0f);
+ }
+
/* Iterate all materials of the correct opacity. */
for (mi = 0; mi < fp->mc; mi++)
- if (fp->mv[mi].fl & fl)
+ if ((fp->mv[mi].fl & fl) && (fp->mv[mi].fl & M_DECAL) == decal)
{
if (sol_enum_mtrl(fp, bp, mi))
{
glEnd();
}
}
+
+ if (decal)
+ glDisable(GL_POLYGON_OFFSET_FILL);
}
static void sol_draw_list(const struct s_file *fp,
}
static void sol_shad_body(const struct s_file *fp,
- const struct s_body *bp, int fl)
+ const struct s_body *bp, int fl, int decal)
{
int mi, li, gi;
+ if (decal)
+ {
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(-1.0f, -2.0f);
+ }
+
glBegin(GL_TRIANGLES);
{
for (mi = 0; mi < fp->mc; mi++)
}
}
glEnd();
+
+ if (decal)
+ glDisable(GL_POLYGON_OFFSET_FILL);
}
static void sol_shad_list(const struct s_file *fp,
{
int i;
+ /* Here we sort geometry into display lists by material type. */
+
for (i = 0; i < fp->bc; i++)
{
struct s_body *bp = fp->bv + i;
- /* Draw all opaque geometry. */
+ /* Draw all opaque geometry, decals last. */
if (sol_enum_body(fp, bp, M_OPAQUE | M_ENVIRONMENT))
{
glNewList(fp->bv[i].ol, GL_COMPILE);
{
- sol_draw_body(fp, fp->bv + i, M_OPAQUE | M_ENVIRONMENT);
+ sol_draw_body(fp, fp->bv+i, M_OPAQUE | M_ENVIRONMENT, 0);
+ sol_draw_body(fp, fp->bv+i, M_OPAQUE | M_ENVIRONMENT, M_DECAL);
}
glEndList();
}
else fp->bv[i].ol = 0;
- /* Draw all translucent geometry. */
+ /* Draw all translucent geometry, decals first. */
if (sol_enum_body(fp, bp, M_TRANSPARENT))
{
glNewList(fp->bv[i].tl, GL_COMPILE);
{
- sol_draw_body(fp, fp->bv + i, M_TRANSPARENT);
+ sol_draw_body(fp, fp->bv+i, M_TRANSPARENT, M_DECAL);
+ sol_draw_body(fp, fp->bv+i, M_TRANSPARENT, 0);
}
glEndList();
}
glNewList(fp->bv[i].rl, GL_COMPILE);
{
- sol_draw_body(fp, fp->bv + i, M_REFLECTIVE);
+ sol_draw_body(fp, fp->bv+i, M_REFLECTIVE, 0);
}
glEndList();
}
glNewList(fp->bv[i].sl, GL_COMPILE);
{
- sol_shad_body(fp, fp->bv + i, M_SHADOWED);
+ sol_shad_body(fp, fp->bv+i, M_SHADOWED, 0);
+ sol_shad_body(fp, fp->bv+i, M_SHADOWED, M_DECAL);
}
glEndList();
}