Problems With Alpha on Targa Files

Started by
3 comments, last by StonerSunshine 21 years, 7 months ago
I''m using a targa loader to be able to texture objects using pictures with alpha values. However, when I try to change the alpha value for the entire texture (by using glColor4f and lowering the alpha value of the quad that the texture is on), all of the values stay true to those contained in the targa file. I''m wondering if it is possible to manipulate those values through some other methood so that I can have the fading effect that I''m trying to get. Thanks in advance for any help or suggestions.
Advertisement
Give some more specifics on the fade effect your trying to get and the problems your getting, then I should be able to tell you whats up



"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I''m reaching up and reaching out. I''m reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one''s been. We''ll ride the spiral to the end and may just go where no one''s been." - Maynard James Keenan [TheBlackJester ]
[Wildfire Studios ]

"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan Name: [email=darkswordtbj@hotmail.com]TheBlackJester[/email]Team: Wildfire Games
Projects O A.D.The Last Alliance

Thanks for your reply.

Well, if I change the alpha values of the quad that a normal bmp texture is on, it changes the entire texture. For example, if I set it to 0.0f, the quad along with the bmp texture on it become completely invisible. However, if I do the same thing with a targa file, the targa texture doesn''t change. Even if the alpha value of the quad is 0.0f, the quad is completely visible. I want to be able to lower and raise the alpha value of the texture on my quad by changing the 4th value of a call to glColo4f(); I.e., fade the texture in and out with for loops.
Hmm,

Thats odd that it works with a BMP and not a TGA. First, make sure that you have your blending enabled. Then, set the blend func to (GL_SRC_ALPHA, GL_ONE). I can''t really think of much more that would be causing it unless I saw some source..

Well, hope that helps


"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I''m reaching up and reaching out. I''m reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one''s been. We''ll ride the spiral to the end and may just go where no one''s been." - Maynard James Keenan [TheBlackJester ]
[Wildfire Studios ]

"With my feet upon the ground I lose myself between the sounds and open wide to suck it in, I feel it move across my skin. I'm reaching up and reaching out. I'm reaching for the random or what ever will bewilder me, what ever will bewilder me. And following our will and wind we may just go where no one's been. We'll ride the spiral to the end and may just go where no one's been." - Maynard James Keenan Name: [email=darkswordtbj@hotmail.com]TheBlackJester[/email]Team: Wildfire Games
Projects O A.D.The Last Alliance

Right now, I do make a call to enable blending and then to glBlendFunc(), and I pass it GL_SRC_ONE_MINUS_SRC_ALPHA. Here is the code where I bind the targa:

glBindTexture(GL_TEXTURE_2D, tex[HUD]);
unsigned char* pixels = NULL;
pixels = tga.GetPixels();
glTexImage2D(GL_TEXTURE_2D, 0, 4, tga.GetImageWidth(),
tga.GetImageHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);

Here is how I bind my bitmaps:

glBindTexture(GL_TEXTURE_2D, tex[Sun]);
gltAutoMipmapBMP("Sun.BMP", GL_LINEAR_MIPMAP_LINEAR, GL_REPEAT);

The following lines are where I''m having trouble:
glBindTexture(GL_TEXTURE_2D, tex[HUD]);
glColor4f(1.0f, 1.0f, 1.0f, 0.5f);

I use this just before drawing the quad, and setting the texcoords. If I bind the Sun texture object instead of the HUD, the call to glColor4f() will show the texture with half it''s original opacity. However, when I use the HUD texture object, (which already has some parts that are clear because of the alpha values in the .tga file), it looks like the original image. No parts of the texture are faded any more so than they already were in the original image. Even if I set the 4th parameter of the call to glColor4f to 0.0f, so that the quad and texture would be completely invisible, the targa HUD picture is still completely visible. Do you know if there is some other way to manipulate those values? Or do you think it may have something to do with the way that I''m handling the targa-based texture?

Thanks again for all of your help.

This topic is closed to new replies.

Advertisement