summaryrefslogtreecommitdiff
path: root/main_simple_scanner.cpp
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-04-13 14:52:46 +0800
committerKeuin <[email protected]>2022-04-13 14:52:46 +0800
commitd802e8367e7709966747efbe57c90f1b8a08f83b (patch)
tree6d5501d32bbb8a5375ac7ba119c72c601070f4be /main_simple_scanner.cpp
parent3caba9694f6e6f0f8b51dcffd7619fa04fbe6c29 (diff)
Use basic_viewport8b if antialiasing is not enabled.
Diffstat (limited to 'main_simple_scanner.cpp')
-rw-r--r--main_simple_scanner.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/main_simple_scanner.cpp b/main_simple_scanner.cpp
index eaaa8b7..bd870d7 100644
--- a/main_simple_scanner.cpp
+++ b/main_simple_scanner.cpp
@@ -26,7 +26,12 @@ void generate_image(uint16_t image_width, uint16_t image_height, double viewport
std::cerr << "Antialiasing Samples: " << samples << std::endl;
}
double r = 1.0 * image_width / image_height;
- aa_viewport8b vp{viewport_width, viewport_width / r, vec3d{0, 0, -focal_length}, samples};
+ viewport8b *vp;
+ if (samples == 1) {
+ vp = new basic_viewport8b{viewport_width, viewport_width / r, vec3d{0, 0, -focal_length}};
+ } else {
+ vp = new aa_viewport8b{viewport_width, viewport_width / r, vec3d{0, 0, -focal_length}, samples};
+ }
hitlist8b world;
world.add_object(std::make_shared<sphere>(
vec3d{0, -100.5, -1},
@@ -34,8 +39,8 @@ void generate_image(uint16_t image_width, uint16_t image_height, double viewport
world.add_object(std::make_shared<sphere>(vec3d{0, 0, sphere_z}, sphere_r));
timer tm;
tm.start_measure();
- auto image = vp.render(world, vec3d::zero(),
- image_width, image_height); // camera position as the coordinate origin
+ auto image = vp->render(world, vec3d::zero(),
+ image_width, image_height); // camera position as the coordinate origin
tm.stop_measure();
if (!caption.empty()) {
image.print(caption,
@@ -47,6 +52,7 @@ void generate_image(uint16_t image_width, uint16_t image_height, double viewport
} else {
std::cerr << "NOPRINT is defined. PPM Image won't be printed." << std::endl;
}
+ delete vp;
}
int main(int argc, char **argv) {