Skip to content

Commit 45f314a

Browse files
committed
no textureID
1 parent 80fa63e commit 45f314a

3 files changed

Lines changed: 4 additions & 19 deletions

File tree

src/ImGui.hpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,6 @@
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-
2510
static std::ostream& operator<<(std::ostream& stream, ImVec2 const& vec) {
2611
return stream << vec.x << ", " << vec.y;
2712
}

src/backend.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void DevTools::setupPlatform() {
5757
m_fontTexture->initWithData(pixels, kCCTexture2DPixelFormat_RGBA8888, width, height, CCSize(width, height));
5858
m_fontTexture->retain();
5959

60-
io.Fonts->SetTexID(textureID(m_fontTexture->getName()));
60+
io.Fonts->SetTexID(reinterpret_cast<ImTextureID>(static_cast<std::uintptr_t>(m_fontTexture->getName())));
6161

6262
// fixes getMousePos to be relative to the GD view
6363
#ifndef GEODE_IS_MOBILE
@@ -219,7 +219,7 @@ void DevTools::renderDrawDataFallback(ImDrawData* draw_data) {
219219
auto* idxBuffer = list->IdxBuffer.Data;
220220
auto* vtxBuffer = list->VtxBuffer.Data;
221221
for (auto& cmd : list->CmdBuffer) {
222-
ccGLBindTexture2D(textureID(cmd.GetTexID()));
222+
ccGLBindTexture2D(static_cast<GLuint>(reinterpret_cast<std::uintptr_t>(cmd.GetTexID())));
223223

224224
const auto rect = cmd.ClipRect;
225225
const auto orig = toCocos(ImVec2(rect.x, rect.y));
@@ -306,7 +306,7 @@ void DevTools::renderDrawData(ImDrawData* draw_data) {
306306
glBufferData(GL_ELEMENT_ARRAY_BUFFER, list->IdxBuffer.Size * sizeof(ImDrawIdx), list->IdxBuffer.Data, GL_STREAM_DRAW);
307307

308308
for (auto& cmd : list->CmdBuffer) {
309-
ccGLBindTexture2D(textureID(cmd.GetTexID()));
309+
ccGLBindTexture2D(static_cast<GLuint>(reinterpret_cast<std::uintptr_t>(cmd.GetTexID())));
310310

311311
const auto rect = cmd.ClipRect;
312312
const auto orig = toCocos(ImVec2(rect.x, rect.y));

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 textureID(m_texture);
46+
return reinterpret_cast<ImTextureID>(static_cast<std::uintptr_t>(m_texture));
4747
}
4848

4949
ImVec2 GLRenderCtx::size() const {

0 commit comments

Comments
 (0)