Advertisement

Texture loading, why does it turn brown?

Started by October 04, 2002 12:48 PM
3 comments, last by Ilthigore 22 years, 4 months ago
Whenever I load textures the original image turns a horrible murky brown colour and is rendered as a horrible murky brown colour. It also saves as the brown colour, I am using the technique NeHe uses in Tutorial VII for non-linear (or mipmapped) filtering. Any hep on how to use the original colour? >>>>>>>>>>>>>>>>> Ilthigore <<<<<<<<<<<<<<<<<
>>>>>>>>>>>>>>>>>Ilthigore<<<<<<<<<<<<<<<<<
Check your code. Prior to rendering textured objects, call glColor3f(1.0f, 1.0f, 1.0f), if you don''t want the object to be transparent.

Hope this helps,
Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
Advertisement
Sorry, but it doesnt help. I''ve tried that already and had no success, the bitmaps themselves are edited which seems kinda strange. However the "crate.bmp" from Tut7 is still ok and renders OK. Did you use specific code for that crate NeHe? It doesn''t look like it but I could be wrong. Any help would be great, thx?

BTW: here is the whole code for my texture loading function:


  GLuint tlLoadGLTextures(char* filename, int type)									// Load Bitmaps And Convert To Textures{	GLuint texture;									// Status Indicator	AUX_RGBImageRec *TextureImage[1];					// Create Storage Space For The Texture	memset(TextureImage,0,sizeof(void *)*1);           	// Set The Pointer To NULL	// Load The Bitmap, Check For Errors, If Bitmap''s Not Found Quit	if (TextureImage[0]=tlLoadBMP(filename))	{									// Set The Status To TRUE		glGenTextures(1, &texture);					// Create The Texture		switch(type)		{		case TEXTYPE_LINEAR:		{		glBindTexture(GL_TEXTURE_2D, texture);		glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);		}		break;		case TEXTYPE_MIPMAP:		{		glBindTexture(GL_TEXTURE_2D, texture);		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_NEAREST);		gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);		}		break;		case TEXTYPE_NOFILTER:		default:		{		glBindTexture(GL_TEXTURE_2D, texture);		glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);		}		break;		}	}	if (TextureImage[0])									// If Texture Exists	{		if (TextureImage[0]->data)							// If Texture Image Exists		{			free(TextureImage[0]->data);					// Free The Texture Image Memory		}		free(TextureImage[0]);								// Free The Image Structure	}	return texture;										// Return The Status}  


The evocation I used was:

tlLoadGLTextures(TEXTYPE_NOFILTER);

In case you''re wondering about this program''s strange structure I use a library for common functions (load font/ texture, make display list for box/pyramid, print, etc.). If this may be the problem, please say so (but don''t say, "It could be the problem").
Thanks a lot.

>>>>>>>>>>>>>>>>>
Ilthigore
<<<<<<<<<<<<<<<<<
>>>>>>>>>>>>>>>>>Ilthigore<<<<<<<<<<<<<<<<<
Since you''re saying that the original tutorial texture displays correctly, and you''re using the same piece of code to load all of your textures, the fault can''t really be in the loading code. Check the textures themselves (using Paint or something) - see if they''re naturally "normal". Other than that, such effects can be a result of blending, but you make them sound kinda weird. Oh, and make sure you''re loading textures that are supported. The crate texture is most likely a 24-bit dib. Make sure your other textures are in the exact same format!

Hope this helps,
Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
post the part of the code where you render the object

(from... glLoadIdentity(); or from glTranslatef/glRotatef)

to a few lines after glBegin();

there is the only place where the problem can be

This topic is closed to new replies.

Advertisement