From 6ae610fd7f28ba5ba7a8e0233cd6fb0ac5df4a8b Mon Sep 17 00:00:00 2001 From: Julian T Date: Mon, 23 Mar 2020 15:56:54 +0100 Subject: Random is generated by user defined function --- main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 1ea89fa..36a9372 100644 --- a/main.c +++ b/main.c @@ -12,6 +12,12 @@ char container[ CONTAINER_SIZE(5, 4, 1) ]; +// Implement random +COORD_T ray_rand(void *seed) +{ + return (COORD_T) rand_r( (int *)seed ) / RAND_MAX; +} + int main() { @@ -81,10 +87,13 @@ int main() // Height percentage unsigned percentstep = TESTH / 100; unsigned percent = 0; + int seed; for (int y = TESTH; y; y--) { for (int x = TESTW; x; x--) { - color_t *c = ray_trace(&cont->space, x, y, 2); + // Random seed + seed = x * y; + color_t *c = ray_trace(&cont->space, x, y, 2, &seed); if (c) { pgm_write_pixel(stdout, c); -- cgit v1.2.3