Alpha Blending

Started by
9 comments, last by tyreth 22 years, 5 months ago
Hello I have been trying for quite a while now to get alpha blending working properly. I am using SDL 1.23, SDL Image 1.20, and OpenGL in Linux. I use SDL Image to load the image (png, bmp, tga I have tried I think). I bhave a 3D application, and am trying to create a cursor. I can get the cursor to draw, but not with proper blending. For example, glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); which was recommended in NeHe''s tutorials caused nothing to blend. I tried various combinations for glBlendFunc (not knowing fully what they do), and received mixed results - the best being the supposedly transparent area being totally transparent, but the colored areas still being semi-transparent. Help using SDL Image to load a png, and so that only the transparent bit is transparent, and the rest is solid would be much appreciated. The problem may be with the alpha channel not being properly setup, so help doing this with the GIMP would also be useful. (when I load my png image in the gimp, it shows the transparent area as the grey grids you normally get). Thanks for any help Tyreth
Advertisement
glEnable(GL_ALPHA_TEST);

^ try that?
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
glEnable(GL_ALPHA_TEST); didn''t help. Was I supposed to do some other settings with it too, or just enable it?
Do your images have alpha channels ?
I don''t know - that''s half the problem. In the gimp when I use the color picker on a colored area of my png, it says Alpha is 255, and the transpared (grey gridded bit) is an Alpha 0. I have also tried with images that seem to work for other applications, but I still can''t see what I am doing different.
What kind of texture function do you use?
GL_REPLACE ?
If not - vertex alpha may affect your texture.
glEnable( GL_BLEND );
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Ok, say I got a .tga image with alpha channel which is( the image) is red circle on black.
How do I draw that red circle without black on a quad?
gimp saves tga''s differently than say photoshop.
make a 256x256 sized image and save it as a uncompressed tga file. now see how large the file is if its 256kb then theres an alpha channel. if its 192kb then there is no alpha channel.
I tried that and it saved at 192kb, how do I get it to save the alpha channel?

This topic is closed to new replies.

Advertisement