If the width and heigth are not equal, then the image will be stretched. This is because the viewport size if fixed to 30 "units" from -15 to 15, and the world is fit within the viewport. The bad code is in trace_rays() where dx and dy are initialized.
102 max_x = 15; |
104 max_y = 15; |
105 min_y = -max_y; |
106 |
107 // dx and dy are the amount to add to each pixel to go to the next pixel |
108 double dx = (max_x - min_x) / scene->get_viewport_pixel_width(); |
109 double dy = (max_y - min_y) / scene->get_viewport_pixel_height(); |
the max and min should be functions of the world height adn width, not constants.