STRANGE problem

Started by
8 comments, last by szecs 14 years, 6 months ago
This seems to happen on a couple cards so far: Nvidia 7600, ATI HD4670 I load some .tga's using DevIL for some particle system, later on I load some .jpg's. For the .jpg's it is crashing on a call to glTexImage2D(). All my textures go through this code, it crashes on the first .jpg to load. The first texture file is found, the pixel data pointer is valid, and it finds the height/width to be correct @ 1024x1024. The first .tga textures are 128x128. Anybody know what this problem is??? Could it just be a driver problem? Here is my code:

ilGenImages( 1,&(this->DEVIL_Texture_Index) );
ilBindImage( (this->DEVIL_Texture_Index) );
ilLoadImage( filename.c_str() );

this->pixels = ilGetData();
this->width = ilGetInteger(IL_IMAGE_WIDTH);
this->height = ilGetInteger(IL_IMAGE_HEIGHT);

glGenTextures(1, &(this->GL_Texture_Index));
glBindTexture(GL_TEXTURE_2D, (this->GL_Texture_Index));

glTexParameteri(GL_TEXTURE_2D,GL_GENERATE_MIPMAP,GL_TRUE);	
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);


if( this->Texture_Name.find(".bmp") != string::npos)
{
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, this->width, this->height, 0, GL_RGB, GL_UNSIGNED_BYTE, this->pixels);
}
else
if( this->Texture_Name.find(".jpg") != string::npos)
{
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, this->width, this->height, 0, GL_RGB, GL_UNSIGNED_BYTE, this->pixels);
}
else
if( this->Texture_Name.find(".tga") != string::npos)
{
	for(int i = 0; i < this->width*this->height*4;i+=4)
	{
		unsigned char R = this->pixels;
		unsigned char B = this->pixels[i+2];
		this->pixels = B;
		this->pixels[i+2] = R;
	}
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this->width, this->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, this->pixels);
}

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Advertisement
This is probably not related, but you set mipmap min filter, but you don't load the mipmaps, or the GPU does if for you? Some cards can't do that.
If that wasn't it, than SORRY!
Thanks. I will try that out. But what makes it even stranger is that the textures that all my textures go through this code. So the first ones succeed and mip-map apparently.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

The specs actually say this works in GL 1.4 and above.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

If you convert all those JPEGs to TGAs, does it still crash?
If not, you know where the problem is.
the only way for it to crash I can see is if
this->pixels
doesnt have enuf data

stick a breakpoint in just before + see if thats the case

btw with the tga files (what youre doing there is gonna be slow) + is unecessary
use GL_BGR instead of RGB
Thanks zedz for the GL_BGR. It does still load pretty damn fast. I wish I had an ATI card to test it out. I've tested like 8 Nvidia cards (1 didnt work). and 2 ATI cards that both didn't work. Sucks cuz I don't have one of those cards and I have bugged this one guy enough.

[Edited by - dpadam450 on October 30, 2009 3:11:35 PM]

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Does the texture being loaded in look 100% correct on the systems it works on?

Are you certain that your bmps and jpegs are 3 channel and that your tgas are 4 channel? You should probably check the info after loading them with devIL before you give them to GL.

Also, are you certain that the image data pointer you are getting back is in RGB format with 8 bits per channel? The devIL documentation for ilGetData doesn't seem to say what format the data is returned in.
Well actually I do load a .jpg title screen image before loading the level and that works. So it appears that everything is valid on all the systems. I'm really going to have to snag an ATI card to debug this. Someone elses ATI card does some other weird things and crashes as well. And they are newer ATI cards, yet my code still works on a Nvidia 5200....

It might just come down to driver issues in the end.

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

try to replace the mipmap filter with simple linear filter, or use glut to upload and build the mipmap levels at startup. Than come back

This topic is closed to new replies.

Advertisement