From 90a7d2055d7069ea88030fd6ba77eb9a8c0c3766 Mon Sep 17 00:00:00 2001 From: touky Date: Tue, 22 Nov 2016 23:32:41 -0500 Subject: [PATCH] imgui vec conversion --- src/lolimgui.h | 13 +++++++++++++ src/textureimage.cpp | 5 +++++ src/textureimage.h | 1 + 3 files changed, 19 insertions(+) diff --git a/src/lolimgui.h b/src/lolimgui.h index 379e0c82..780c049d 100644 --- a/src/lolimgui.h +++ b/src/lolimgui.h @@ -12,8 +12,21 @@ #pragma once +#define IM_VEC2_CLASS_EXTRA ImVec2(const lol::vec2 &v) { x = v.x; y = v.y; } \ + ImVec2(const lol::ivec2 &v) : ImVec2(lol::vec2(v)) { } \ + operator lol::vec2() const { return lol::vec2(x, y); } \ + operator lol::ivec2() const { return lol::ivec2(lol::vec2(x, y)); } + +#define IM_VEC4_CLASS_EXTRA ImVec4(const lol::vec4 &v) { x = v.x; y = v.y; z = v.z; w = v.w; } \ + ImVec4(const lol::ivec4 &v) : ImVec4(lol::vec4(v)) { } \ + operator lol::vec4() { return lol::vec4(x, y, z, w); } \ + operator lol::ivec4() const { return lol::ivec4(lol::vec4(x, y, z, w)); } + #include "imgui.h" +#undef IM_VEC2_CLASS_EXTRA +#undef IM_VEC4_CLASS_EXTRA + //Imgui extension --------------------------------------------------------------------------------- typedef int ImGuiSetDock; // condition flags for Set*() // enum ImGuiSetCond_ diff --git a/src/textureimage.cpp b/src/textureimage.cpp index eb4f21e8..f3d6f3ed 100644 --- a/src/textureimage.cpp +++ b/src/textureimage.cpp @@ -162,6 +162,11 @@ Image const * TextureImage::GetImage() const return m_data->m_image; } +ivec2 TextureImage::GetImageSize() const +{ + return m_data->m_image_size; +} + ivec2 TextureImage::GetTextureSize() const { return m_data->m_texture_size; diff --git a/src/textureimage.h b/src/textureimage.h index 662586d6..307c33d7 100644 --- a/src/textureimage.h +++ b/src/textureimage.h @@ -57,6 +57,7 @@ public: Texture const * GetTexture() const; Image * GetImage(); Image const * GetImage() const; + ivec2 GetImageSize() const; ivec2 GetTextureSize() const; void Bind(); void Unbind();