diff --git a/wtracer.cpp b/wtracer.cpp index fa40e3b..add0793 100644 --- a/wtracer.cpp +++ b/wtracer.cpp @@ -84,15 +84,6 @@ Hittable_list setup_random_scene(const int sph_i) { return world; } -struct render_params { - int image_width; - int image_height; - int samples_per_pixel; - int max_depth; - Hittable_list& world; - Camera& cam; -}; - struct render_tile { int start_x; int start_y; @@ -100,41 +91,6 @@ struct render_tile { int end_y; }; -void split_line(const int& line_length, int& start, int& end) { -#ifdef _OPENMP - const int line_length_thread = static_cast(line_length/omp_get_num_threads()); - start = omp_get_thread_num() * line_length_thread; - end = std::min((omp_get_thread_num()+1) * line_length_thread, line_length); -#else - start = 0; - end = line_length; -#endif -} - -void render(boost::lockfree::queue& queue, - std::atomic& queue_counter, - const render_params& params, std::vector& image) { - render_tile rt; - while (queue.pop(rt)) { - --queue_counter; - int qc = queue_counter; - printf("\rTiles remaining: %4d", qc); - std::cout << std::flush; - for (int i = rt.start_x; i queue_counter; boost::lockfree::queue queue(0); @@ -194,7 +141,25 @@ int main() { #pragma omp parallel { - render(queue, queue_counter, params, image); + render_tile rt; + while (queue.pop(rt)) { + --queue_counter; + int qc = queue_counter; + printf("\rTiles remaining: %4d", qc); + std::cout << std::flush; + for (int i = rt.start_x; i