From c3ee3d3942013ddaee610188534466702f211264 Mon Sep 17 00:00:00 2001 From: chatlanin Date: Thu, 13 Mar 2025 15:29:33 +0300 Subject: [PATCH] add ve name --- bin/layers/local_panel/local_panel.cpp | 2 +- bin/layers/opengl_panel/opengl_panel.hpp | 22 ++++++++--------- src/glfw/glfw.hpp | 2 +- src/opengl/shader_program/shader_program.hpp | 12 +++++---- src/utils/define.hpp | 2 ++ src/utils/func.hpp | 26 ++++++++++++++++++++ src/utils/include.hpp | 16 ++++++------ src/utils/math.hpp | 14 ----------- src/utils/utils.hpp | 2 +- 9 files changed, 58 insertions(+), 40 deletions(-) create mode 100644 src/utils/func.hpp delete mode 100644 src/utils/math.hpp diff --git a/bin/layers/local_panel/local_panel.cpp b/bin/layers/local_panel/local_panel.cpp index 78316b8..30a8e69 100755 --- a/bin/layers/local_panel/local_panel.cpp +++ b/bin/layers/local_panel/local_panel.cpp @@ -11,7 +11,7 @@ namespace sandbox void local_panel::render() { - if (ImGui::Button("RUN thread", ImVec2(128, 130))) + if (ImGui::Button(VE_NAME("RUN thread"), ImVec2(128, 130))) { auto f = []() { diff --git a/bin/layers/opengl_panel/opengl_panel.hpp b/bin/layers/opengl_panel/opengl_panel.hpp index b84826f..bad2114 100755 --- a/bin/layers/opengl_panel/opengl_panel.hpp +++ b/bin/layers/opengl_panel/opengl_panel.hpp @@ -21,17 +21,17 @@ namespace sandbox struct camera { // Начальное положение камеры - mt::vec3 m_pos = mt::vec3{ 0.0f, 0.0f, 3.0f }; - mt::vec3 m_front = mt::vec3{ 0.0f, 0.0f, -1.0f }; - mt::vec3 m_up = mt::vec3{ 0.0f, 1.0f, 0.0f }; + glm::vec3 m_pos = glm::vec3{ 0.0f, 0.0f, 3.0f }; + glm::vec3 m_front = glm::vec3{ 0.0f, 0.0f, -1.0f }; + glm::vec3 m_up = glm::vec3{ 0.0f, 1.0f, 0.0f }; float m_speed = 0.05f; glm::mat4 m_view, m_projection; void up() { m_pos += m_speed * m_front; } void down() { m_pos -= m_speed * m_front; } - void left() { m_pos -= mt::normalize(mt::cross(m_front, m_up)) * m_speed; } - void right() { m_pos += mt::normalize(mt::cross(m_front, m_up)) * m_speed; } + void left() { m_pos -= glm::normalize(glm::cross(m_front, m_up)) * m_speed; } + void right() { m_pos += glm::normalize(glm::cross(m_front, m_up)) * m_speed; } template void update(const T& obj) @@ -41,7 +41,7 @@ namespace sandbox static_cast(VE::application::get()->get_glfw()->width()) / VE::application::get()->get_glfw()->height(), 0.1f, 100.0f); - glUniformMatrix4fv(glGetUniformLocation(obj.get_id(), "view"), 1, GL_FALSE, mt::value_ptr(m_view)); + glUniformMatrix4fv(glGetUniformLocation(obj.get_id(), "view"), 1, GL_FALSE, glm::value_ptr(m_view)); glUniformMatrix4fv(glGetUniformLocation(obj.get_id(), "projection"), 1, GL_FALSE, glm::value_ptr(m_projection)); } @@ -75,11 +75,11 @@ namespace sandbox if (m_pitch > 89.0f) m_pitch = 89.0f; if (m_pitch < -89.0f) m_pitch = -89.0f; - mt::vec3 front; - front.x = std::cos(mt::radians(m_yaw)) * std::cos(mt::radians(m_pitch)); - front.y = std::sin(mt::radians(m_pitch)); - front.z = std::sin(mt::radians(m_yaw)) * std::cos(mt::radians(m_pitch)); - m_front = mt::normalize(front); + glm::vec3 front; + front.x = std::cos(glm::radians(m_yaw)) * std::cos(glm::radians(m_pitch)); + front.y = std::sin(glm::radians(m_pitch)); + front.z = std::sin(glm::radians(m_yaw)) * std::cos(glm::radians(m_pitch)); + m_front = glm::normalize(front); } }; diff --git a/src/glfw/glfw.hpp b/src/glfw/glfw.hpp index 270a52c..86f3681 100755 --- a/src/glfw/glfw.hpp +++ b/src/glfw/glfw.hpp @@ -20,7 +20,7 @@ namespace VE // что не есть хорошо для умных указателей GLFWwindow* m_win; std::unique_ptr m_context; - mt::vec4 m_bgcolor = { 0.1f, 0.1f, 0.1f, 1.f }; + glm::vec4 m_bgcolor = { 0.1f, 0.1f, 0.1f, 1.f }; struct win_data { diff --git a/src/opengl/shader_program/shader_program.hpp b/src/opengl/shader_program/shader_program.hpp index 9744233..cc9aa66 100644 --- a/src/opengl/shader_program/shader_program.hpp +++ b/src/opengl/shader_program/shader_program.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "utils/utils.hpp" // IWYU pragma: keep namespace VE @@ -17,11 +19,11 @@ namespace VE GLuint get_id() const noexcept; public: - void set(std::string location, mt::vec2 value); - void set(std::string location, mt::vec3 value); - void set(std::string location, mt::vec4 value); - void set(std::string location, mt::mat3 value); - void set(std::string location, mt::mat4 value); + void set(std::string location, glm::vec2 value); + void set(std::string location, glm::vec3 value); + void set(std::string location, glm::vec4 value); + void set(std::string location, glm::mat3 value); + void set(std::string location, glm::mat4 value); void set(std::string location, float value); void set(std::string location, int value); diff --git a/src/utils/define.hpp b/src/utils/define.hpp index 8d99d85..b21c018 100755 --- a/src/utils/define.hpp +++ b/src/utils/define.hpp @@ -17,3 +17,5 @@ #define VE_PUSH_FONT(def_font, def_size)\ ImGui::PushFont(VE::style::fonts::get_font(VE::style::fonts::font_type::def_font, def_size)) #define VE_POP_FONT() ImGui::PopFont() + +#define VE_NAME(n) VE::func::name(n).data() diff --git a/src/utils/func.hpp b/src/utils/func.hpp new file mode 100644 index 0000000..ae6300e --- /dev/null +++ b/src/utils/func.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include + +#include + +namespace VE::func +{ + inline auto name(std::string n) + { + return "##" + n; + } + + inline ImU32 color(std::string hex, unsigned char alpha = 255) + { + if (hex[0] == '#') hex.erase(0, 1); + + unsigned int r = 255; + unsigned int g = 255; + unsigned int b = 255; + + if (hex.length() == 6) std::sscanf(hex.c_str(), "%2x%2x%2x", &r, &g, &b); + + return IM_COL32(r, g, b, alpha); + } +} diff --git a/src/utils/include.hpp b/src/utils/include.hpp index 7393336..0ffb320 100755 --- a/src/utils/include.hpp +++ b/src/utils/include.hpp @@ -22,10 +22,12 @@ второй это поставить glad первым */ -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include // IWYU pragma: keep -#include // IWYU pragma: keep +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/src/utils/math.hpp b/src/utils/math.hpp deleted file mode 100644 index a042035..0000000 --- a/src/utils/math.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include - -namespace mt -{ - using namespace glm; - - template - T convert(vec2& v) { return T{ v.x, v.y }; } - - template - T convert(vec3& v) { return T{ v.x, v.y, v.z }; } -} diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp index e0bafaa..34636f7 100644 --- a/src/utils/utils.hpp +++ b/src/utils/utils.hpp @@ -6,4 +6,4 @@ #include "var.hpp" // IWYU pragma: keep #include "include.hpp" // IWYU pragma: keep #include "using.hpp" // IWYU pragma: keep -#include "math.hpp" // IWYU pragma: keep +#include "func.hpp" // IWYU pragma: keep