ccdemos/textures.cc
branchpyrit
changeset 88 f7edb3b90816
parent 81 9dbb9c8c115b
child 91 9d66d323c354
--- a/ccdemos/textures.cc	Sun Apr 27 22:55:17 2008 +0200
+++ b/ccdemos/textures.cc	Mon Apr 28 11:44:11 2008 +0200
@@ -1,7 +1,6 @@
 #include "raytracer.h"
 #include "octree.h"
 
-#include "image.h"
 #include "common_sdl.h"
 
 Camera cam(Vector3(0.,6.,6.), Vector3(0.,2.,-7.), Vector3(0.,0.,-1.));
@@ -141,26 +140,12 @@
 	if (argc == 2 && !strcmp(argv[1], "-r"))
 	{
 		pyrit_verbosity = 2;
-		Float *fdata = (Float *) malloc(w*h*3*sizeof(Float));
 		rt.ambientOcclusion(300, 5.0, 0.5);
-		DefaultSampler sampler(fdata, w, h);
+		DefaultSampler sampler(w, h);
 		sampler.setOversample(2);
 		sampler.setSubsample(1);
 		rt.setSampler(&sampler);
 		rt.render();
-
-		struct image *img;
-		new_image(&img, w, h, 3);
-
-		Float *fd = fdata;
-		for (unsigned char *cd = img->data; cd != img->data + w*h*3; cd++, fd++) {
-			if (*fd > 1.0)
-				*cd = 255;
-			else
-				*cd = (unsigned char)(*fd * 255.0);
-		}
-		free(fdata);
-		save_png("textures.png", img);
-		destroy_image(&img);
+		sampler.getPixmap().writePNG("textures.png");
 	}
 }