~turminal/raytracing

7459993ebb255d3a374baa2444b811fd16511416 — Bor Grošelj Simić 2 years ago 1a6aa74
initialize random generator in main
2 files changed, 3 insertions(+), 4 deletions(-)

M main.ha
M util.ha
M main.ha => main.ha +3 -0
@@ 1,5 1,6 @@
use fmt;
use math;
use math::random;
use os;
use time;



@@ 44,6 45,8 @@ fn compute_color(scene: *hittable, r: *ray, depth: uint) color = {
};

export fn main() void = {
	rng = math::random::init(1);

	let width = 800z, height = 600z;
	let img = image_create(width, height, C(0f64, 0f64, 0f64));
	defer image_free(img);

M util.ha => util.ha +0 -4
@@ 3,10 3,6 @@ use types;

let rng: math::random::random = 0u64;

@init fn random_init() void = {
	rng = math::random::init(2);
};

export fn random(min: f64, max: f64) f64 = {
	// TODO: drop the signed cast
	let n = math::random::next(&rng);