Jump to content

  • Log In with Google      Sign In   
  • Create Account

ilutGLBindTexImage creates a 1*1 texture


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Somone else   Members   -  Reputation: 112

Like
0Likes
Like

Posted 23 August 2012 - 02:46 AM

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: Attached File  Engine.zip   461.47KB   66 downloads

PS: I don't know if this fits in this forum. It kind of has to do with OpenGL, and kind of doesn't.

Sponsor:

#2 Lazy Foo   Members   -  Reputation: 1105

Like
1Likes
Like

Posted 23 August 2012 - 04:48 AM

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, 23 August 2012 - 04:49 AM.

Learn to make games with my SDL 2 Tutorials





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS