diff --git a/.gitignore b/.gitignore index 378eac2..76dea94 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ build +.PVS-Studio/State/ReportState.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index e6cbc98..0000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [], - "compilerPath": "/usr/bin/gcc", - "cStandard": "gnu17", - "cppStandard": "gnu++14", - "intelliSenseMode": "linux-gcc-x64", - "compileCommands": "${workspaceFolder}/build/compile_commands.json", - "configurationProvider": "ms-vscode.cmake-tools" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 23225a1..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "(gdb) Lancer", - "type": "cppdbg", - "request": "launch", - "program": "${workspaceFolder}/build/raytracing_tests", - "args": [], - "stopAtEntry": false, - "cwd": "${workspaceFolder}", - "environment": [], - "console": "externalTerminal", - "MIMode": "gdb", - "setupCommands": [ - { - "description": "Activer l'impression en mode Pretty pour gdb", - "text": "-enable-pretty-printing", - "ignoreFailures": true - } - ] - } - ] -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index d789c03..06362fd 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { + "cmake.sourceDirectory": "/home/jbnadal/sources/jb/raytracing_challenge", "cSpell.words": [ "Raytracer" ] diff --git a/CMakeLists.txt b/CMakeLists.txt index 4306fe1..2256e8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,10 @@ cmake_minimum_required(VERSION 3.14) -project(raytracing_challenge) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -enable_testing() - -include_directories("${CMAKE_SOURCE_DIR}/tests") -include_directories("${CMAKE_SOURCE_DIR}/src") - -add_executable( - raytracing_tests - - src/tuple.cpp - - tests/main.cpp - tests/chapitre01_tuples.cpp +project(raytracing_challenge + VERSION 0.1 + DESCRIPTION "Raytracing Challenge in c++" ) + +add_subdirectory(raytracing) +add_subdirectory(apps) +add_subdirectory(tests) diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt new file mode 100644 index 0000000..faed794 --- /dev/null +++ b/apps/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.14) + +project(main) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(raytracer main.cpp) +# We need hello.h and the hello library +target_link_libraries(raytracer + PRIVATE raytracing) diff --git a/apps/main.cpp b/apps/main.cpp new file mode 100644 index 0000000..83310e0 --- /dev/null +++ b/apps/main.cpp @@ -0,0 +1,40 @@ +/*! + * main.cpp + * + * Copyright (c) 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: 30/01/2024 + * + */ + +// This is an independent project of an individual developer. Dear PVS-Studio, please check it. +// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com + + +#include +#include + +/* ------------------------------------------------------------------------- */ + +int main(void) +{ + printf("Later Here we will have main function\n"); + + return 0; +} diff --git a/raytracing/CMakeLists.txt b/raytracing/CMakeLists.txt new file mode 100644 index 0000000..06f797d --- /dev/null +++ b/raytracing/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.14) + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +project(raytracing) + +add_library(raytracing + src/tuple.cpp +) + +target_include_directories(${PROJECT_NAME} + PUBLIC ${PROJECT_SOURCE_DIR}/include + PUBLIC ${PROJECT_SOURCE_DIR}/src +) diff --git a/raytracing/include/raytracing.h b/raytracing/include/raytracing.h new file mode 100644 index 0000000..f112444 --- /dev/null +++ b/raytracing/include/raytracing.h @@ -0,0 +1,28 @@ +/*! + * raytracing.h + * + * Copyright (c) 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: 29/01/2024 + * + */ + +#pragma once + +#include "tuple.h" diff --git a/src/tuple.cpp b/raytracing/src/tuple.cpp similarity index 97% rename from src/tuple.cpp rename to raytracing/src/tuple.cpp index e63fec0..2773693 100644 --- a/src/tuple.cpp +++ b/raytracing/src/tuple.cpp @@ -137,14 +137,14 @@ float Tuple::w(void) const bool Tuple::is_point(void) { - return (m_w == kRaytracerTuplePoint) ? true : false; + return float_equal(m_w, kRaytracerTuplePoint); } /* ------------------------------------------------------------------------- */ bool Tuple::is_vector(void) { - return (m_w == kRaytracerTupleVector) ? true : false; + return float_equal(m_w, kRaytracerTupleVector); } /* ------------------------------------------------------------------------- */ diff --git a/src/tuple.h b/raytracing/src/tuple.h similarity index 100% rename from src/tuple.h rename to raytracing/src/tuple.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..34b0dbf --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.14) + +project(main_test) + +include(CTest) + +enable_testing() + +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(main_test + main_test.cpp + + chapitre01_tuples.cpp +) + +include_directories("${CMAKE_SOURCE_DIR}/tests") + +target_link_libraries(main_test + PRIVATE raytracing) diff --git a/tests/main.cpp b/tests/main_test.cpp similarity index 100% rename from tests/main.cpp rename to tests/main_test.cpp