diff --git a/include/mt_opengl.h b/include/mt_opengl.h index 46e68bf..32d3f1c 100755 --- a/include/mt_opengl.h +++ b/include/mt_opengl.h @@ -780,9 +780,9 @@ public: // Call this once after creating the context. void LoadAllProcedures(irr::video::IContextManager *cmgr); // Check if an extension is supported. - inline bool IsExtensionPresent(const std::string &ext) + inline bool IsExtensionPresent(const std::string &ext) const { - return extensions.find(ext) != extensions.end(); + return extensions.count(ext) > 0; } PFNGLCULLFACEPROC_MT CullFace = NULL; @@ -3191,5 +3191,5 @@ public: static constexpr const GLenum NONE = 0; }; -//Global GL procedures object. +// Global GL procedures object. IRRLICHT_API extern OpenGLProcedures GL; diff --git a/scripts/BindingGenerator.lua b/scripts/BindingGenerator.lua index 4b70339..366ec48 100755 --- a/scripts/BindingGenerator.lua +++ b/scripts/BindingGenerator.lua @@ -387,9 +387,9 @@ public: // Call this once after creating the context. void LoadAllProcedures(irr::video::IContextManager *cmgr); // Check if an extension is supported. - inline bool IsExtensionPresent(const std::string &ext) + inline bool IsExtensionPresent(const std::string &ext) const { - return extensions.find(ext) != extensions.end(); + return extensions.count(ext) > 0; } ]]; @@ -403,7 +403,7 @@ f:write[[ static constexpr const GLenum NONE = 0; ]]; f:write( "};\n" ); -f:write( "\n//Global GL procedures object.\n" ); +f:write( "\n// Global GL procedures object.\n" ); f:write( "IRRLICHT_API extern OpenGLProcedures GL;\n" ); f:close(); @@ -427,12 +427,15 @@ f:write( loader:Concat() ); f:write[[ // OpenGL 3 way to enumerate extensions - int ext_count = 0; + GLint ext_count = 0; GetIntegerv(NUM_EXTENSIONS, &ext_count); extensions.reserve(ext_count); - for (int k = 0; k < ext_count; k++) - extensions.emplace((char *)GetStringi(EXTENSIONS, k)); - if (ext_count) + for (GLint k = 0; k < ext_count; k++) { + auto tmp = GetStringi(EXTENSIONS, k); + if (tmp) + extensions.emplace((char*)tmp); + } + if (!extensions.empty()) return; // OpenGL 2 / ES 2 way to enumerate extensions diff --git a/source/Irrlicht/mt_opengl_loader.cpp b/source/Irrlicht/mt_opengl_loader.cpp index 0233774..084f831 100755 --- a/source/Irrlicht/mt_opengl_loader.cpp +++ b/source/Irrlicht/mt_opengl_loader.cpp @@ -759,12 +759,15 @@ void OpenGLProcedures::LoadAllProcedures(irr::video::IContextManager *cmgr) if (!TexPageCommitment) TexPageCommitment = (PFNGLTEXPAGECOMMITMENTPROC_MT)cmgr->getProcAddress("glTexPageCommitmentARB"); // OpenGL 3 way to enumerate extensions - int ext_count = 0; + GLint ext_count = 0; GetIntegerv(NUM_EXTENSIONS, &ext_count); extensions.reserve(ext_count); - for (int k = 0; k < ext_count; k++) - extensions.emplace((char *)GetStringi(EXTENSIONS, k)); - if (ext_count) + for (GLint k = 0; k < ext_count; k++) { + auto tmp = GetStringi(EXTENSIONS, k); + if (tmp) + extensions.emplace((char*)tmp); + } + if (!extensions.empty()) return; // OpenGL 2 / ES 2 way to enumerate extensions