Преглед изворни кода

IMGUI_STB_NAMESPACE define Stb stuff in a namespace (trying stuff to reduce problems with multiple implementations)

ocornut пре 10 година
родитељ
комит
26f93e6660
1 измењених фајлова са 16 додато и 1 уклоњено
  1. 16 1
      imgui.cpp

+ 16 - 1
imgui.cpp

@@ -331,6 +331,15 @@
 // STB libraries implementation
 //-------------------------------------------------------------------------
 
+struct ImGuiTextEditState;
+
+//#define IMGUI_STB_NAMESPACE     ImStb
+
+#ifdef IMGUI_STB_NAMESPACE
+namespace IMGUI_STB_NAMESPACE
+{
+#endif
+
 #ifdef __clang__
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wunused-function"
@@ -338,15 +347,16 @@
 #endif
 
 #define STBRP_STATIC
+#define STBRP_ASSERT(x)    IM_ASSERT(x)
 #define STB_RECT_PACK_IMPLEMENTATION
 #include "stb_rect_pack.h"
 
 #define STB_TRUETYPE_IMPLEMENTATION
 #define STBTT_malloc(x,u)  ((void)(u), ImGui::MemAlloc(x))
 #define STBTT_free(x,u)    ((void)(u), ImGui::MemFree(x))
+#define STBTT_assert(x)    IM_ASSERT(x)
 #include "stb_truetype.h"
 
-struct ImGuiTextEditState;
 #define STB_TEXTEDIT_STRING ImGuiTextEditState
 #define STB_TEXTEDIT_CHARTYPE ImWchar
 #include "stb_textedit.h"
@@ -355,6 +365,11 @@ struct ImGuiTextEditState;
 #pragma clang diagnostic pop
 #endif
 
+#ifdef IMGUI_STB_NAMESPACE
+} // namespace ImStb
+using namespace IMGUI_STB_NAMESPACE;
+#endif
+
 //-------------------------------------------------------------------------
 // Forward Declarations
 //-------------------------------------------------------------------------