diff --git a/CMakeLists.txt b/CMakeLists.txt index 5651b51..95e3155 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,10 @@ pkg_check_modules(EPOXY REQUIRED epoxy) pkg_check_modules(SDL2 REQUIRED sdl2) pkg_check_modules(ASSIMP REQUIRED assimp) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + #find_package(OpenCL REQUIRED) include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/imgui-submodule/imgui/examples" "${CMAKE_CURRENT_SOURCE_DIR}/imgui-submodule/imgui" ${EPOXY_INCLUDE_DIRS} ${ASSIMP_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}) @@ -45,3 +49,10 @@ add_compile_options(-Wall) add_executable(${PROJECT_NAME} ${SOURCES} ${IMGUI_SOURCES}) target_link_libraries(${PROJECT_NAME} m pthread ${EPOXY_LIBRARIES} ${SDL2_LIBRARIES} ${ASSIMP_LIBRARIES} glm) install (TARGETS ${PROJECT_NAME} DESTINATION bin) + +target_precompile_headers(${PROJECT_NAME} + PUBLIC + "$<$:stb/stb_image.h>" + "$<$:glm/glm.hpp>" + PRIVATE +) diff --git a/include/opengl-playground/globalcanvassettings.hpp b/include/opengl-playground/globalcanvassettings.hpp index ea22ebb..a4cec9d 100644 --- a/include/opengl-playground/globalcanvassettings.hpp +++ b/include/opengl-playground/globalcanvassettings.hpp @@ -1,7 +1,7 @@ #ifndef GLOBALCANVASSETTINGS_H #define GLOBALCANVASSETTINGS_H -#include +//#include class GlobalCanvasSettings { diff --git a/include/opengl-playground/material.hpp b/include/opengl-playground/material.hpp index c9cf785..1c76fa9 100644 --- a/include/opengl-playground/material.hpp +++ b/include/opengl-playground/material.hpp @@ -4,8 +4,8 @@ #include #include #include -#include - +//#include +#include class Material { @@ -42,6 +42,8 @@ class Material glm::vec3 diff_color; glm::vec3 ambient_color; glm::vec3 specular_color; + + friend std::ostream &operator<<(std::ostream &os, Material const &material); }; #endif // MATERIAL_H diff --git a/include/opengl-playground/openglgraphics.hpp b/include/opengl-playground/openglgraphics.hpp index d0bbc30..9880854 100644 --- a/include/opengl-playground/openglgraphics.hpp +++ b/include/opengl-playground/openglgraphics.hpp @@ -4,7 +4,7 @@ #include #include #include -#include +//#include #include class OpenGlGraphics diff --git a/include/opengl-playground/openglshader.hpp b/include/opengl-playground/openglshader.hpp index 9e0a5f3..33b9386 100644 --- a/include/opengl-playground/openglshader.hpp +++ b/include/opengl-playground/openglshader.hpp @@ -3,7 +3,7 @@ #include #include -#include +//#include class OpenGlShaderProgram { diff --git a/models/.gitignore b/models/.gitignore new file mode 100644 index 0000000..4ca7089 --- /dev/null +++ b/models/.gitignore @@ -0,0 +1,2 @@ +*.blend1 +*.blend* diff --git a/src/material.cpp b/src/material.cpp index 35c65d2..50f6bb8 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -1,6 +1,18 @@ #include +std::ostream &operator<<(std::ostream &os, glm::vec3 const &vec3) +{ + return os << "(" << vec3.r << "|" << vec3.g << "|" << vec3.b << ")"; +} +std::ostream &operator<<(std::ostream &os, Material const &material) +{ + return os << "Diffuse Color: " << material.diff_color << ", " + << "Ambient Color: " << material.ambient_color << ", " + << "Specular Color: " << material.specular_color << ", " + << "Texture counts (diff, amb, spec): " << material.diffuse_textures.size() + << ", " << material.ambient_textures.size() << ", " << material.specular_textures.size(); +} Material::Material() { diff --git a/src/model.cpp b/src/model.cpp index 49c2b41..8ccf60e 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -135,6 +135,7 @@ Mesh Model::processMesh(aiMesh *mesh, const aiScene *scene) material->Get(AI_MATKEY_SHININESS, mesh_material.shininess); material->Get(AI_MATKEY_SHININESS_STRENGTH, mesh_material.shininess_strength); + std::cout << "Material: " << mesh_material << std::endl; } diff --git a/src/opengltexture.cpp b/src/opengltexture.cpp index 5a5307c..08da0cc 100644 --- a/src/opengltexture.cpp +++ b/src/opengltexture.cpp @@ -3,6 +3,7 @@ #define STB_IMAGE_IMPLEMENTATION #include #include +#include OpenGlTexture::OpenGlTexture(const std::string &texture_path) { @@ -36,8 +37,14 @@ void OpenGlTexture::setRGBDataFromBytes(unsigned int width, unsigned int height, void OpenGlTexture::loadFromImagePath(const std::string &base_directory) { int width, height, nrChannels; - std::string filename = this->texture_path; - filename = base_directory + '/' + filename; + std::filesystem::path base_path(base_directory); + std::filesystem::path tex_path(this->texture_path); + std::string filename; + + if (tex_path.is_relative()) + filename = base_path / tex_path; + else + filename = tex_path; unsigned char *data = stbi_load(filename.c_str(), &width, &height, &nrChannels, 0); if (data) { diff --git a/src/vertex.cpp b/src/vertex.cpp index 0af056c..87704de 100644 --- a/src/vertex.cpp +++ b/src/vertex.cpp @@ -1 +1,10 @@ #include + +Vertex operator+(Vertex const &a, Vertex const &b) +{ + Vertex out = a; + + out.Position + b.Position; + + return out; +}