int width, height, nrChannels;
stbi_set_flip_vertically_on_load(true); // tell stb_image.h to flip loaded texture's on the y-axis.
unsigned char* data = stbi_load("container.jpg", &width, &height, &nrChannels, 0);
std::ifstream infile("container.jpg");
if (infile.good())
{
std::cout << "Good" << std::endl;
}
else
{
std::cout << "Not good" << std::endl;
}
if (data)
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
}
else
{
std::cout << "Failed to load texture" << std::endl;
}
stbi_image_free(data);
进入文件返回的是good 但是fail to load texture