aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt7
-rw-r--r--src/main.cpp37
3 files changed, 45 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..7da22d4
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.10)
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
+
+project(path-tracer VERSION 1.0)
+
+add_executable(path-tracer src/main.cpp)
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..2cd66a9
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,37 @@
+#include <iostream>
+
+int main() {
+ size_t width = 256;
+ size_t height = 256;
+
+ // PPM format header
+ std::cout << "P3" << std::endl;
+
+ std::cout << width << std::endl;
+ std::cout << height << std::endl;
+
+ // Max color
+ std::cout << "255" << std::endl;
+
+ std::cerr << "Generating image" << std::endl;
+
+ for (size_t column = 0; column < width; column++) {
+ std::cerr << width - column << " lines remaining" << std::endl;
+
+ for (size_t row = 0; row < height; row++) {
+ auto r = double(column) / (width-1);
+ auto g = double(row) / (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';
+ }
+ }
+
+ std::cerr << "Done !" << std::endl;
+
+ return 0;
+}