Advertisement

NeHe's TGA loading code

Started by December 14, 2000 05:30 PM
0 comments, last by Bleakcabal 23 years, 11 months ago
I don''t know if anyone here is familiar with NeHe''s tga loading code, but ill include a small sample about the section ill be refereing to :

for(GLuint i=0; iimageData;							// Temporarily Store The Value At Image Data ''i''
		texture->imageData = texture->imageData;	// Set The 1st Byte To The Value Of The 3rd Byte
		texture->imageData = temp;					// Set The 3rd Byte To The Value In ''temp'' (1st Byte Value)
	}

</pre>

If I wanted to be able to put the any black pixel with an alpha value of 0.0f and all other with an alpha value of 1.0f I guess I would have to modify this particular piece of code. 

How can I check the value for the colors is it something like :
( pseudo-code )

if
texture->imageData != 0.0f &&
texture->imageData[i+1] != 0.0f &&
texture->imageData[i+2] != 0.0f 
then
texture->imageData[i+3] = 0.0f
else 
texture->imageData[i+3] = 1.0f

or :

if
texture->imageData = 0 &&
texture->imageData[i+1] = 0 &&
texture->imageData[i+2] = 0 
then
texture->imageData[i+3] = 0
else 
texture->imageData[i+3] = 1


Or maybe Im wrong and I should do some other thing at some other place ? And how can I know what system is used for color representation ? int, floats, gl, standard ?  </i>   </pre> 
WHO DO THEYTHINK THEY'REFOOLING : YOU ?
bit hard to see but if im correct u want unsigned bytes 0x00-0xff
this is want tga files data is stored in 0x00 4 nothing 0xff for maximum

http://members.xoom.com/myBollux

This topic is closed to new replies.

Advertisement