diff --git a/src/charles.cc b/src/charles.cc index 975ef9f..ca2c48c 100644 --- a/src/charles.cc +++ b/src/charles.cc @@ -8,6 +8,9 @@ #include #include "basics.h" +#include "object_sphere.h" +#include "scene.h" +#include "writer_png.h" const char *OUT_FILE = "charles_out.png"; @@ -16,50 +19,21 @@ int main(int argc, const char *argv[]) { -#if 0 - FILE *out_file = fopen(OUT_FILE, "wb"); - if (!out_file) { - return -1; - } + Scene scene = Scene(); - Scene *scene = scene_init(); + // Make some spheres. + Sphere *s1 = new Sphere(Vector3(233, 290, 0), 100.0); + Sphere *s2 = new Sphere(Vector3(407, 290, 0), 100.0); + Sphere *s3 = new Sphere(Vector3(320, 140, 0), 100.0); + scene.add_shape(s1); + scene.add_shape(s2); + scene.add_shape(s3); - Object *obj = object_init(ObjectTypeSphere); - Texture *tex = texture_init(); - Color color = {255, 0, 0, 255}; - texture_set_color(tex, color); - object_set_texture(obj, tex); - Vector3 loc = {233, 290, 0}; - object_set_location(obj, loc); - object_sphere_set_radius(obj, 100); - scene_add_object(scene, obj); + // Render. + scene.render(); - obj = object_init(ObjectTypeSphere); - tex = texture_init(); - Color color2 = {0, 255, 0, 255}; - texture_set_color(tex, color2); - object_set_texture(obj, tex); - loc = vector_init(407, 290, 0); - object_set_location(obj, loc); - object_sphere_set_radius(obj, 100); - scene_add_object(scene, obj); - - obj = object_init(ObjectTypeSphere); - tex = texture_init(); - Color color3 = {0, 0, 255, 255}; - texture_set_color(tex, color3); - object_set_texture(obj, tex); - loc = vector_init(320, 140, 0); - object_set_location(obj, loc); - object_sphere_set_radius(obj, 100); - scene_add_object(scene, obj); - - scene_render(scene); - write_scene_png(scene, out_file); - - scene_destroy(scene); - fclose(out_file); -#endif + Writer *writer = new PNGWriter(); + scene.write(*writer, OUT_FILE); return 0; }