diff options
author | Julian T <julian@jtle.dk> | 2020-03-23 15:56:54 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-03-23 15:56:54 +0100 |
commit | 6ae610fd7f28ba5ba7a8e0233cd6fb0ac5df4a8b (patch) | |
tree | 389c8ca1ea81b0a32a9e6cbd60456e075914eb17 /main.c | |
parent | 6ca75e5d27980e082d977ffdb9a93589b55961ce (diff) |
Random is generated by user defined function
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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); |