From 19cae22aba5962da5ad9a884b0faf838c20aea6d Mon Sep 17 00:00:00 2001 From: Lauchmelder Date: Tue, 21 Dec 2021 15:51:54 +0100 Subject: [PATCH] restructured project to encapsulate backend into library --- CMakeLists.txt | 1 + backend/CMakeLists.txt | 20 +++++++++++++++++++ {src => backend/include}/backend/Drawable.hpp | 0 .../include}/backend/ObjectManager.hpp | 0 {src => backend/include}/backend/Shader.hpp | 0 .../include}/backend/Transformable.hpp | 0 .../include}/backend/VertexArrayObject.hpp | 0 {src/backend => backend/src}/Drawable.cpp | 2 +- {src/backend => backend/src}/Shader.cpp | 2 +- .../backend => backend/src}/Transformable.cpp | 2 +- .../src}/VertexArrayObject.cpp | 2 +- src/CMakeLists.txt | 11 ++++------ 12 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 backend/CMakeLists.txt rename {src => backend/include}/backend/Drawable.hpp (100%) rename {src => backend/include}/backend/ObjectManager.hpp (100%) rename {src => backend/include}/backend/Shader.hpp (100%) rename {src => backend/include}/backend/Transformable.hpp (100%) rename {src => backend/include}/backend/VertexArrayObject.hpp (100%) rename {src/backend => backend/src}/Drawable.cpp (85%) rename {src/backend => backend/src}/Shader.cpp (98%) rename {src/backend => backend/src}/Transformable.cpp (97%) rename {src/backend => backend/src}/VertexArrayObject.cpp (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index f44b1a0..d5c6e2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,4 +26,5 @@ if(NOT GLM_FOUND) endif() # Include sub-projects. +add_subdirectory("backend") add_subdirectory ("src") diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt new file mode 100644 index 0000000..3e14332 --- /dev/null +++ b/backend/CMakeLists.txt @@ -0,0 +1,20 @@ +add_library(backend STATIC + "src/Drawable.cpp" + "src/Transformable.cpp" + "src/Shader.cpp" + "src/VertexArrayObject.cpp" +) + +target_sources(backend PUBLIC + ${VENDOR_DIR}/glad/src/glad.c +) + +target_include_directories(backend PUBLIC + ${GLM_INCLUDE_DIRS} + ${VENDOR_DIR}/glad/include + include +) + +target_link_libraries(backend PUBLIC + ${GLM_LIBRARIES} +) \ No newline at end of file diff --git a/src/backend/Drawable.hpp b/backend/include/backend/Drawable.hpp similarity index 100% rename from src/backend/Drawable.hpp rename to backend/include/backend/Drawable.hpp diff --git a/src/backend/ObjectManager.hpp b/backend/include/backend/ObjectManager.hpp similarity index 100% rename from src/backend/ObjectManager.hpp rename to backend/include/backend/ObjectManager.hpp diff --git a/src/backend/Shader.hpp b/backend/include/backend/Shader.hpp similarity index 100% rename from src/backend/Shader.hpp rename to backend/include/backend/Shader.hpp diff --git a/src/backend/Transformable.hpp b/backend/include/backend/Transformable.hpp similarity index 100% rename from src/backend/Transformable.hpp rename to backend/include/backend/Transformable.hpp diff --git a/src/backend/VertexArrayObject.hpp b/backend/include/backend/VertexArrayObject.hpp similarity index 100% rename from src/backend/VertexArrayObject.hpp rename to backend/include/backend/VertexArrayObject.hpp diff --git a/src/backend/Drawable.cpp b/backend/src/Drawable.cpp similarity index 85% rename from src/backend/Drawable.cpp rename to backend/src/Drawable.cpp index b1de433..95e2797 100644 --- a/src/backend/Drawable.cpp +++ b/backend/src/Drawable.cpp @@ -1,4 +1,4 @@ -#include "Drawable.hpp" +#include "backend/Drawable.hpp" void Drawable::Render() { diff --git a/src/backend/Shader.cpp b/backend/src/Shader.cpp similarity index 98% rename from src/backend/Shader.cpp rename to backend/src/Shader.cpp index 9a1ccd4..c3e8bdf 100644 --- a/src/backend/Shader.cpp +++ b/backend/src/Shader.cpp @@ -1,4 +1,4 @@ -#include "Shader.hpp" +#include "backend/Shader.hpp" #include diff --git a/src/backend/Transformable.cpp b/backend/src/Transformable.cpp similarity index 97% rename from src/backend/Transformable.cpp rename to backend/src/Transformable.cpp index ed50644..40d1fda 100644 --- a/src/backend/Transformable.cpp +++ b/backend/src/Transformable.cpp @@ -1,4 +1,4 @@ -#include "Transformable.hpp" +#include "backend/Transformable.hpp" Transformable::Transformable() : position(0.0f), scale(1.0f), orientation(0.0, 0.0, 0.0, 1.0) diff --git a/src/backend/VertexArrayObject.cpp b/backend/src/VertexArrayObject.cpp similarity index 97% rename from src/backend/VertexArrayObject.cpp rename to backend/src/VertexArrayObject.cpp index 72e7fed..e604376 100644 --- a/src/backend/VertexArrayObject.cpp +++ b/backend/src/VertexArrayObject.cpp @@ -1,4 +1,4 @@ -#include "VertexArrayObject.hpp" +#include "backend/VertexArrayObject.hpp" #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c14500b..47bcdb5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,8 @@ add_executable(visualizer - "main.cpp" "Application.cpp" - "backend/VertexArrayObject.cpp" "backend/Shader.cpp" "Cuboid.cpp" "backend/Drawable.cpp" "backend/Transformable.cpp") + "main.cpp" "Application.cpp" "Cuboid.cpp" +) target_sources(visualizer PUBLIC - ${VENDOR_DIR}/glad/src/glad.c - ${VENDOR_DIR}/imgui/backends/imgui_impl_opengl3.cpp ${VENDOR_DIR}/imgui/backends/imgui_impl_glfw.cpp ${VENDOR_DIR}/imgui/imgui.cpp @@ -16,12 +14,11 @@ target_sources(visualizer PUBLIC target_include_directories(visualizer PRIVATE ${GLFW3_INCLUDE_DIRS} - ${GLM_INCLUDE_DIRS} - ${VENDOR_DIR}/glad/include ${VENDOR_DIR}/imgui + backend ) target_link_libraries(visualizer PRIVATE ${GLFW3_LIBRARIES} - ${GLM_LIBRARIES} + backend ) \ No newline at end of file