From 81fbfeffbb393f59fd382da9aabf669e9fa8b742 Mon Sep 17 00:00:00 2001 From: chatlanin Date: Tue, 26 Sep 2023 10:11:54 +0300 Subject: [PATCH] add base implementation define and imgui window name --- .projectile | 0 src/sandbox/layers/test_panel/test_panel.cpp | 2 +- src/sandbox/layers/test_panel/test_panel.hpp | 14 +------------- src/try_engine/layer/layer.hpp | 6 +----- src/try_engine/renderer/texture/texture.hpp | 4 ++++ src/try_engine/utils/define.hpp | 19 +++++++++++++++++-- 6 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 .projectile diff --git a/.projectile b/.projectile new file mode 100644 index 0000000..e69de29 diff --git a/src/sandbox/layers/test_panel/test_panel.cpp b/src/sandbox/layers/test_panel/test_panel.cpp index 71d01cc..55b1701 100755 --- a/src/sandbox/layers/test_panel/test_panel.cpp +++ b/src/sandbox/layers/test_panel/test_panel.cpp @@ -19,7 +19,7 @@ namespace tr::layers ImGui::SetNextWindowPos(ImVec2(pos_x, pos_y)); ImGui::SetNextWindowSize(ImVec2(width, height)); - BEGIN_IMGUI_WIN(); + BEGIN_IMGUI_WIN("test_win"); if (ImGui::Button("RUN", ImVec2(28, 30))) { em->execute(std::string("asdf"), "asdf"); diff --git a/src/sandbox/layers/test_panel/test_panel.hpp b/src/sandbox/layers/test_panel/test_panel.hpp index 33081b7..3cf73d1 100755 --- a/src/sandbox/layers/test_panel/test_panel.hpp +++ b/src/sandbox/layers/test_panel/test_panel.hpp @@ -6,22 +6,10 @@ namespace tr::layers { class test_panel : public try_engine::layer { - BASE_TYPE_DEFINE(); - - public: - CONSTRUCT_IMPL(test_panel); - - public: - BASE_OVERIDE_IMPL(); - - public: - SET_EVENT_MANAGER_IMPL(); + BASE_IMPL(test_panel); private: - FLAGS_STRUCT_DEFINED(); - bool show = true; - event_manager* em; float width = 720.f; float height = 480.f; diff --git a/src/try_engine/layer/layer.hpp b/src/try_engine/layer/layer.hpp index 8c8ebfc..b7b2801 100755 --- a/src/try_engine/layer/layer.hpp +++ b/src/try_engine/layer/layer.hpp @@ -10,7 +10,7 @@ namespace try_engine using time = time::timestep; public: - layer(const std::string& name_) : name { name_ } {}; + layer() = default; virtual ~layer() = default; layer(const layer&) = delete; @@ -23,10 +23,6 @@ namespace try_engine virtual void on_event(system_event::event&) {}; virtual void on_event(std::any, std::any) {}; virtual void on_update(time) = 0; - const std::string& get_name() const { return name; }; - - protected: - std::string name; }; } diff --git a/src/try_engine/renderer/texture/texture.hpp b/src/try_engine/renderer/texture/texture.hpp index 6850845..74853eb 100755 --- a/src/try_engine/renderer/texture/texture.hpp +++ b/src/try_engine/renderer/texture/texture.hpp @@ -14,6 +14,9 @@ namespace try_engine template void bind(Image& image) { + // HERE наяинаем тут + // возможно эту штуку нужно делать сразу полсе make + // либо перенеси ее в make glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.cols, image.rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, image.data); } @@ -25,3 +28,4 @@ namespace try_engine GLuint texture_id = 0; }; } + diff --git a/src/try_engine/utils/define.hpp b/src/try_engine/utils/define.hpp index 2cd3399..b81f47a 100755 --- a/src/try_engine/utils/define.hpp +++ b/src/try_engine/utils/define.hpp @@ -41,7 +41,7 @@ void on_update(time t) override #define CONSTRUCT_IMPL(name)\ - name() : try_engine::layer { ""#name"" } { BASE_WINDOW_FLAGS(); };\ + name() : try_engine::layer() { BASE_WINDOW_FLAGS(); };\ ~name() = default #define FLAGS_STRUCT_DEFINED()\ @@ -61,7 +61,22 @@ } f;\ ImGuiWindowFlags window_flags = 0 -#define BEGIN_IMGUI_WIN() if (!ImGui::Begin(name.c_str(), &f.p_open, window_flags)) ImGui::End() + +#define BASE_IMPL(name)\ + BASE_TYPE_DEFINE();\ + public:\ + CONSTRUCT_IMPL(name);\ + public:\ + BASE_OVERIDE_IMPL();\ + public:\ + SET_EVENT_MANAGER_IMPL();\ + private:\ + FLAGS_STRUCT_DEFINED();\ + private:\ + event_manager* em + + +#define BEGIN_IMGUI_WIN(name) if (!ImGui::Begin(name, &f.p_open, window_flags)) ImGui::End() #define END_IMGUI_WIN() ImGui::End() #define TR_PUSH_FONT(def_font, def_size)\