diff --git a/src/headers/camera/camera.cpp b/src/headers/camera/camera.cpp index 521c51d..582f8a4 100644 --- a/src/headers/camera/camera.cpp +++ b/src/headers/camera/camera.cpp @@ -13,26 +13,12 @@ void camera::show_img() { float scalar = float(window_width) / img_width; - /*int index = 1;*/ - /**/ - /*for (auto pixel : pixel_grid) {*/ - /* int x = (index - 1) % img_width;*/ - /* int y = (index - 1) / img_width;*/ - /* i_image.setPixel(x, y, pixel);*/ - /**/ - /* index++;*/ - /*}*/ - sf::Texture t_image; t_image.loadFromImage(i_image); sf::Sprite s_image(t_image); s_image.setScale(sf::Vector2f(scalar, scalar)); - // optionally save the image - if (this->img_gen == true) - i_image.saveToFile("rendered_img.png"); - while (window.isOpen()){ sf::Event event; @@ -79,6 +65,10 @@ void camera::render(const hittable& world) { index++; } + // optionally save the image + if (this->img_gen == true) + i_image.saveToFile("rendered_img.png"); + std::clog << "done\n"; this->show_img(); diff --git a/src/headers/sphere/sphere.hpp b/src/headers/sphere/sphere.hpp index 7d6ad23..026a737 100644 --- a/src/headers/sphere/sphere.hpp +++ b/src/headers/sphere/sphere.hpp @@ -14,7 +14,7 @@ class sphere : public hittable { {} - bool sphere::hit(const ray& r, interval ray_t, hit_record& rec) const override { + bool hit(const ray& r, interval ray_t, hit_record& rec) const override { vec3 oc = center - r.origin(); auto a = r.direction().length_squared(); auto h = dot(r.direction(), oc); diff --git a/src/main.cpp b/src/main.cpp index 628369a..13ad58c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,7 +57,7 @@ int main () { cam.aspect_ratio = 16.0 / 9.0; cam.img_width = 1024; - cam.samples_per_pixel = 50; + cam.samples_per_pixel = 200; cam.max_depth = 50; cam.img_gen = true;