diff options
author | Julian T <julian@jtle.dk> | 2020-07-23 23:13:55 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-07-23 23:13:55 +0200 |
commit | 18960c4b88ce912e08b12182b835a7de75388b78 (patch) | |
tree | fd3994dc07a07298824521000bde1683461e5262 | |
parent | 13a7b10ab0efa82a24187cdfb2cf2a55691568f0 (diff) |
New project structure
-rw-r--r-- | CMakeLists.txt | 14 | ||||
-rw-r--r-- | main.cpp | 7 | ||||
-rw-r--r-- | src/main.cpp | 23 | ||||
-rw-r--r-- | src/object.hpp | 19 | ||||
-rw-r--r-- | src/scene.cpp | 5 | ||||
-rw-r--r-- | src/scene.hpp | 15 | ||||
-rw-r--r-- | src/vector.hpp | 18 |
7 files changed, 93 insertions, 8 deletions
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 <iostream> - -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 <SFML/Graphics/CircleShape.hpp> +#include <SFML/Graphics/RenderWindow.hpp> +#include <SFML/Window/Event.hpp> +#include <SFML/Window/VideoMode.hpp> +#include <iostream> + +#include <SFML/Graphics.hpp> + +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 <memory> +#include "vector.hpp" + +class Material { + Vec3d color; + + double defuse; + double emissive; +}; + +class Object { + public: + std::shared_ptr<Material> 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 <vector> +#include "object.hpp" + +class Scene { + public: + void addObject(Object obj); + + std::vector<Object> 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 |