我在使用DevIL 1.7.8读取图像时遇到了问题。到目前为止,我知道以下代码片段应该可以工作:
ilInit();
ILuint ImageName;
ilGenImages(1, &ImageName);
ilBindImage(ImageName);
wchar_t* imgFilename = L"..\\..\\resources\\textures\\red.png";
ilLoadImage(imgFilename);
ILubyte* texture = ilGetData();当我检查第一个像素时
for (int i=0; i<64; i++) cout << (int)texture[i] << endl;我得到了一个相当随机的输出。这张照片实际上是完全红色的。
我也试着使用ilut
ilutRenderer(ILUT_OPENGL);
GLuint t = ilutGLLoadImage(L"..\\..\\resources\\textures\\red.png");但实际上我甚至不能包含相应的头文件,因为在那个头文件中链接了il.h,它应该在一个不存在的文件夹(\IL)中。即使当我创建这个文件夹并将所需的头文件复制到其中时,我也会遇到编译错误。
有人能帮我处理DevIL吗?
发布于 2015-05-03 07:47:43
我正在阅读图像和绑定纹理,如下所示:
ilEnable(IL_ORIGIN_SET);
ilOriginFunc(IL_ORIGIN_LOWER_LEFT); // set [0,0] of texture to bottom left corner
ilImage image;
GLuint ind;
glGenTextures(1, &ind);
glBindTexture(GL_TEXTURE_2D, ind);
image.Load(L"<path>");// or just name.format be sure to have image in correct folder.渲染时,需要先绑定正确的纹理:
glBindTexture(GL_TEXTURE_2D, ind);然后将纹理的UV坐标指定给顶点:
glTexCoord2f(x1, y1);
glVertex3f(x, y, z);不要忘记启用GL_TEXTURE_2D或您正在使用的任何类型。
https://stackoverflow.com/questions/10956442
复制相似问题