diff --git a/ImCurveEdit.cpp b/ImCurveEdit.cpp index 1ca60f17..f9d03b8d 100644 --- a/ImCurveEdit.cpp +++ b/ImCurveEdit.cpp @@ -5,8 +5,12 @@ #include #include -#if !defined(_MSC_VER) +#if defined(_MSC_VER) || defined(__MINGW32__) +#include +#endif +#if !defined(_MSC_VER) && !defined(__MINGW64_VERSION_MAJOR) #define _malloca(x) alloca(x) +#define _freea(x) #endif namespace ImCurveEdit diff --git a/ImGuizmo.cpp b/ImGuizmo.cpp index 3a22a262..ff0d6e28 100644 --- a/ImGuizmo.cpp +++ b/ImGuizmo.cpp @@ -26,11 +26,13 @@ #endif #include "imgui_internal.h" #include "ImGuizmo.h" -#if !defined(_WIN32) + +#if defined(_MSC_VER) || defined(__MINGW32__) +#include +#endif +#if !defined(_MSC_VER) && !defined(__MINGW64_VERSION_MAJOR) #define _malloca(x) alloca(x) #define _freea(x) -#else -#include #endif // includes patches for multiview from diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..bc86a5d4 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +CXXFLAGS=-std=c++11 +CPPFLAGS=-I. -Iexample + +LIB_OBJS = ImGuizmo.o GraphEditor.o ImCurveEdit.o ImGradient.o ImSequencer.o +EXAMPLE_OBJS = example/imgui.o example/imgui_draw.o example/imgui_tables.o example/imgui_widgets.o example/main.o + +EXAMPLE_NAME = example.exe +LDFLAGS=-mwindows -static-libgcc -static-libstdc++ +LIBS=-limm32 -lopengl32 -lgdi32 + +$(EXAMPLE_NAME): $(LIB_OBJS) $(EXAMPLE_OBJS) + $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS) + +example/main.o: CXXFLAGS := -std=c++17 + +clean: + $(RM) $(LIB_OBJS) + $(RM) $(EXAMPLE_OBJS) + $(RM) $(EXAMPLE_NAME) diff --git a/example/ImApp.h b/example/ImApp.h index 83606ae6..df59a2a3 100644 --- a/example/ImApp.h +++ b/example/ImApp.h @@ -1,12 +1,14 @@ #pragma once +#include // intptr_t + #if defined(_WIN32) // dont bother adding library #pragma comment(lib,"opengl32.lib") #define WINDOWS_LEAN_AND_MEAN #include #include -# define glGetProcAddress(name) wglGetProcAddress((LPCSTR)name) +# define glGetProcAddress(name) (void *)wglGetProcAddress((LPCSTR)name) #elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) # define glGetProcAddress(name) NSGLGetProcAddress(name) #elif defined(__sgi) || defined(__sun) @@ -2579,7 +2581,7 @@ typedef float GLfloat; #else #define GLEXTERN #endif -#ifdef _MSC_VER +#ifdef _WIN32 GLEXTERN void(APIENTRY* glActiveTexture) (GLenum texture); #endif GLEXTERN void(APIENTRY* glUniform1i) (GLint location, GLint v0); @@ -2699,7 +2701,7 @@ namespace ImApp info->hInstance = GetModuleHandle(0); static DEVMODEA screenSettings = { { 0 }, -#if _MSC_VER < 1400 +#if defined(_MSC_VER) && _MSC_VER < 1400 0,0,148,0,0x001c0000,{ 0 },0,0,0,0,0,0,0,0,0,{ 0 },0,32,config.mWidth,config.mHeight,0,0, // Visual C++ 6.0 #else 0,0,156,0,0x001c0000,{ 0 },0,0,0,0,0,{ 0 },0,32,static_cast(config.mWidth), static_cast(config.mHeight),{ 0 }, 0, // Visuatl Studio 2005 @@ -2996,7 +2998,7 @@ namespace ImApp LE(glUniform1i); //GLint location, GLint v0); LE(glUniformMatrix3fv) // GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -#ifdef _MSC_VER +#ifdef _WIN32 LE(glActiveTexture); //GLenum texture); #endif LE(glBindFramebuffer); //GLenum target, TextureID framebuffer); @@ -3085,7 +3087,7 @@ namespace ImApp static bool IsAnyMouseButtonDown() { ImGuiIO& io = ImGui::GetIO(); - for (int n = 0; n < ARRAYSIZE(io.MouseDown); n++) + for (int n = 0; n < IM_ARRAYSIZE(io.MouseDown); n++) if (io.MouseDown[n]) return true; return false; diff --git a/example/main.cpp b/example/main.cpp index cf51f59f..76890e23 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -1,4 +1,6 @@ #include "imgui.h" +#define IMGUI_DEFINE_MATH_OPERATORS +#include "imgui_internal.h" #define IMAPP_IMPL #include "ImApp.h" @@ -11,14 +13,6 @@ #include #include -#include "imgui_internal.h" -// -// -// ImGuizmo example helper functions -// -// -static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x - rhs.x, lhs.y - rhs.y); } - bool useWindow = true; int gizmoCount = 1; float camDistance = 8.f; @@ -398,7 +392,7 @@ struct MySequence : public ImSequencer::SequenceInterface virtual const char* GetItemLabel(int index) const { static char tmps[512]; - sprintf_s(tmps, "[%02d] %s", index, SequencerItemTypeNames[myItems[index].mType]); + snprintf(tmps, 512, "[%02d] %s", index, SequencerItemTypeNames[myItems[index].mType]); return tmps; }