Results 1 to 3 of 3

Thread: Blending problem

  1. #1
    Member Contributor
    Join Date
    Dec 2001
    Posts
    91

    Blending problem

    Hi All,

    I am having a problem with blending.

    If I load a texture (.bmp file format) that is black and white, then the white part shows up and the black part is transparent.

    What I want is the black part to show up and the white part to be transparent.

    I currently have glBlendFunc set to (GL_ONE, GL_SRC_ALPHA).

    Can I change the blending function to get the results I want or is this all I am going to get while using .bmp's because they don't have an alpha channel???

    Any help would be appreciated,
    jpummill

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: Blending problem

    Strange.
    Without an alpha channel in your texture, the blending function you gave shouldn't do anything ...

    Are you sure that the black parts are truly transparent, or are they just invisible because you draw onto a black background?

    The 'correct' blending function for your current mode of behaviour (with alpha channel) would be
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    or
    glBlendFunc(GL_SRC_ALPHA,GL_ONE); //additive blending

    without an alpha channel would be
    glBlendFunc(GL_SRC_COLOR,GL_ONE_MINUS_SRC_COLOR);
    or
    glBlendFunc(GL_SRC_COLOR,GL_ONE); //additive

    To invert the thing, so that black becomes opaque and white becomes transparent, you can flip the thing around, eg

    glBlendFunc(GL_ONE_MINUS_SRC_ALPHA,GL_SRC_ALPHA);
    or
    glBlendFunc(GL_ONE_MINUS_SRC_ALPHA,GL_ONE);
    or
    glBlendFunc(GL_ONE_MINUS_SRC_COLOR,GL_SRC_COLOR);
    or
    glBlendFunc(GL_ONE_MINUS_SRC_COLOR,GL_ONE);

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    477

    Re: Blending problem

    glBlendFunc(GL_SRC_ALPHA,GL_ONE);
    glEnable(GL_BLEND);
    // Draw your stuff
    glDisable(GL_BLEND);

Similar Threads

  1. Problem with blending
    By Ralph in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-04-2008, 03:22 AM
  2. blending problem
    By 0stress in forum OpenGL ES
    Replies: 3
    Last Post: 09-21-2006, 03:36 PM
  3. I problem with blending HELP ME PLEASE!
    By Dol AI with 3D Bone system in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 10-14-2004, 07:40 AM
  4. Is this a blending problem?
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-04-2003, 07:53 AM
  5. Blending problem
    By Imotiep in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-19-2001, 01:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean