I'm trying to load a texture using stbi_load()
. Here's my code:
int width, height, numComponents;
unsigned char* imgData = stbi_load(fileName.c_str(), &width, &height, &numComponents, 4);
if (imgData == NULL)
cout << "Cannot load texture" << endl;
//some code
//free
stbi_image_free(imgData);
And when I run the program, it says Cannot load texture
. I don't know what's wrong. I am sure that the filename is a valid path, because when I write:
std::ifstream infile(fileName);
if (infile.good())
{
cout << "Good" << endl;
}
else
{
cout << "Not good" << endl;
}
It produces Good
. Can someone tell me what is wrong with this code that causes imgData
to be NULL
(The image is a *.jpg
file, if anybody was wondering). Any help would be highly appreciated!
Edit : I ran stbi_failure_reason()
and it returned progressive jpeg
. What does this mean ?
stbi_failure_reason()
and it returnedprogressive jpeg
. What does this mean ?