Jump to content
  • Advertisement
Sign in to follow this  
Adrian Bibby Walther

OpenGL ilutGLBindTexImage creates a 1*1 texture

This topic is 2222 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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(). Edited by Lazy Foo

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!