emilk/imgui_software_renderer

Update to latest imgui

JamesDunne opened this issue · 2 comments

Is it feasible to upgrade this code against latest imgui? I'd love to use this for a project of mine but it's 2 years old at this point. Granted, it runs fine on that older version but I don't want to start out on a known out of date version of imgui. Thanks!

Figured it out... here's a patch on commit b5ae63a9e42eccf7db3bf64696761a53424c53dd:

diff --git a/src/libs.cpp b/src/libs.cpp
index 48cacff..0c2fbb6 100644
--- a/src/libs.cpp
+++ b/src/libs.cpp
@@ -2,8 +2,7 @@
 #include <imgui/imgui_demo.cpp>
 #include <imgui/imgui_draw.cpp>

-#define LOGURU_IMPLEMENTATION 1
-#include <loguru.hpp>
+#include <loguru.cpp>

 #include <emilib/imgui_helpers.cpp>
 #include <emilib/imgui_sdl.cpp>

and a related patch for master branch of emilib based on commit 0d90f4c0cd44813f6898b417bf3f4ef574a5b136:

diff --git a/emilib/imgui_helpers.cpp b/emilib/imgui_helpers.cpp
index 2b50b85..4d1318e 100644
--- a/emilib/imgui_helpers.cpp
+++ b/emilib/imgui_helpers.cpp
@@ -98,7 +98,7 @@ bool SliderSize(const std::string& label, size_t* v, size_t v_min, size_t v_max,
     return changed;
 }

-bool InputText(const std::string& label, std::string& text, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data)
+bool InputText(const std::string& label, std::string& text, ImGuiInputTextFlags flags, ImGuiTextEditCallback callback, void* user_data)
 {
     char buff[1024];
     strncpy(buff, text.c_str(), sizeof(buff));
diff --git a/emilib/imgui_helpers.hpp b/emilib/imgui_helpers.hpp
index b3a32e1..cf813f2 100644
--- a/emilib/imgui_helpers.hpp
+++ b/emilib/imgui_helpers.hpp
@@ -13,6 +13,7 @@

 #include <imgui/imgui.h>

+#if 0
 static inline ImVec2 operator*(const ImVec2& lhs, const float rhs)              { return ImVec2(lhs.x*rhs, lhs.y*rhs); }
 static inline ImVec2 operator/(const ImVec2& lhs, const float rhs)              { return ImVec2(lhs.x/rhs, lhs.y/rhs); }
 static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs)            { return ImVec2(lhs.x+rhs.x, lhs.y+rhs.y); }
@@ -26,6 +27,7 @@ static inline ImVec2& operator/=(ImVec2& lhs, const float rhs)
 static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs)            { return ImVec4(lhs.x+rhs.x, lhs.y+rhs.y, lhs.z+rhs.z, lhs.w+rhs.w); }
 static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs)            { return ImVec4(lhs.x-rhs.x, lhs.y-rhs.y, lhs.z-rhs.z, lhs.w-rhs.w); }
 static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs)            { return ImVec4(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z, lhs.w*rhs.w); }
+#endif

 namespace imgui_helpers {

@@ -53,7 +55,7 @@ namespace ImGuiPP {

 bool SliderSize(const std::string& label, size_t* v, size_t v_min, size_t v_max, float power = 1.0f);

-bool InputText(const std::string& label, std::string& text, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL);
+bool InputText(const std::string& label, std::string& text, ImGuiInputTextFlags flags = 0, ImGuiTextEditCallback callback = NULL, void* user_data = NULL);
 void Text(const std::string& text);
 void LabelText(const std::string& label, const std::string& text);
 bool Button(const std::string& text);

Hope that helps!

emilk commented

The core of this repo are imgui_sw.hpp and imgui_sw.cpp. Those are the files I expect someone to pluck out and plug in to their own backend.

I used main.cpp and libs.cpp (and emilib) mostly as a test to see that the software renderer works. I would guess rewriting those tests (your own SDL2 bind code) is less work than upgrading all of emilib.

Anyway, this project is in my past (as is emilib). I can review and test PRs but I won't be spending time writing code.