Error when loading texture with SOIL_load_OGL_texture

445 Views Asked by At

I'm currently working on a little 3d renderer and was trying to add textures. Thing is when I try to load the texture using SOIL_load_OGL_texture I get an access violation error with vcruntime140d.dll .

I saw another post here with a similar error, but it was coming from the fact that the user had apparently not created an OpenGL context when trying to load the texture, which I have done.

The error has something to do with a string being a nullptr int the strstr() function of vcruntime140d.dll

Here is a screenshot of the call stack : call stack

EDIT : here is code producing the error :

std::string stringPath = texturePath.string();

std::cout << "Loading texture : " << stringPath.c_str() << std::endl;

glEnable(GL_TEXTURE_2D);

GLuint textureID = SOIL_load_OGL_texture(stringPath.c_str(), SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_POWER_OF_TWO | SOIL_FLAG_MIPMAPS);

if (textureID == 0)
{
    printf("SOIL loading error: '%s'\n", SOIL_last_result());
    return -1;
}

glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

m_textures.emplace(texturePath, textureID);

return textureID;
0

There are 0 best solutions below