Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Correct Parameter For glBlendFunc Function

  1. #1
    Newbie Newbie
    Join Date
    Mar 2014
    Posts
    3

    Correct Parameter For glBlendFunc Function

    Hi!!!

    I've got a question about the glBlendFunc. How do i have to choose the parameters to get this result:

    Image1
    Image2
    Blending

    greetz

  2. #2
    Intern Contributor
    Join Date
    Sep 2013
    Posts
    89
    I dont see any blending being done in that picture. You just draw image2 on top of image1.

  3. #3
    Newbie Newbie
    Join Date
    Mar 2014
    Posts
    3
    Is this not blending, where alpha = 0?

    Ist that not possible with glBlendFunc in general?

    My idea was to do this overlay by using glBlendFunc. The Image2 should be a texture with alpha channel.
    Last edited by susanne; 03-20-2014 at 01:34 PM.

  4. #4
    Intern Contributor Brokenmind's Avatar
    Join Date
    Feb 2014
    Location
    Aachen / Germany
    Posts
    71
    Usually, these two lines should do the trick:

    Code :
    	glEnable(GL_BLEND);
    	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    And yes, this is blending because otherwise, the white background would cover all the stars, which it does not due to alpha=0.

  5. #5
    Intern Contributor
    Join Date
    Sep 2013
    Posts
    89
    What you want is probably disabled blending with an Alpha-Test.
    Alpha-Test will cull all fragments where the alpha value does not satisfy the test.

  6. #6
    Newbie Newbie
    Join Date
    Mar 2014
    Posts
    3
    Quote Originally Posted by Brokenmind View Post
    Code :
    	glEnable(GL_BLEND);
    	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    That seems to work. Thank you Brokenmind .

    Quote Originally Posted by Cornix View Post
    What you want is probably disabled blending with an Alpha-Test.
    Alpha-Test will cull all fragments where the alpha value does not satisfy the test.
    How can i implement this? Or is this only possible with a fragment shader?

  7. #7
    Intern Contributor
    Join Date
    Sep 2013
    Posts
    89
    With the blending provided by Brokenmind it will work too. If you want to do it without blending (because you really dont need blending if you only use alpha values of 1 and 0) then you can do:
    Code :
    glEnable(GL_ALPHA_TEST);
    glAlphaFunc(GL_EQUAL, 1);
    This will make it so that only those fragments with an alpha value of exactly 1 will be drawn. All other fragments will be discarded.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •