File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77
88using 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+
1025static std::ostream& operator <<(std::ostream& stream, ImVec2 const & vec) {
1126 return stream << vec.x << " , " << vec.y ;
1227}
Original file line number Diff line number Diff 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-
3217static bool g_useNormalPos = false ;
3318
3419CCPoint getMousePos_H () {
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ void GLRenderCtx::cleanup() {
4343GLRenderCtx::GLRenderCtx (ImVec2 const & size) : m_size(size) {}
4444
4545ImTextureID GLRenderCtx::texture () const {
46- return reinterpret_cast <ImTextureID>( static_cast < uintptr_t >( m_texture) );
46+ return textureID ( m_texture);
4747}
4848
4949ImVec2 GLRenderCtx::size () const {
You can’t perform that action at this time.
0 commit comments