From 18960c4b88ce912e08b12182b835a7de75388b78 Mon Sep 17 00:00:00 2001 From: Julian T Date: Thu, 23 Jul 2020 23:13:55 +0200 Subject: New project structure --- CMakeLists.txt | 14 +++++++++++++- main.cpp | 7 ------- src/main.cpp | 23 +++++++++++++++++++++++ src/object.hpp | 19 +++++++++++++++++++ src/scene.cpp | 5 +++++ src/scene.hpp | 15 +++++++++++++++ src/vector.hpp | 18 ++++++++++++++++++ 7 files changed, 93 insertions(+), 8 deletions(-) delete mode 100644 main.cpp create mode 100644 src/main.cpp create mode 100644 src/object.hpp create mode 100644 src/scene.cpp create mode 100644 src/scene.hpp create mode 100644 src/vector.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a9bff2d..8f895da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,4 +2,16 @@ cmake_minimum_required(VERSION 3.10) project(pathtracing) -add_executable(pathtracing main.cpp) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +FILE(GLOB sources ${CMAKE_SOURCE_DIR}/src/*.cpp) + +add_executable(pathtracing ${sources}) + +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH}) + +# Detect and add SFML +find_package(SFML 2 REQUIRED system window graphics) +include_directories(${SFML_INCLUDE_DIR}) +target_link_libraries(pathtracing ${SFML_LIBRARIES} ${SFML_DEPENDENCIES}) diff --git a/main.cpp b/main.cpp deleted file mode 100644 index da92ead..0000000 --- a/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include - -using namespace std; - -int main() { - cout << "Hello World!" << endl; -} diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..3c15429 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,23 @@ +#include +#include +#include +#include +#include + +#include + +using namespace std; + +int main() +{ + cout << "Hello World!" << endl; + + sf::RenderWindow window(sf::VideoMode(200, 200), "Yaah working"); + sf::CircleShape shape(100.f); + + window.clear(); + window.draw(shape); + window.display(); + + return 0; +} diff --git a/src/object.hpp b/src/object.hpp new file mode 100644 index 0000000..56c6968 --- /dev/null +++ b/src/object.hpp @@ -0,0 +1,19 @@ +#ifndef OBJECT_H +#define OBJECT_H + +#include +#include "vector.hpp" + +class Material { + Vec3d color; + + double defuse; + double emissive; +}; + +class Object { + public: + std::shared_ptr m; +}; + +#endif diff --git a/src/scene.cpp b/src/scene.cpp new file mode 100644 index 0000000..d65dca7 --- /dev/null +++ b/src/scene.cpp @@ -0,0 +1,5 @@ +#include "scene.hpp" + +void Scene::addObject(Object obj) { + objs.push_back(obj); +} diff --git a/src/scene.hpp b/src/scene.hpp new file mode 100644 index 0000000..6e3f33e --- /dev/null +++ b/src/scene.hpp @@ -0,0 +1,15 @@ +#ifndef SCENE_H +#define SCENE_H + +#include +#include "object.hpp" + +class Scene { + public: + void addObject(Object obj); + + std::vector objs; + +}; + +#endif diff --git a/src/vector.hpp b/src/vector.hpp new file mode 100644 index 0000000..6d15f34 --- /dev/null +++ b/src/vector.hpp @@ -0,0 +1,18 @@ +#ifndef VECTOR_H +#define VECTOR_H + +class Vec3d { + Vec3d(); + Vec3d(double x, double y, double z); + + void set(double x, double y, double z); + void normalize(); + + double length(); + + Vec3d cross(const Vec3d &vec); + + // Operators +}; + +#endif -- cgit v1.2.3