0

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;
genpfault
  • 51,148
  • 11
  • 85
  • 139
Noctuaris
  • 1
  • 2
  • I tried using SOIL_load_image instead and it now works, I don't really understand why though. – Noctuaris Jan 07 '20 at 08:16
  • Do you have a valid OpenGL context at that point? What is the exact error message? Access violation reading/writing ... or Access violation executing ...? The only use of `strstr` in SOIL is `strstr( (char const*)glGetString( GL_EXTENSIONS ))`. – BDL Jan 07 '20 at 11:53
  • I have a valid OpenGL context I believe since I can render geometry (just not with textures) I get an access violation error when reading The exact error is : Exception thrown at 0x00007FFC41651C77 (vcruntime140.dll) in game.exe: 0xC0000005: Access violation reading location 0x0000000000000000 – Noctuaris Jan 07 '20 at 14:47
  • What's your OpenGL context version and is it a Core or Compatibility profile? – SurvivalMachine Jan 07 '20 at 17:06
  • I tried it with OpenGL 3.3 and 4.4, both with Core and Compatibility profile – Noctuaris Jan 07 '20 at 17:45
  • Wow, the issue, whatever it was, just decided to magically resolve itself. I still don't understand the least bit what was causing it, nor what I did to fix it, but thanks anyway. – Noctuaris Jan 07 '20 at 18:42
  • Okay my bad it's back. It seems to have to do with my integrated graphics chipset not being able to use glEnable(GL_TEXTURE_2D), even with a Compatibility profile, while my graphics card can handle it. – Noctuaris Jan 08 '20 at 07:24

0 Answers0