Skip to content

Commit

Permalink
_AssertOpenGlLoaderWorking(): log if OpenGl Loader not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Sep 17, 2024
1 parent 50cab09 commit afe556c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/immvision/internal/gl/gl_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace ImmVision_GlProvider
if ((glGenTexturesAddress == 0) || (glDeleteTexturesAddress == 0))
{
#if defined(IMMVISION_USE_GLAD)
fprintf(stderr, "OpenGL Loader was not initialized yet! Trying to initialize it with current OpenGL settings...\n"
"This may fail. If it does, please make sure to call OpenGL functions after the app is initialized.\n");
gladLoadGL();
glGenTexturesAddress = (size_t)glGenTextures;
glDeleteTexturesAddress = (size_t)glDeleteTextures;
Expand All @@ -32,10 +34,7 @@ namespace ImmVision_GlProvider

if ((glGenTexturesAddress == 0) || (glDeleteTexturesAddress == 0))
{
const char* err_msg = "glGenTextures/glDeleteTexturesAddress address not initialized. Is your your OpenGL Loader initialized?";
std::cerr << err_msg;
assert(false);
throw std::runtime_error(err_msg);
IM_ASSERT(false && "OpenGL Loader was not initialized yet!");
}
}

Expand Down
7 changes: 3 additions & 4 deletions src_all_in_one/immvision/immvision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7143,6 +7143,8 @@ namespace ImmVision_GlProvider
if ((glGenTexturesAddress == 0) || (glDeleteTexturesAddress == 0))
{
#if defined(IMMVISION_USE_GLAD)
fprintf(stderr, "OpenGL Loader was not initialized yet! Trying to initialize it with current OpenGL settings...\n"
"This may fail. If it does, please make sure to call OpenGL functions after the app is initialized.\n");
gladLoadGL();
glGenTexturesAddress = (size_t)glGenTextures;
glDeleteTexturesAddress = (size_t)glDeleteTextures;
Expand All @@ -7151,10 +7153,7 @@ namespace ImmVision_GlProvider

if ((glGenTexturesAddress == 0) || (glDeleteTexturesAddress == 0))
{
const char* err_msg = "glGenTextures/glDeleteTexturesAddress address not initialized. Is your your OpenGL Loader initialized?";
std::cerr << err_msg;
assert(false);
throw std::runtime_error(err_msg);
IM_ASSERT(false && "OpenGL Loader was not initialized yet!");
}
}

Expand Down

0 comments on commit afe556c

Please sign in to comment.