Skip to main content
GameDev.net gamedev.net
🔒 Locked

ilutGLBindTexImage creates a 1*1 texture

Started by Adrian Bibby Walther Aug 23, 2012 at 8:46 AM 0 replies 2.6k views
Original Post
Adrian Bibby Walther
Adrian Bibby Walther
I have been trying to solve this for some time, but after googling and googling, again ang again. I finally decided to post it here.
I use the following code to load a texture into OpenGL, using DevIL:

bool CImage::Load(const std::string &File){
Clear();
ILuint Image;
ilGenImages(1,&Image);
ilBindImage(Image);
ilLoadImage(File.c_str());
if(ilGetInteger(IL_IMAGE_ORIGIN) == IL_ORIGIN_LOWER_LEFT) iluFlipImage();
Tex = ilutGLBindTexImage();
Width = ilGetInteger(IL_IMAGE_WIDTH);
Height = ilGetInteger(IL_IMAGE_HEIGHT);
int W,H;
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_WIDTH,&W);
glGetTexLevelParameteriv(GL_TEXTURE_2D,0,GL_TEXTURE_HEIGHT,&H);
ilDeleteImages(1,&Image);
return Tex != 0;
}

My problem is that after the texture is loaded, it only has a size of 1*1 ie. one pixel, which it 512 times smaller than the actual image.
The pixel is the same color as the top left pixel in the actual image, so I know that some of the data is loaded.

If you want you can download the code here, and check it out: [attachment=10879:Engine.zip]

PS: I don't know if this fits in this forum. It kind of has to do with OpenGL, and kind of doesn't.
Lazy Foo
Lazy Foo
I wasn't a fan of the DevIL/OpenGL built in loading functions. They were always buggy every time I used them.

The way I go about loading an OpenGL texture with DevIL is by creating a generic function that creates a texture from any pixel pointer and then just passing in the pixels from ilGetData().

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.