commit 6bd1181be5f6db0d50940addbdcfdea7ed1b7f3e Author: K Tyl Date: Sun May 31 23:52:34 2020 +0100 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..58797bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# output image +image.ppm + +# binary +flark + +# CMake +# https://github.com/github/gitignore/blob/master/CMake.gitignore +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2d6dd14 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.10) + +project(flark) + +add_executable(flark main.cpp) + diff --git a/README.md b/README.md new file mode 100644 index 0000000..0b3021b --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Flark + +Ray tracing rendering experiments + +https://raytracing.github.io/ diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..ac5f9e0 --- /dev/null +++ b/main.cpp @@ -0,0 +1,31 @@ +#include + +const int WIDTH = 256; +const int HEIGHT = 256; + +int main() +{ + std::cout << "P3" << std::endl; + std::cout << WIDTH << ' ' << HEIGHT << "\n255\n"; + + for (int y = HEIGHT - 1; y >= 0; --y) + { + std::cerr << "\rScanlines remaining: " << y << ' ' << std::flush; + + for (int x = 0; x < WIDTH; ++x) + { + double r = double(x) / (WIDTH - 1); + double g = double(y) / (HEIGHT - 1); + double b = 0.25; + + int ir = static_cast(255.999 * r); + int ig = static_cast(255.999 * g); + int ib = static_cast(255.999 * b); + + std::cout << ir << ' ' << ig << ' ' << ib << std::endl; + } + } + + std::cerr << "\nDone." << std::endl; +} +