"exception at 0x53C227FF (msvcr110d.dll)" with SOIL library
- by Sean M.
I'm creating a game in C++ using OpenGL, and decided to go with the SOIL library for image loading, as I have used it in the past to great effect. The problem is, in my newest game, trying to load an image with SOIL throws the following runtime error:
This error points to this part:
// SOIL.c
int query_NPOT_capability( void )
{
/* check for the capability */
if( has_NPOT_capability == SOIL_CAPABILITY_UNKNOWN )
{
/* we haven't yet checked for the capability, do so */
if(
(NULL == strstr( (char const*)glGetString( GL_EXTENSIONS ),
"GL_ARB_texture_non_power_of_two" ) )
) //############ it points here ############//
{
/* not there, flag the failure */
has_NPOT_capability = SOIL_CAPABILITY_NONE;
} else
{
/* it's there! */
has_NPOT_capability = SOIL_CAPABILITY_PRESENT;
}
}
/* let the user know if we can do non-power-of-two textures or not */
return has_NPOT_capability;
}
Since it points to the line where SOIL tries to access the OpenGL extensions, I think that for some reason SOIL is trying to load the texture before an OpenGL context is created. The problem is, I've gone through the entire solution, and there is only one place where SOIL has to load a texture, and it happens long after the OpenGL context is created.
This is the part where it loads the texture...
//Init glfw
if (!glfwInit())
{
fprintf(stderr, "GLFW Initialization has failed!\n");
exit(EXIT_FAILURE);
}
printf("GLFW Initialized.\n");
//Process the command line arguments
processCmdArgs(argc, argv);
//Create the window
glfwWindowHint(GLFW_SAMPLES, g_aaSamples);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
g_mainWindow = glfwCreateWindow(g_screenWidth, g_screenHeight, "Voxel Shipyard", g_fullScreen ? glfwGetPrimaryMonitor() : nullptr, nullptr);
if (!g_mainWindow)
{
fprintf(stderr, "Could not create GLFW window!\n");
closeOGL();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(g_mainWindow);
printf("Window and OpenGL rendering context created.\n");
//Create the internal rendering components
prepareScreen();
//Init glew
glewExperimental = GL_TRUE;
int err = glewInit();
if (err != GLEW_OK)
{
fprintf(stderr, "GLEW initialization failed!\n");
fprintf(stderr, "%s\n", glewGetErrorString(err));
closeOGL();
exit(EXIT_FAILURE);
}
printf("GLEW initialized.\n"); <-- Sucessfully creates an OpenGL context
//Initialize the app
g_app = new App();
g_app->PreInit();
g_app->Init();
g_app->PostInit(); <-- Loads the texture (after the context is created)
...and debug printing to the console CONFIRMS that the OpenGL context was created before the texture loading was attempted.
So my question is if anyone is familiar with this specific error, or knows if there is a specific instance as to why SOIL would think OpenGL isn't initialized yet.