-
Notifications
You must be signed in to change notification settings - Fork 941
Closed
Description
I've just started reading/implementing Ray Tracing in One Weekend and already stumbled upon this problem. This is my c++ code:
int main() {
const int image_width = 256;
const int image_height = 256;
std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";
for (int y = image_height-1; y >= 0; --y) {
std::cerr << "\rScanlines remaining: " << y << ' ' << std::flush;
for (int x = 0; x < image_width; ++x) {
auto r = double(x) / (image_width-1);
auto g = double(y) / (image_height-1);
auto b = 0.25;
int ir = static_cast<int>(255.999 * r);
int ig = static_cast<int>(255.999 * g);
int ib = static_cast<int>(255.999 * b);
std::cout << ir << ' ' << ig << ' ' << ib << '\n';
}
}
}
And this is the output in the .ppm file:
P3
256 256
255
0 255 63
1 255 63
2 255 63
3 255 63
4 255 63
5 255 63
6 255 63
7 255 63
8 255 63
9 255 63
10 255 63
...
Tried opening this with Gimp, XNView and IrfanView but they all can't seem to read the file.