Skip to content

Commit 9e01079

Browse files
committed
oh i forgot a thing in platform.cpp
1 parent e5f54f2 commit 9e01079

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/ImGui.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@
77

88
using namespace cocos2d;
99

10+
// little helper function to convert ImTexture2D <=> GLuint,
11+
// supporting both versions of imgui where this was a void* and is now a u64
12+
// (templated because c++ is stupid)
13+
template <class T = ImTextureID>
14+
static auto textureID(auto value) {
15+
if constexpr (std::is_same_v<decltype(value), GLuint>) { // GLuint -> ImTextureID
16+
if constexpr (std::is_same_v<T, void*>) return reinterpret_cast<T>(static_cast<std::uintptr_t>(value));
17+
else return static_cast<T>(value);
18+
}
19+
else { // ImTextureID -> GLuint
20+
if constexpr (std::is_same_v<T, void*>) return static_cast<GLuint>(reinterpret_cast<std::uintptr_t>(value));
21+
else return static_cast<GLuint>(value);
22+
}
23+
}
24+
1025
static std::ostream& operator<<(std::ostream& stream, ImVec2 const& vec) {
1126
return stream << vec.x << ", " << vec.y;
1227
}

src/backend.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@ using namespace cocos2d;
1414

1515
// based off https://github.com/matcool/gd-imgui-cocos
1616

17-
// little helper function to convert ImTexture2D <=> GLuint,
18-
// supporting both versions of imgui where this was a void* and is now a u64
19-
// (templated because c++ is stupid)
20-
template <class T = ImTextureID>
21-
static auto textureID(auto value) {
22-
if constexpr (std::is_same_v<decltype(value), GLuint>) { // GLuint -> ImTextureID
23-
if constexpr (std::is_same_v<T, void*>) return reinterpret_cast<T>(static_cast<std::uintptr_t>(value));
24-
else return static_cast<T>(value);
25-
}
26-
else { // ImTextureID -> GLuint
27-
if constexpr (std::is_same_v<T, void*>) return static_cast<GLuint>(reinterpret_cast<std::uintptr_t>(value));
28-
else return static_cast<GLuint>(value);
29-
}
30-
}
31-
3217
static bool g_useNormalPos = false;
3318

3419
CCPoint getMousePos_H() {

src/platform/platform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void GLRenderCtx::cleanup() {
4343
GLRenderCtx::GLRenderCtx(ImVec2 const& size) : m_size(size) {}
4444

4545
ImTextureID GLRenderCtx::texture() const {
46-
return reinterpret_cast<ImTextureID>(static_cast<uintptr_t>(m_texture));
46+
return textureID(m_texture);
4747
}
4848

4949
ImVec2 GLRenderCtx::size() const {

0 commit comments

Comments
 (0)