Advertisement

white texture problem

Started by May 27, 2006 12:28 PM
7 comments, last by lc_overlord 18 years, 6 months ago
Whenever I try to load textures from bmps, I get a white square. I checked the enabling, filepath, and binding, but so far I can only load one picture. The other textures' lines are just like the one that can load, and I can't think of any other reason for a white picture. Can anyone help me on this?
could you please post your code? that way it would be a lot easier to figure out your problem. thanks

--nathan
Advertisement
The most common reason for a white texture is the filter parameter. Default minification filter requires a complete mimpap set. Either set the minification filter to a filter that does not require mipmaps, or upload all mipmap levels before using the texture.

Other than that, what the above poster said.
Here it is:

//texture.h...class TEXTURE{	public:		TEXTURE( char name[], F_TYPE filter );		TEXTURE(){};		~TEXTURE(){};		GLuint gid(){return this->id;};	private:		GLuint id;};//texture.cpp...TEXTURE::TEXTURE(char name[],F_TYPE filter){        AUX_RGBImageRec *texture_image;        if (texture_image=BMPLoad(name))        {                glGenTextures(1,&id);                glBindTexture(GL_TEXTURE_2D,id);				if (filter==LINEAR)		{			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);			glTexImage2D(GL_TEXTURE_2D,0,3,texture_image->sizeX,texture_image->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,texture_image->data);		}if (texture_image)	{		if (texture_image->data)			free(texture_image->data);		free(texture_image);	}}//wall.cpp...bool Wall::tDrawWall(GLuint _texture){	glLoadIdentity();	glBindTexture(GL_TEXTURE_2D, _texture);	glRotatef(this->rot, 0.0f,1.0f,0.0f);	glTranslatef(this->x,this->y,this->z);	glBegin(GL_QUADS);		glTexCoord2f(0.0f,1.0f);	glVertex3f(0.0f,1.0f, 0.0f);		glTexCoord2f(1.0f,1.0f);	glVertex3f(1.0f,1.0f, 0.0f);		glTexCoord2f(1.0f,0.0f);	glVertex3f(1.0f,1.0f,-1.0f);		glTexCoord2f(0.0f,0.0f);	glVertex3f(0.0f,1.0f,-1.0f);	glEnd();	return true;}bool Wall::fDrawWall(GLuint _texture){	glLoadIdentity();	glBindTexture(GL_TEXTURE_2D, _texture);	glRotatef(this->rot, 0.0f,1.0f,0.0f);	glTranslatef(this->x,this->y,this->z);	glBegin(GL_QUADS);		glTexCoord2f(1.0f,0.0f);	glVertex3f(0.0f,0.0f,0.0f);		glTexCoord2f(0.0f,0.0f);	glVertex3f(1.0f,0.0f,0.0f);		glTexCoord2f(0.0f,1.0f);	glVertex3f(1.0f,1.0f,0.0f);		glTexCoord2f(1.0f,1.0f);	glVertex3f(0.0f,1.0f,0.0f);	glEnd();	return true;}/...mainTEXTURE t_floor,t_stone,t_jungle;inline void LoadTextures() {	t_floor=TEXTURE( "data/floor.bmp",   LINEAR);	t_stone=TEXTURE( "data/stone.bmp",   LINEAR);	t_jungle=TEXTURE("data/jungle.bmp",  LINEAR);}//...	wal[11].tDrawWall(t_floor.gid() );	wal[12].fDrawWall(t_stone.gid() );
(Slightly off topic)
I also get that in Direct3D, i.e my skybox textures are fine, but the terrain's texture (single jpg on an X file) is white. Of course this may be due to me using externs all over the place as a hack, but I'll check out Brother Bob's suggestion.
____________________________________Spazuh- Because I've had too much coffee
so far your code looks fine...but i've only glimpsed over it.
try not calling glLoadIdentity();
take that out of your code, that might fix your problem.
also, could you post the code of where you call the functions that display the image, maybe theres something wrong there?
and by the way, are your images to the power of 2? ie 64x64, 128x128, 256x256....
thats all i have to say for now

hope that helps
--nathan
Advertisement
Yeah, turns out my textures weren't by the powers of two..kind of frusstrating
did that solve your problem? you don't HAVE to have it 128x128 etc...you can do combos such as 256x128 or 512x64.
also, usually when i forget about that, my game just lags horribly and doesn't show up white. the pictures shows up with the colors messed up and the FPS drops to about 10. so that's why i'm wondering if that fixed your problem.

--nathan
Quote: Original post by lack the hack
did that solve your problem? you don't HAVE to have it 128x128 etc...you can do combos such as 256x128 or 512x64.
also, usually when i forget about that, my game just lags horribly and doesn't show up white. the pictures shows up with the colors messed up and the FPS drops to about 10. so that's why i'm wondering if that fixed your problem.

--nathan


It depends on your driver/card combo, my card doesn't even blink when faced with an NPOT texture, it runs it anyway, with little or no speed loss.
Some cards lag horribly and some doesn't even try to load them resulting in white polys.


This topic is closed to new replies.

Advertisement