Modified material sorter to draw opaque decals AFTER opaque textures, and transparent...
authorrlk <rlk@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Sun, 23 Dec 2007 19:48:11 +0000 (19:48 +0000)
committerrlk <rlk@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Sun, 23 Dec 2007 19:48:11 +0000 (19:48 +0000)
Removed TGA search from mapc.
Modified subdirectory Makefiles to transmit the target specification to the root Makefile.

git-svn-id: https://s.snth.net/svn/neverball/trunk@1283 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/Makefile
putt/Makefile
share/Makefile
share/mapc.c
share/solid_gl.c

index 20957f3..460617d 100644 (file)
@@ -1,11 +1,5 @@
 # This makefile only exists so that I can run emacs M-x compile from within
 # the source directory.  See the Makefile in the parent directory
 
-all :
-       (cd ..; $(MAKE))
-
-clean :
-       (cd ..; $(MAKE) clean)
-
-test :
-       (cd ..; $(MAKE) test)
+% :
+       $(MAKE) -C .. $@
index 20957f3..460617d 100644 (file)
@@ -1,11 +1,5 @@
 # This makefile only exists so that I can run emacs M-x compile from within
 # the source directory.  See the Makefile in the parent directory
 
-all :
-       (cd ..; $(MAKE))
-
-clean :
-       (cd ..; $(MAKE) clean)
-
-test :
-       (cd ..; $(MAKE) test)
+% :
+       $(MAKE) -C .. $@
index 20957f3..460617d 100644 (file)
@@ -1,11 +1,5 @@
 # This makefile only exists so that I can run emacs M-x compile from within
 # the source directory.  See the Makefile in the parent directory
 
-all :
-       (cd ..; $(MAKE))
-
-clean :
-       (cd ..; $(MAKE) clean)
-
-test :
-       (cd ..; $(MAKE) test)
+% :
+       $(MAKE) -C .. $@
index 9f2887b..d532094 100644 (file)
@@ -334,7 +334,6 @@ static int size_load(const char *file, int *w, int *h)
 static void size_image(const char *name, int *w, int *h)
 {
     char jpg[MAXSTR];
-    char tga[MAXSTR];
     char png[MAXSTR];
     int i;
 
@@ -352,11 +351,9 @@ static void size_image(const char *name, int *w, int *h)
     *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))
     {
 
@@ -1913,15 +1910,17 @@ static void uniq_side(struct s_file *fp)
 
 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);
+    }
 }
 
 /*---------------------------------------------------------------------------*/
@@ -2186,11 +2185,6 @@ static void dump_file(struct s_file *p, const char *name)
            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];
index 23cc94e..679ce56 100644 (file)
@@ -103,14 +103,6 @@ static void sol_draw_mtrl(const struct s_file *fp, int i)
         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,
@@ -232,14 +224,20 @@ static void sol_draw_lump(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))
             {
@@ -259,6 +257,9 @@ static void sol_draw_body(const struct s_file *fp,
                 glEnd();
             }
         }
+
+    if (decal)
+        glDisable(GL_POLYGON_OFFSET_FILL);
 }
 
 static void sol_draw_list(const struct s_file *fp,
@@ -361,10 +362,16 @@ static void sol_shad_lump(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++)
@@ -377,6 +384,9 @@ static void sol_shad_body(const struct s_file *fp,
             }
     }
     glEnd();
+
+    if (decal)
+        glDisable(GL_POLYGON_OFFSET_FILL);
 }
 
 static void sol_shad_list(const struct s_file *fp,
@@ -443,11 +453,13 @@ static void sol_load_objects(struct s_file *fp, int s)
 {
     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))
         {
@@ -455,13 +467,14 @@ static void sol_load_objects(struct s_file *fp, int s)
 
             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))
         {
@@ -469,7 +482,8 @@ static void sol_load_objects(struct s_file *fp, int s)
 
             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();
         }
@@ -483,7 +497,7 @@ static void sol_load_objects(struct s_file *fp, int s)
 
             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();
         }
@@ -497,7 +511,8 @@ static void sol_load_objects(struct s_file *fp, int s)
 
             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();
         }