diff --git a/CMakeLists.txt b/CMakeLists.txt index bfe05ea..717a41e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,30 +1,32 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.28 FATAL_ERROR) project(perlin-shadows) set(CMAKE_CXX_STANDARD 23) -include_directories(src) - link_libraries(-lGL -lglut -lGLEW -lGLU) -add_executable(perlin-shadows - src/constants.h - src/final.cpp - src/geography.cpp - src/geography.h - src/grid.cpp - src/grid.h - src/noise_math.h - src/renderer.cpp - src/renderer.h - src/camera.cpp - src/camera.h - src/shader.cpp - src/shader.h - src/point_light.cpp - src/point_light.h - src/renderable.cpp - src/renderable.h +add_executable(${CMAKE_PROJECT_NAME}) +target_sources(${CMAKE_PROJECT_NAME} + PRIVATE + src/constants.h + src/final.cpp + src/geography.cpp + src/geography.h + src/grid.cpp + src/grid.h + src/renderer.cpp + src/renderer.h + src/camera.cpp + src/camera.h + src/shader.cpp + src/shader.h + src/point_light.cpp + src/point_light.h + src/renderable.cpp + src/renderable.h + PRIVATE + FILE_SET modules TYPE CXX_MODULES FILES + src/noise.cppm ) file(READ src/shader/phong.vert PHONG_VERT) @@ -36,4 +38,5 @@ file(READ src/shader/shadow.frag SHADOW_FRAG) file(READ src/shader/shadow.geom SHADOW_GEOM) configure_file(src/point_light.in.h src/point_light.h @ONLY) +include_directories(src) target_include_directories(perlin-shadows PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/src") diff --git a/src/grid.cpp b/src/grid.cpp index 64fd085..8fea867 100644 --- a/src/grid.cpp +++ b/src/grid.cpp @@ -4,9 +4,11 @@ #include #include "constants.h" -#include "noise_math.h" + +import noise; using namespace std; +using namespace noise; random_device Grid::device_; default_random_engine::result_type Grid::base_random_{0}; diff --git a/src/noise_math.h b/src/noise.cppm similarity index 91% rename from src/noise_math.h rename to src/noise.cppm index b5d1d08..0c40e94 100644 --- a/src/noise_math.h +++ b/src/noise.cppm @@ -1,4 +1,6 @@ -#pragma once +export module noise; + +export namespace noise { // Based on Ken Perlin's smoother step function: // https://en.wikipedia.org/wiki/Smoothstep#Variations Returns value in range @@ -21,3 +23,5 @@ const float bound_1) { return bound_0 + SmootherStep(x) * (bound_1 - bound_0); } + +} // namespace noise