Blending question
I''m working on a neet little program that draws an textured quad to the screen. The problem I''m haveing is trying to figure out how to set up blending so that the image color don''t take on any of the background color.
I have an image with a alpha layer that is all 0.0 or 1.0 values. I want the areas with 0.0 alpha values to be transparent and the 1.0 to be put on the screen with no show through of the background color.
I''ve tryed every combination of parameters for glBlendFunc that I can think of and all I''ve done is confused myself on how blending works. any help is appreciated....
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
Switch off blending and ENABLE alphatesting:
example:
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER,0.9f);
This test will succeed for all pixels with an alpha value > 0.9f. Thus these pixels will be rendered. all other pixels won''t. So the pixels which are rejected will in fact ''show through'' the background. All other pixels will overwrite the background.
--
Get productive, Get DemoGL: http://www.demogl.com
example:
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER,0.9f);
This test will succeed for all pixels with an alpha value > 0.9f. Thus these pixels will be rendered. all other pixels won''t. So the pixels which are rejected will in fact ''show through'' the background. All other pixels will overwrite the background.
--
Get productive, Get DemoGL: http://www.demogl.com
--
Get productive, Get DemoGL: http://www.demogl.com
Get productive, Get DemoGL: http://www.demogl.com
Tried that, I didnt'' work. if I used GL_GREATER the image just wasn''t displayed if I used GL_LESS it was displayed in a black box. I''ve confirmed that the alpha channel is loaded properly so that''s not the problem.
I''ve mannaged to get it pretty close so I''ll live with it for now and see if I canfighue it out later. Unless someone has another idea.
I''ve mannaged to get it pretty close so I''ll live with it for now and see if I canfighue it out later. Unless someone has another idea.
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
Tried that, I didnt'' work. if I used GL_GREATER the image just wasn''t displayed if I used GL_LESS it was displayed in a black box. I''ve confirmed that the alpha channel is loaded properly so that''s not the problem.
I''ve mannaged to get it pretty close so I''ll live with it for now and see if I canfighue it out later. Unless someone has another idea.
I''ve mannaged to get it pretty close so I''ll live with it for now and see if I canfighue it out later. Unless someone has another idea.
------------------------------Piggies, I need more piggies![pig][pig][pig][pig][pig][pig]------------------------------Do not invoke the wrath of the Irken elite. [flaming]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement