--- a/include/raytracer.h Fri Mar 28 00:53:20 2008 +0100
+++ b/include/raytracer.h Fri Mar 28 17:13:21 2008 +0100
@@ -28,6 +28,7 @@
#define RAYTRACER_H
#include <vector>
+#include <queue>
#include "common.h"
#include "container.h"
@@ -60,9 +61,30 @@
int max_depth;
Vector3 SphereDistribute(int i, int n, Float extent, Vector3 &normal);
+
+ queue<Sample*> sample_queue;
+ bool sample_queue_end;
+ pthread_mutex_t sample_queue_mutex, sampler_mutex;
+ pthread_cond_t sample_queue_cond, worker_ready_cond;
+
+ static void *raytrace_worker(void *d);
public:
Raytracer(): top(NULL), camera(NULL), lights(), bg_colour(0.0, 0.0, 0.0),
- ao_samples(0), num_threads(2), max_depth(3) {};
+ ao_samples(0), num_threads(2), max_depth(3)
+ {
+ pthread_mutex_init(&sample_queue_mutex, NULL);
+ pthread_mutex_init(&sampler_mutex, NULL);
+ pthread_cond_init (&sample_queue_cond, NULL);
+ pthread_cond_init (&worker_ready_cond, NULL);
+ };
+ ~Raytracer()
+ {
+ pthread_mutex_destroy(&sample_queue_mutex);
+ pthread_mutex_destroy(&sampler_mutex);
+ pthread_cond_destroy (&sample_queue_cond);
+ pthread_cond_destroy (&worker_ready_cond);
+ }
+
void render();
Colour raytrace(Ray &ray, int depth, Shape *origin_shape);
void addshape(Shape *shape) { top->addShape(shape); };