From 6ee08c8370f578e59dd4c6bb5f542b469f0d3748 Mon Sep 17 00:00:00 2001 From: Julian T Date: Tue, 10 Mar 2020 08:55:59 +0100 Subject: Fixed color_set --- main.c | 6 +++--- pgm.c | 2 +- pgm.h | 2 +- test.png | Bin 60983 -> 65535 bytes 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main.c b/main.c index d1b8080..dcc824b 100644 --- a/main.c +++ b/main.c @@ -55,13 +55,13 @@ int main() add_sphere(&s, vector_set(NULL, 8, 8, 3), 2, &m2); add_plane(&s, vector_set(NULL, 0, 0, 2), vector_set(NULL, 0, 0, 1), &mpl); //add_plane(&s, vector_set(NULL, 0, -20, 0), vector_set(NULL, 0, 1, 0), &mpl); - add_light(&s, vector_set(NULL, 20, 10, 30), color_set(NULL, 1, 1, 1), color_set(NULL, 0.5, 0.5, 0.5)); - //add_light(&s, vector_set(NULL, 0, 10, 20), color_set(NULL, 255, 255, 255), color_set(NULL, 150, 150, 150)); + add_light(&s, vector_set(NULL, 20, 10, 30), color_set(NULL, 0.2, 0.2, 0.2), color_set(NULL, 0.5, 0.5, 0.5)); + add_light(&s, vector_set(NULL, 0, 10, 20), color_set(NULL, 0.5, 0.5, 0.5), color_set(NULL, 0.5, 0.5, 0.5)); pgm_write_header(stdout, TESTW, TESTH); for (int y = TESTH; y; y--) { for (int x = TESTW; x; x--) { - color_t *c = ray_trace(&s, x, y, 8); + color_t *c = ray_trace(&s, x, y, 2); if (c) { pgm_write_pixel(stdout, c); diff --git a/pgm.c b/pgm.c index 654f4b7..a1d3124 100644 --- a/pgm.c +++ b/pgm.c @@ -15,7 +15,7 @@ int pgm_write_pixel(FILE *fp, color_t *c) return fprintf(fp, "%.0lf %.0lf %.0lf\n", c->r * COLOR_MAX, c->g * COLOR_MAX, c->b * COLOR_MAX); } -color_t *color_set(color_t *c, uint8_t r, uint8_t g, uint8_t b) +color_t *color_set(color_t *c, COORD_T r, COORD_T g, COORD_T b) { if (!c) { c = (color_t *) malloc(sizeof(color_t)); diff --git a/pgm.h b/pgm.h index fbd7f73..5a6621d 100644 --- a/pgm.h +++ b/pgm.h @@ -9,7 +9,7 @@ typedef struct { COORD_T r, g, b; } color_t; -color_t *color_set(color_t *c, uint8_t r, uint8_t g, uint8_t b); +color_t *color_set(color_t *c, COORD_T r, COORD_T g, COORD_T b); color_t *color_scale(color_t *dest, color_t *a, COORD_T b); color_t *color_add(color_t *dest, color_t *a, color_t *b); color_t *color_scale_vector(color_t *dest, color_t *a, vector_t *v); diff --git a/test.png b/test.png index 03b64fb..086018d 100644 Binary files a/test.png and b/test.png differ -- cgit v1.2.3