Update main() for C++
This commit is contained in:
parent
b42a756042
commit
c9b130c121
1 changed files with 15 additions and 41 deletions
|
@ -8,6 +8,9 @@
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#include "basics.h"
|
#include "basics.h"
|
||||||
|
#include "object_sphere.h"
|
||||||
|
#include "scene.h"
|
||||||
|
#include "writer_png.h"
|
||||||
|
|
||||||
const char *OUT_FILE = "charles_out.png";
|
const char *OUT_FILE = "charles_out.png";
|
||||||
|
|
||||||
|
@ -16,50 +19,21 @@ int
|
||||||
main(int argc,
|
main(int argc,
|
||||||
const char *argv[])
|
const char *argv[])
|
||||||
{
|
{
|
||||||
#if 0
|
Scene scene = Scene();
|
||||||
FILE *out_file = fopen(OUT_FILE, "wb");
|
|
||||||
if (!out_file) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
// Render.
|
||||||
Texture *tex = texture_init();
|
scene.render();
|
||||||
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);
|
|
||||||
|
|
||||||
obj = object_init(ObjectTypeSphere);
|
Writer *writer = new PNGWriter();
|
||||||
tex = texture_init();
|
scene.write(*writer, OUT_FILE);
|
||||||
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
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue