我有一个关于在 VS 2010 中使用 DevIL 的问题。我正在尝试加载图像以作为纹理应用于精灵,但我似乎无法弄清楚如何将图像添加到项目中以便 DevIL 可以找到它. 对 ilLoadImage 的调用不断返回 false。
void LoadTexture(string path)
{
wstring widePath = wstring(path.begin(), path.end());
const wchar_t* pathName = widePath.c_str();
ILuint devilId = 0;
ilGenImages(1, &devilId);
ilBindImage(devilId);
if(!ilLoadImage(pathName))
{
ILenum error = ilGetError();
const wchar_t* errorString = iluErrorString(error);
cout << *errorString << endl;
exit(0);
}
iluFlipImage();
int width = ilGetInteger(IL_IMAGE_WIDTH);
int height = ilGetInteger(IL_IMAGE_HEIGHT);
int openGLId = ilutGLBindTexImage();
if(openGLId = 0)
{
cout << "The OpenGL id was not set." << endl;
exit(0);
}
ilDeleteImages(1, &devilId);
}
void InitializeTextures()
{
ilInit();
iluInit();
ilutInit();
ilutRenderer(ILUT_OPENGL);
LoadTexture("dungeon_textures-200413-SM.jpg");
}