aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-03-23 15:56:54 +0100
committerJulian T <julian@jtle.dk>2020-03-23 15:56:54 +0100
commit6ae610fd7f28ba5ba7a8e0233cd6fb0ac5df4a8b (patch)
tree389c8ca1ea81b0a32a9e6cbd60456e075914eb17 /main.c
parent6ca75e5d27980e082d977ffdb9a93589b55961ce (diff)
Random is generated by user defined function
Diffstat (limited to 'main.c')
-rw-r--r--main.c11
1 files changed, 10 insertions, 1 deletions
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);