Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Alpha Blending using RGBA textures?

mikadomikado Member Posts: 9
Hi there,

I wonder how to activate alpha-texture blending (RGBA textures). I have found pieces of examples on the net but nothing seemed to work properly.

My program has two kinds of textures:
1. textures with alpha
2. textures without alpha (but with "normal" background transparency).

How can I activate (and disable) alpha blending of textures on demand?

At the moment I use:

glBlendFunc(GL_SRC_ALPHA, GL_SRC_ONE_MINUS_ALPHA);
glEnable(GL_BLEND);

which works fine for transparency, but ignores alpha chanels...

Thanks for every kind of help :)
Mikado.

Comments

  • gautamgautam Member Posts: 642
    [b][red]This message was edited by gautam at 2004-4-8 10:53:2[/red][/b][hr]
    Hi,
    You can use

    [code]
    glAlphaFunc(...);
    glEnable(GL_ALPHA_TEST);
    [/code]

    This way it wont even blend to the background and is also less expensive than a glBlendFunc call.

    Coming to how to activate and deactivate on demand ? Thats really simple. To disable do the following

    [code]
    if(glIsEnabled(GL_ALPHA_TEST))
    glDisable(GL_ALPHA_TEST);
    [/code]

    Or you could inline the code like this - dont think this is the best way to handle it

    [code]
    inline void ChangeAlphaState()
    {
    if(glIsEnable(GL_ALPHA_TEST))
    glDiable(GL_ALPHA_TEST);
    else
    glEnable(GL_ALPHA_TEST);
    }

    [/code]


    : Hi there,
    :
    : I wonder how to activate alpha-texture blending (RGBA textures). I have found pieces of examples on the net but nothing seemed to work properly.
    :
    : My program has two kinds of textures:
    : 1. textures with alpha
    : 2. textures without alpha (but with "normal" background transparency).
    :
    : How can I activate (and disable) alpha blending of textures on demand?
    :
    : At the moment I use:
    :
    : glBlendFunc(GL_SRC_ALPHA, GL_SRC_ONE_MINUS_ALPHA);
    : glEnable(GL_BLEND);
    :
    : which works fine for transparency, but ignores alpha chanels...
    :
    : Thanks for every kind of help :)
    : Mikado.
    :



  • mikadomikado Member Posts: 9

    I have found the bug, finally. Alpha images didn't get alpha-bits when beeing loaded... ;-)

    Thx!!!
  • gautamgautam Member Posts: 642
    Happens :). Nice to hear it works.

    :
    : I have found the bug, finally. Alpha images didn't get alpha-bits when beeing loaded... ;-)
    :
    : Thx!!!
    :

Sign In or Register to comment.