Fix some minor issues with GL loader

fixes #258
This commit is contained in:
sfan5 2023-12-17 18:10:39 +01:00
parent 0110826ce9
commit 6e6b4a6f3c
3 changed files with 20 additions and 14 deletions

@ -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;

@ -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

@ -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