diff --git a/Makefile b/Makefile index 3a50d22..cc4f0df 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CXX = g++ -CXXFLAGS = -Wall -Wextra -O2 -std=c++14 +CXXFLAGS = -std=c++14 -Wall -Wextra -march=native -Ofast -fopenmp -flto DEPS = util.h vec3.h color.h ray.h camera.h hittable.h hittable_list.h sphere.h OBJ = wtracer.o diff --git a/wtracer.cpp b/wtracer.cpp index cf70ca0..f21d0ad 100644 --- a/wtracer.cpp +++ b/wtracer.cpp @@ -27,7 +27,8 @@ Color ray_color(const Ray& r, const Hittable& world, int depth) { int main() { const auto aspect_ratio = 16.0 / 9.0; //const int image_width = 1280; - const int image_width = 384; + const int image_width = 768; + //const int image_width = 384; const int image_height = static_cast(image_width / aspect_ratio); const int samples_per_pixel = 250; const int max_depth = 50; @@ -40,8 +41,11 @@ int main() { Camera cam; + Color* image = new Color[image_height*image_width]; + for (int j = image_height - 1; j >= 0; --j) { std::cerr << "\rScanlines remaining: " << j << " " << std::flush; + #pragma omp parallel for for (int i = 0; i < image_width; ++i) { Color pixel_color(0, 0, 0); for (int s = 0; s= 0; --j) { + for (int i = 0; i < image_width; ++i) { + write_color(std::cout, image[i*image_height+j], samples_per_pixel); + } + } + delete[] image; + std::cerr << "Done.\n"; }