}
rt::element* sphere = new rt::sphere(
vec_new((scal_t)x, (scal_t)y, (scal_t)z),
- (scal_t)radius,
- color_new((scal_t)r, (scal_t)g, (scal_t)b, S(1.0))
+ (scal_t)radius
);
+ sphere->material(color_new((scal_t)r, (scal_t)g, (scal_t)b, S(1.0)));
list_push2(&s->objects, sphere, DTOR(rt::sphere_destroy));
return 0;
}
}
rt::element* plane = new rt::plane(
vec_new((scal_t)x, (scal_t)y, (scal_t)z),
- vec_new((scal_t)nx, (scal_t)ny, (scal_t)nz),
- color_new((scal_t)r, (scal_t)g, (scal_t)b, S(1.0))
+ vec_new((scal_t)nx, (scal_t)ny, (scal_t)nz)
);
+ plane->material(color_new((scal_t)r, (scal_t)g, (scal_t)b, S(1.0)));
list_push2(&s->objects, plane, DTOR(rt::plane_destroy));
return 0;
}
rt::element* triangle = new rt::triangle(
vec_new((scal_t)x1, (scal_t)y1, (scal_t)z1),
vec_new((scal_t)x2, (scal_t)y2, (scal_t)z2),
- vec_new((scal_t)x3, (scal_t)y3, (scal_t)z3),
- color_new((scal_t)r, (scal_t)g, (scal_t)b, S(1.0))
+ vec_new((scal_t)x3, (scal_t)y3, (scal_t)z3)
);
+ triangle->material(color_new((scal_t)r, (scal_t)g, (scal_t)b, S(1.0)));
list_push2(&s->objects, triangle, DTOR(rt::triangle_destroy));
return 0;
}
/*raster_light(p, *(light_t*)i->val);*/
/*}*/
+ raster_t* texture = raster_import("texture.bmp");
+ if (texture == NULL) {
+ texture = raster_import("texture.ppm");
+ }
+
+ if (s->objects && texture != NULL) {
+ rt::element* obj = (rt::element*)s->objects->val;
+ obj->texture(texture);
+#if VERBOSITY >= 3
+ printf("Loaded texture file; will texture first scene object.\n");
+#endif
+ }
+
#if VERBOSITY >= 3
printf("rendering scene...\n");
#endif
printf("render complete!\ntime\t%.3fms\n", (float)dt / 1000.0f);
#endif
+ if (texture) {
+ raster_destroy(texture);
+ }
+
return p;
}