所以我正在学习如何使用OpenGL(找到here)并尝试加载第6课中的图像。
我遇到的问题是我无法加载文件。我收到IL_INVALID_EXTENTION错误代码(1291)。首先是代码示例:
// Here is the code calling the load function
if (!gTexture.loadTextureFromFile("LazyFooTutorials/texture.png"))
{
printf("Unable to load texture from file...\n");
return false;
}
// Here is the code that calls ResIL
bool LTexture::loadTextureFromFile(std::string path) {
bool textureLoaded = false;
ILuint imgID = 0;
ilGenImages(1, &imgID);
ilBindImage(imgID);
ILboolean success = ilLoadImage(path.c_str());
if (success == IL_TRUE)
{
success = ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
if (success == IL_TRUE)
{
textureLoaded = loadTextureFromPixels32((GLuint*)ilGetData(), (GLuint)ilGetInteger(IL_IMAGE_WIDTH), (GLuint)ilGetInteger(IL_IMAGE_HEIGHT));
}
ilDeleteImages(1, &imgID);
}
if (!textureLoaded)
{
printf("Failed to load image: %s\n", path.c_str());
}
return textureLoaded;
}
我认为ResIL可以加载png,我会去查找ResIL文档,以便我可以验证。