projects
/
csgray
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added scene loading
[csgray]
/
src
/
main.c
diff --git
a/src/main.c
b/src/main.c
index
d6aac1c
..
6e69844
100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-16,6
+16,7
@@
static int parse_opt(int argc, char **argv);
static int width = DFL_WIDTH, height = DFL_HEIGHT;
static float inv_gamma = 1.0f / DFL_GAMMA;
static const char *out_fname = DFL_OUTFILE;
static int width = DFL_WIDTH, height = DFL_HEIGHT;
static float inv_gamma = 1.0f / DFL_GAMMA;
static const char *out_fname = DFL_OUTFILE;
+static const char *in_fname;
int main(int argc, char **argv)
{
int main(int argc, char **argv)
{
@@
-30,27
+31,44
@@
int main(int argc, char **argv)
return 1;
}
return 1;
}
+ if(csg_load(in_fname) == -1) {
+ return 1;
+ }
+
if(!(pixels = malloc(width * height * 3 * sizeof *pixels))) {
perror("failed to allocate framebuffer");
return 1;
}
if(!(pixels = malloc(width * height * 3 * sizeof *pixels))) {
perror("failed to allocate framebuffer");
return 1;
}
+ /*
csg_view(0, 0, 5, 0, 0, 0);
oa = csg_sphere(0, 0, 0, 1);
csg_color(oa, 1, 0.1, 0.05);
csg_view(0, 0, 5, 0, 0, 0);
oa = csg_sphere(0, 0, 0, 1);
csg_color(oa, 1, 0.1, 0.05);
+ csg_roughness(oa, 0.3);
ob = csg_sphere(0.3, 0.7, 0.7, 0.7);
csg_color(ob, 0.2, 0.3, 1);
ob = csg_sphere(0.3, 0.7, 0.7, 0.7);
csg_color(ob, 0.2, 0.3, 1);
+ csg_roughness(ob, 0.3);
+ oc = csg_subtraction(oa, ob);
+
+ oa = oc;
+
+ ob = csg_sphere(-0.9, -0.1, 0.7, 0.5);
+ csg_color(ob, 1, 0.9, 0.2);
+ csg_roughness(ob, 0.3);
+
oc = csg_subtraction(oa, ob);
oc = csg_subtraction(oa, ob);
+
csg_add_object(oc);
obj = csg_plane(0, -1, 0, 0, 1, 0);
csg_color(obj, 0.4, 0.7, 0.4);
csg_add_object(obj);
csg_add_object(oc);
obj = csg_plane(0, -1, 0, 0, 1, 0);
csg_color(obj, 0.4, 0.7, 0.4);
csg_add_object(obj);
- obj = csg_null(-6, 10, 10);
+ obj = csg_null(-4, 10, 10);
csg_emission(obj, 80, 80, 80);
csg_add_object(obj);
csg_emission(obj, 80, 80, 80);
csg_add_object(obj);
+ */
csg_render_image(pixels, width, height);
save_image(out_fname, pixels, width, height);
csg_render_image(pixels, width, height);
save_image(out_fname, pixels, width, height);
@@
-138,9
+156,18
@@
static int parse_opt(int argc, char **argv)
return -1;
}
} else {
return -1;
}
} else {
- fprintf(stderr, "unexpected argument: %s\n", argv[i]);
- return -1;
+ if(in_fname) {
+ fprintf(stderr, "unexpected argument: %s\n", argv[i]);
+ return -1;
+ }
+ in_fname = argv[i];
}
}
}
}
+
+ if(!in_fname) {
+ fprintf(stderr, "you need to pass a scene file to read\n");
+ return -1;
+ }
+
return 0;
}
return 0;
}