]> Dogcows Code - chaz/rasterize/commitdiff
make animate script work for modern luas master
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 1 Dec 2021 19:00:57 +0000 (12:00 -0700)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Wed, 1 Dec 2021 19:03:10 +0000 (12:03 -0700)
Makefile
README
animate.lua
raster.c

index d361c49d719b3d7cfe5a69a3f468c67c729d14b4..1dee42f0110eb896d8a4ce9ca83d0d0d5b159b00 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ IUSE    = BACKFACE_CULLING BLENDING DEPTH_TEST EXTRA_INLINE NDEBUG \
 VIEWER  = feh
 
 CC      = gcc
 VIEWER  = feh
 
 CC      = gcc
+EXEEXT  =
 CFLAGS  = -std=c99 -O2 -g -pg
 CPPFLAGS= -MMD $(IUSE:%=-D%)
 LDLIBS  = -lm
 CFLAGS  = -std=c99 -O2 -g -pg
 CPPFLAGS= -MMD $(IUSE:%=-D%)
 LDLIBS  = -lm
@@ -13,14 +14,15 @@ LDLIBS  = -lm
 SRCS    = main.c array.c common.c list.c model.c raster.c rbtree.c scene.c
 OBJS    = $(SRCS:%.c=%.o)
 DEPS    = $(OBJS:%.o=%.d)
 SRCS    = main.c array.c common.c list.c model.c raster.c rbtree.c scene.c
 OBJS    = $(SRCS:%.c=%.o)
 DEPS    = $(OBJS:%.o=%.d)
+PROG    = $(PROJECT)$(EXEEXT)
 
 
-all: $(PROJECT)
+all: $(PROG)
 
 
-$(PROJECT): $(OBJS)
+$(PROG): $(OBJS)
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 clean:
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
 
 clean:
-       rm -f $(PROJECT) $(OBJS) $(DEPS)
+       rm -f $(PROG) $(OBJS) $(DEPS)
 
 distclean: clean
        rm -f tags gmon.out
 
 distclean: clean
        rm -f tags gmon.out
@@ -31,10 +33,10 @@ realclean: distclean
 dist:
        git archive HEAD --prefix=$(PROJECT)/ --output=$(PROJECT).zip
 
 dist:
        git archive HEAD --prefix=$(PROJECT)/ --output=$(PROJECT).zip
 
-run: $(PROJECT)
+run: $(PROG)
        ./$< && $(VIEWER) scene.ppm
 
        ./$< && $(VIEWER) scene.ppm
 
-debug: $(PROJECT)
+debug: $(PROG)
        gdb ./$<
 
 -include $(DEPS)
        gdb ./$<
 
 -include $(DEPS)
diff --git a/README b/README
index 4a1a889abe3058c2af096df026dfd84b5b8872fc..4a614ea44d8e5ce97ccafe95a1120e1a98ad7bca 100644 (file)
--- a/README
+++ b/README
@@ -8,8 +8,27 @@ Project 3 Notes
 To build, just `make' it.  You will need GNU make; it won't work well with any
 other kind of make(1).  Once built, the executable is called rasterize.
 
 To build, just `make' it.  You will need GNU make; it won't work well with any
 other kind of make(1).  Once built, the executable is called rasterize.
 
+Caveats:
+
+1. I happened to do Phong interpolation a little differently (i.e. not as
+good) compared to what is described in the project handout.  Instead of
+calculating the lighting vectors in eye-coordinates, I did it all in world
+coordinates.  So I had to save the camera position (already in world
+coordinates) from the scene file and transform each point vector of the
+geometry by just the view matrix.  Anyway, the results look a little bit
+different than the provide images, so maybe I didn't do it quite right.
+
+2. Contrary to the specification, the geometry color is not overridden by a
+texture map in this implementation.  Rather, the geometry color is
+multiplied by the texture color, so blending can work with texture mapping.
+
+3. The PPM importer doesn't handle comments, and the BMP importer is also
+quite picky about the depth and color space, though importing will fail
+without any useful explanation.
+
 Known to run on:
 Known to run on:
- * Linux 3.2.1-gentoo
- * NetBSD 5.1.2
+ * Linux 3.2.1-gentoo (x86_64)
+ * NetBSD 5.1.2 (amd64)
  * Darwin 10.8.0 (in the Mac lab)
  * Darwin 10.8.0 (in the Mac lab)
+ * Win32 (tried with i686-mingw32-gcc)
 
 
index 616c717f4eb51ff396a343b5a2759ef90faf35d8..ae3ff24e464dd4dd6cf3c9b12f0106dbd91a07b3 100755 (executable)
@@ -109,7 +109,7 @@ X
         i = coroutine.yield()
         out:close()
         if 1 < supersample and
         i = coroutine.yield()
         out:close()
         if 1 < supersample and
-                run("convert %s -scale %dx%d %s", filename, size.w, size.h, filename) ~= 0 then
+                not run("convert %s -scale %dx%d %s", filename, size.w, size.h, filename) then
             print()
             os.exit(1)
         end
             print()
             os.exit(1)
         end
@@ -140,7 +140,7 @@ for render,frame in renderings() do render(frame) end
 
 print()
 
 
 print()
 
-if run("ffmpeg -i frames/anim%%04d.bmp %s -y -an scene.avi", ffmpeg_opts) == 0 then
+if run("ffmpeg -i frames/anim%%04d.bmp %s -y -an scene.avi", ffmpeg_opts) then
     print("Animation written to scene.avi.")
 else
     print("The animation could not be created. Is ffmpeg installed?")
     print("Animation written to scene.avi.")
 else
     print("The animation could not be created. Is ffmpeg installed?")
index 9ab926a0a30030374bd0b695c5b0e990b6fc8386..9cb12c5637f64694fdf9c2631eec65b1b36e0d9f 100644 (file)
--- a/raster.c
+++ b/raster.c
@@ -305,14 +305,15 @@ raster_t* raster_import_ppm(const char* filename)
 
     for (int y = h - 1; y >= 0; --y) {
         for (int x = 0; x < w; ++x) {
 
     for (int y = h - 1; y >= 0; --y) {
         for (int x = 0; x < w; ++x) {
-            rgbachan_t r, g, b;
-            if (fscanf(file, "%hhu %hhu %hhu ", &r, &g, &b) != 3) {
+            uint16_t r, g, b;
+            /* mingw32 does not like %hhu conversion type */
+            if (fscanf(file, "%hu %hu %hu ", &r, &g, &b) != 3) {
                 fprintf(stderr, "Failed reading color values from %s: %s\n", filename, strerror(errno));
                 return NULL;
             }
                 fprintf(stderr, "Failed reading color values from %s: %s\n", filename, strerror(errno));
                 return NULL;
             }
-            rgba_t rgba = PACK(rgba, 3, r);
-            rgba = PACK(rgba, 2, g);
-            rgba = PACK(rgba, 1, b);
+            rgba_t rgba = PACK(rgba, 3, (uint8_t)r);
+            rgba = PACK(rgba, 2, (uint8_t)g);
+            rgba = PACK(rgba, 1, (uint8_t)b);
             rgba = PACK(rgba, 0, 255);
             p->pixels[y * w + x] = color_from_rgba(rgba);
         }
             rgba = PACK(rgba, 0, 255);
             p->pixels[y * w + x] = color_from_rgba(rgba);
         }
This page took 0.024684 seconds and 4 git commands to generate.