Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Fix some minor issues with GL loader
Browse files Browse the repository at this point in the history
fixes #258
  • Loading branch information
sfan5 committed Dec 17, 2023
1 parent c58d50a commit 6f4dff7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
6 changes: 3 additions & 3 deletions include/mt_opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,9 +780,9 @@ class OpenGLProcedures {
// 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;
Expand Down Expand Up @@ -3191,5 +3191,5 @@ class OpenGLProcedures {
static constexpr const GLenum NONE = 0;
};

//Global GL procedures object.
// Global GL procedures object.
IRRLICHT_API extern OpenGLProcedures GL;
17 changes: 10 additions & 7 deletions scripts/BindingGenerator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
]];
Expand All @@ -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();

Expand All @@ -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
Expand Down
11 changes: 7 additions & 4 deletions source/Irrlicht/mt_opengl_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6f4dff7

Please sign in to comment.