[FEAT] Use CPM and catch2 has library
This commit is contained in:
13
.vscode/settings.json
vendored
13
.vscode/settings.json
vendored
@@ -108,6 +108,17 @@
|
|||||||
"/home/jbnadal/sources/jb/raytracer_challenge/build/apps/CMakeFiles/chapter_11_p1.dir",
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/apps/CMakeFiles/chapter_11_p1.dir",
|
||||||
"/home/jbnadal/sources/jb/raytracer_challenge/build/apps/CMakeFiles/chapter_11_p2.dir",
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/apps/CMakeFiles/chapter_11_p2.dir",
|
||||||
"/home/jbnadal/sources/jb/raytracer_challenge/build/apps/CMakeFiles/chapter_12.dir",
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/apps/CMakeFiles/chapter_12.dir",
|
||||||
"/home/jbnadal/sources/jb/raytracer_challenge/build/tests/CMakeFiles/raytracing_test.dir"
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/tests/CMakeFiles/raytracing_test.dir",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2.dir/catch2/benchmark",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2.dir/catch2/benchmark/detail",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2.dir/catch2/generators",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2.dir/catch2/reporters",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2.dir/catch2/interfaces",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2.dir/catch2",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2.dir/catch2/internal",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2.dir/catch2/matchers",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2.dir/catch2/matchers/internal",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2.dir/../../catch2-build/generated-includes/catch2",
|
||||||
|
"/home/jbnadal/sources/jb/raytracer_challenge/build/build/_deps/catch2-src/src/CMakeFiles/Catch2WithMain.dir/catch2/internal"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,8 @@ project(raytracing_challenge
|
|||||||
DESCRIPTION "Raytracing Challenge in C++"
|
DESCRIPTION "Raytracing Challenge in C++"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
include(cmake/CPM.cmake)
|
||||||
|
|
||||||
find_package(OpenMP)
|
find_package(OpenMP)
|
||||||
|
|
||||||
add_subdirectory(raytracing)
|
add_subdirectory(raytracing)
|
||||||
|
|||||||
5
Doc.md
5
Doc.md
@@ -4,3 +4,8 @@ https://lire.amazon.fr/?asin=B07Q84TQ91&ref_=kwl_kr_iv_rec_1
|
|||||||
|
|
||||||
|
|
||||||
https://github.com/sraaphorst/raytracer-cpp/blob/b57794ce9f4ed80d782711adb9131f3e3097d4b0/CMakeLists.txt
|
https://github.com/sraaphorst/raytracer-cpp/blob/b57794ce9f4ed80d782711adb9131f3e3097d4b0/CMakeLists.txt
|
||||||
|
|
||||||
|
|
||||||
|
# package deps
|
||||||
|
|
||||||
|
https://github.com/cpm-cmake/CPM.cmake
|
||||||
@@ -8,22 +8,22 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
|
|
||||||
|
|
||||||
add_executable(chapter_05 chapter_05.cpp)
|
add_executable(chapter_05 chapter_05.cpp)
|
||||||
target_link_libraries(chapter_05 PRIVATE raytracing gcov OpenMP::OpenMP_CXX)
|
target_link_libraries(chapter_05 PRIVATE raytracing OpenMP::OpenMP_CXX)
|
||||||
|
|
||||||
add_executable(chapter_06 chapter_06.cpp)
|
add_executable(chapter_06 chapter_06.cpp)
|
||||||
target_link_libraries(chapter_06 PRIVATE raytracing gcov OpenMP::OpenMP_CXX)
|
target_link_libraries(chapter_06 PRIVATE raytracing OpenMP::OpenMP_CXX)
|
||||||
|
|
||||||
add_executable(chapter_07 chapter_07.cpp)
|
add_executable(chapter_07 chapter_07.cpp)
|
||||||
target_link_libraries(chapter_07 PRIVATE raytracing gcov OpenMP::OpenMP_CXX)
|
target_link_libraries(chapter_07 PRIVATE raytracing OpenMP::OpenMP_CXX)
|
||||||
|
|
||||||
add_executable(chapter_09 chapter_09.cpp)
|
add_executable(chapter_09 chapter_09.cpp)
|
||||||
target_link_libraries(chapter_09 PRIVATE raytracing gcov OpenMP::OpenMP_CXX)
|
target_link_libraries(chapter_09 PRIVATE raytracing OpenMP::OpenMP_CXX)
|
||||||
|
|
||||||
add_executable(chapter_10 chapter_10.cpp)
|
add_executable(chapter_10 chapter_10.cpp)
|
||||||
target_link_libraries(chapter_10 PRIVATE raytracing gcov OpenMP::OpenMP_CXX)
|
target_link_libraries(chapter_10 PRIVATE raytracing OpenMP::OpenMP_CXX)
|
||||||
|
|
||||||
add_executable(chapter_11_p1 chapter_11_p1.cpp)
|
add_executable(chapter_11_p1 chapter_11_p1.cpp)
|
||||||
target_link_libraries(chapter_11_p1 PRIVATE raytracing gcov OpenMP::OpenMP_CXX)
|
target_link_libraries(chapter_11_p1 PRIVATE raytracing OpenMP::OpenMP_CXX)
|
||||||
|
|
||||||
add_executable(chapter_11_p2 chapter_11_p2.cpp)
|
add_executable(chapter_11_p2 chapter_11_p2.cpp)
|
||||||
target_link_libraries(chapter_11_p2 PRIVATE raytracing OpenMP::OpenMP_CXX)
|
target_link_libraries(chapter_11_p2 PRIVATE raytracing OpenMP::OpenMP_CXX)
|
||||||
|
|||||||
24
cmake/CPM.cmake
Normal file
24
cmake/CPM.cmake
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
#
|
||||||
|
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
|
||||||
|
|
||||||
|
set(CPM_DOWNLOAD_VERSION 0.38.7)
|
||||||
|
set(CPM_HASH_SUM "83e5eb71b2bbb8b1f2ad38f1950287a057624e385c238f6087f94cdfc44af9c5")
|
||||||
|
|
||||||
|
if(CPM_SOURCE_CACHE)
|
||||||
|
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||||
|
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
|
||||||
|
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||||
|
else()
|
||||||
|
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Expand relative path. This is important if the provided path contains a tilde (~)
|
||||||
|
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
||||||
|
|
||||||
|
file(DOWNLOAD
|
||||||
|
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
|
||||||
|
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
|
||||||
|
)
|
||||||
|
|
||||||
|
include(${CPM_DOWNLOAD_LOCATION})
|
||||||
17976
raytracing/include/external/catch.hpp
vendored
17976
raytracing/include/external/catch.hpp
vendored
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "core/tuple.h"
|
#include "core/tuple.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "core/color.h"
|
#include "core/color.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "renderer/canvas.h"
|
#include "renderer/canvas.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "raytracing.h"
|
#include "raytracing.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "raytracing.h"
|
#include "raytracing.h"
|
||||||
|
|
||||||
@@ -180,7 +182,7 @@ SCENARIO("Rotating a point around the x axis", "[features/transformations.featur
|
|||||||
Matrix full_quarter = Matrix::rotation_x(std::numbers::pi / 2);
|
Matrix full_quarter = Matrix::rotation_x(std::numbers::pi / 2);
|
||||||
THEN("half_quarter * p = point(0, sqrt(2) / 2, sqrt(2) / 2)")
|
THEN("half_quarter * p = point(0, sqrt(2) / 2, sqrt(2) / 2)")
|
||||||
{
|
{
|
||||||
REQUIRE(half_quarter * p == Tuple::Point(0, sqrt(2) / 2, sqrt(2) / 2));
|
REQUIRE(half_quarter * p == Tuple::Point(0, std::sqrt(2) / 2, std::sqrt(2) / 2));
|
||||||
}
|
}
|
||||||
AND_THEN("full_quarter * p == point(0, 0, 1)")
|
AND_THEN("full_quarter * p == point(0, 0, 1)")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "raytracing.h"
|
#include "raytracing.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "raytracing.h"
|
#include "raytracing.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "raytracing.h"
|
#include "raytracing.h"
|
||||||
|
|
||||||
@@ -629,7 +631,7 @@ SCENARIO("Constructing a ray when the camera is transformed", "[features/camera.
|
|||||||
}
|
}
|
||||||
AND_THEN("r.direction = vector(sqrt(2) / 2, 0, -sqrt(2) / 2)")
|
AND_THEN("r.direction = vector(sqrt(2) / 2, 0, -sqrt(2) / 2)")
|
||||||
{
|
{
|
||||||
REQUIRE(r.direction() == Tuple::Vector(sqrt(2) / 2, 0, -sqrt(2) / 2));
|
REQUIRE(r.direction() == Tuple::Vector(std::sqrt(2) / 2, 0, -std::sqrt(2) / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "raytracing.h"
|
#include "raytracing.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "raytracing.h"
|
#include "raytracing.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "raytracing.h"
|
#include "raytracing.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "raytracing.h"
|
#include "raytracing.h"
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <external/catch.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
#include "raytracing.h"
|
#include "raytracing.h"
|
||||||
|
|
||||||
|
|||||||
34
tests/13_cylinders.cpp
Normal file
34
tests/13_cylinders.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/*!
|
||||||
|
* 13_cylinders.cpp
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015-2024, NADAL Jean-Baptiste. All rights reserved.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* @Author: NADAL Jean-Baptiste
|
||||||
|
* @Date: 18/03/2024
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include "raytracing.h"
|
||||||
|
|
||||||
|
using namespace Raytracer;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------- */
|
||||||
@@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.19)
|
|||||||
|
|
||||||
project(raytracing_test)
|
project(raytracing_test)
|
||||||
|
|
||||||
|
CPMAddPackage("gh:catchorg/Catch2@3.5.3")
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
@@ -23,10 +25,11 @@ add_executable(raytracing_test
|
|||||||
10_patterns.cpp
|
10_patterns.cpp
|
||||||
11_reflection_refraction.cpp
|
11_reflection_refraction.cpp
|
||||||
12_cubes.cpp
|
12_cubes.cpp
|
||||||
|
13_cylinders.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories("${CMAKE_SOURCE_DIR}/tests")
|
include_directories("${CMAKE_SOURCE_DIR}/tests")
|
||||||
|
|
||||||
target_link_libraries(raytracing_test PRIVATE raytracing gcov OpenMP::OpenMP_CXX)
|
target_link_libraries(raytracing_test PRIVATE raytracing Catch2WithMain OpenMP::OpenMP_CXX)
|
||||||
|
|
||||||
add_test(NAME raytracing_test COMMAND tests/raytracing_test)
|
add_test(NAME raytracing_test COMMAND tests/raytracing_test)
|
||||||
|
|||||||
@@ -26,4 +26,4 @@
|
|||||||
#define CATCH_INTERNAL_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS
|
#define CATCH_INTERNAL_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS
|
||||||
#define CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS
|
#define CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS
|
||||||
#define CATCH_CONFIG_MAIN
|
#define CATCH_CONFIG_MAIN
|
||||||
#include "external/catch.hpp"
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|||||||
Reference in New Issue
Block a user