When I am starting my program to run using VS2019 local debuger everything works perfectly fine. When I am opening .exe file, my program cannot find these files. I am trying to launch my program from x64/Debug folder in my project repo folder.
Screenshot from my console debug
My first thought were about path. I included full path to my .PNG file, but my program cannot find it anyway.
Here is the code I am using with loading texture file:
Texture texSpecularMap;
if (!texSpecularMap.LoadPNG("assets/textures/container_specular_map.png"))
{
Debug::logWarning("Failed to load texture: assets/textures/container_specular_map.png");
}
bool Texture::LoadPNG(const char* filePath)
{
stbi_set_flip_vertically_on_load(true);
unsigned char* data = stbi_load(filePath, &width, &height, &nChannels, 0);
if (data) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
}
else
{
return false;
}
stbi_image_free(data);
return true;
}
Don't look at my stupid warning messeges. I know I should specify a variable storing path.
When loading images with stb_image, stbi_failure_reason() is you best friend. The best thing you can do is give a absolute path to the file.