![](/img/trans.png)
[英]Access violation when calling glTextureParameteri with OpenGL and DevIL
[英]Devil iluErrorString() causing access violation
请看看我第一天VC ++的结果。 它包含一个我知道的错误。 我的问题是魔鬼应该出现一个错误,但是尝试使用iluErrorString()将错误解码为字符串会导致访问冲突...
#pragma comment(lib, "ILU.lib")
#pragma comment(lib, "ILUT.lib")
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <IL/il.h>
#include <IL/ilu.h>
#include <IL/ilut.h>
using namespace std;
int main(){
FILE *myFile;
ILuint fileSize;
ILubyte *Lump;
ilInit();
ILuint ImageName; // The image name to return.
ilGenImages(1, &ImageName); // Grab a new image name.
ilBindImage(ImageName); //bind the image
myFile = fopen("C:/Documents and Settings/Bartjan/Desktop/c++ meuq/test/Debug/image.png", "r"); //open the file for reading
if (myFile != NULL){
fseek(myFile, 0, SEEK_END); //get file size
fileSize = ftell(myFile);
Lump = (ILubyte*)malloc(fileSize); //allocate mem
fseek(myFile, 0, SEEK_SET); //set the file pointer
fread(Lump, 1, fileSize, myFile); //read the entire file into mem
fclose(myFile);
ilLoadL(IL_PNG, Lump, fileSize);
free(Lump);
}
ilDeleteImages(1, &ImageName); //delete the image
ILenum error;
while ((error = ilGetError()) != IL_NO_ERROR) {
cout << error << ": " << iluErrorString(error);
}
_getch();
return 0;
}
它咳出一个错误1285,这意味着它不明白:
ilLoadL(IL_PNG, Lump, fileSize);
我知道这一点。 问题在这里:
cout << error << ": " << iluErrorString(error);
这会导致访问冲突,我不知道为什么?
如果您没有像对IL那样初始化ILU,则会出现此问题:
iluInit();
这是因为iluErrorString和ilGetString一样总是返回0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.