From fa0f4c8fc4da46e4f0cd7223b2fca6d4ffa68085 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Mon, 13 Apr 2020 21:53:19 +0200 Subject: [PATCH] Add GLM as submodule --- .gitmodules | 3 +++ CMakeLists.txt | 10 ++++------ Primitives.cpp | 2 +- Scene.cpp | 12 ++++++------ Shader.cpp | 4 ++-- UserInterfaceManager.cpp | 2 +- ext/glm | 1 + main.cpp | 3 +-- 8 files changed, 19 insertions(+), 18 deletions(-) create mode 160000 ext/glm diff --git a/.gitmodules b/.gitmodules index bef1bd6..9a5d305 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "ext/tfd"] path = ext/tfd url = https://github.com/native-toolkit/tinyfiledialogs.git +[submodule "ext/glm"] + path = ext/glm + url = https://github.com/g-truc/glm.git diff --git a/CMakeLists.txt b/CMakeLists.txt index a5ef90f..b6b5192 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,6 @@ set(THREAD_LIBRARY Threads::Threads) find_package(PNG REQUIRED) set(PNG_LIBRARY PNG::PNG) - # # GLFW3 # @@ -95,9 +94,9 @@ find_package(OpenGL REQUIRED) # # GLM # -find_package(glm REQUIRED) -macro_log_feature(glm_FOUND "GLM" "OpenGL Mathematics" "https://glm.g-truc.net" TRUE) -set(GLM_LIBRARY glm) +set(BUILD_STATIC_LIBS ON) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ext/glm) +message(STATUS "Compiling 'GLM' OpenGL Mathematics https://glm.g-truc.net.") # # GLAD @@ -131,7 +130,6 @@ set(IMGUITEXTEDIT_SRC ) message(STATUS "Including 'ImGuiColorTextEdit' from https://github.com/BalazsJako/ImGuiColorTextEdit -- ${IMGUITEXTEDIT_INCLUDE_DIR}.") - # # TINY XML 2 # @@ -265,7 +263,6 @@ message(STATUS "Using 'CMakeRC ' from https://github.com/vector-of-bool/cmrc.git target_link_libraries(${VMIX_BINARY} LINK_PRIVATE ${GLFW_LIBRARY} ${OPENGL_LIBRARY} - ${GLM_LIBRARY} GLAD ${CMAKE_DL_LIBS} ${GOBJECT_LIBRARIES} @@ -282,6 +279,7 @@ target_link_libraries(${VMIX_BINARY} LINK_PRIVATE TINYXML2 TINYFD IMGUI + glm::glm vmix::rc ) diff --git a/Primitives.cpp b/Primitives.cpp index 973d9a8..ac80bb5 100644 --- a/Primitives.cpp +++ b/Primitives.cpp @@ -138,7 +138,7 @@ void MediaSurface::update( float dt ) mediaplayer_->update(); // if (parent_ != nullptr) { -// parent_->transform_ = parent_->transform_ * glm::scale(glm::mat4(1.f), glm::vec3(mediaplayer_->aspectRatio(), 1.f, 1.f)); +// parent_->transform_ = parent_->transform_ * glm::scale(glm::identity(), glm::vec3(mediaplayer_->aspectRatio(), 1.f, 1.f)); // scale_.x = 1.0; // } // else diff --git a/Scene.cpp b/Scene.cpp index fc56b97..172eb06 100644 --- a/Scene.cpp +++ b/Scene.cpp @@ -19,11 +19,11 @@ glm::mat4 transform(glm::vec3 translation, glm::vec3 rotation, glm::vec3 scale) { - glm::mat4 View = glm::translate(glm::mat4(1.f), translation); + glm::mat4 View = glm::translate(glm::identity(), translation); View = glm::rotate(View, rotation.x, glm::vec3(1.f, 0.f, 0.f)); View = glm::rotate(View, rotation.y, glm::vec3(0.f, 1.f, 0.f)); View = glm::rotate(View, rotation.z, glm::vec3(0.f, 0.f, 1.f)); - glm::mat4 Model = glm::scale(glm::mat4(1.f), scale); + glm::mat4 Model = glm::scale(glm::identity(), scale); return View * Model; } @@ -34,7 +34,7 @@ Node::Node() : initialized_(false), parent_(nullptr), visible_(true) auto duration = std::chrono::system_clock::now().time_since_epoch(); id_ = std::chrono::duration_cast(duration).count() % 100000000; - transform_ = glm::mat4(1.f); + transform_ = glm::identity(); scale_ = glm::vec3(1.f); rotation_ = glm::vec3(0.f); translation_ = glm::vec3(0.f); @@ -321,8 +321,8 @@ void Animation::init() { Group::init(); - animation_ = glm::mat4(1.f); -// animation_ = glm::translate(glm::mat4(1.f), glm::vec3(2.f, 0.f, 0.f)); + animation_ = glm::identity(); +// animation_ = glm::translate(glm::identity(), glm::vec3(2.f, 0.f, 0.f)); } void Animation::update( float dt ) @@ -338,7 +338,7 @@ void Animation::update( float dt ) glm::vec4 delta = glm::vec4(pos, 0.f) * animation_; // apply this translation to the Group transform - transform_ *= glm::translate(glm::mat4(1.f), glm::vec3(delta.x, delta.y, 0.f)); + transform_ *= glm::translate(glm::identity(), glm::vec3(delta.x, delta.y, 0.f)); } diff --git a/Shader.cpp b/Shader.cpp index 39b2124..dec0989 100644 --- a/Shader.cpp +++ b/Shader.cpp @@ -210,8 +210,8 @@ void Shader::use() void Shader::reset() { - projection = glm::mat4(1.f); - modelview = glm::mat4(1.f); + projection = glm::identity(); + modelview = glm::identity(); resolution = glm::vec3(1280.f, 720.f, 0.f); color = glm::vec4(1.f, 1.f, 1.f, 1.f); } diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index a0db9b8..3b5763f 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -170,7 +170,7 @@ void UserInterface::handleMouse() Log::Info("Mouse press (%.1f,%.1f)", io.MousePos.x, io.MousePos.y); - glm::mat4 mv = glm::mat4(1.f); + glm::mat4 mv = glm::identity(); glm::vec3 point = Rendering::manager().unProject(glm::vec2(io.MousePos.x, io.MousePos.y), mv); Log::Info(" (%.1f,%.1f)", point.x, point.y); diff --git a/ext/glm b/ext/glm new file mode 160000 index 0000000..bf71a83 --- /dev/null +++ b/ext/glm @@ -0,0 +1 @@ +Subproject commit bf71a834948186f4097caa076cd2663c69a10e1e diff --git a/main.cpp b/main.cpp index c169c86..0b0ea3b 100644 --- a/main.cpp +++ b/main.cpp @@ -180,7 +180,7 @@ void drawScene() scene.root_.update( static_cast( GST_TIME_AS_MSECONDS(dt)) * 0.001f ); // draw in output frame buffer - glm::mat4 MV = glm::mat4(1.f); + glm::mat4 MV = glm::identity(); glm::mat4 P = glm::scale( glm::ortho(-5.f, 5.f, -5.f, 5.f), glm::vec3(1.f, output->aspectRatio(), 1.f)); output->begin(); scene.root_.draw(MV, P); @@ -212,7 +212,6 @@ void drawPreview() ImGui::End(); } - }