Skip to content

Commit

Permalink
Improved failure handling
Browse files Browse the repository at this point in the history
Removed some warning causing code
  • Loading branch information
ChuzaWick420 committed Nov 24, 2024
1 parent 26c63b4 commit 644dbb2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
18 changes: 4 additions & 14 deletions src/headers/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/headers/sphere/sphere.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 644dbb2

Please sign in to comment.