Results 1 to 6 of 6

Thread: gl blending

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2011
    Posts
    8

    gl blending

    Somehow it seems that my texture pixels alpha is completely ignored when i try to do blending

    i do:
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    // ... render something

    The only thing that seems to have an effect is when i use
    glColor4ub(255,255,255,50);

    and then alpha on the ENTIRE rendered polygon is 50

    How do i make it use the alpha values on the pixels?

    Thanks!

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: gl blending

    Most probably your RGBA texture is not sent correctly to OpenGL.
    Check you image loader, the texture parameters, etc.

  3. #3
    Senior Member Frequent Contributor _NK47's Avatar
    Join Date
    Mar 2008
    Posts
    574

    Re: gl blending

    if you upload images without alpha they get converted to alpha 255 which is completely opaque. most likely your textures are 24bit or if 32bit then alpha channel is 255 through all pixels.
    your alpha blending seems to work fine because glColor4ub(255,255,255,50) works.

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2011
    Posts
    8

    Re: gl blending

    Hi all, and thanks for your replies.

    i am using GL_BGRA (I've tried GL_RGBA as well)
    and i definitely set "correct" alpha values in the texture.

    So it's seems that it's not the issue.

    Code :
    glBindTexture(GL_TEXTURE_2D, g_texid[HAND_TEX]);
    		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    		glTexImage2D(GL_TEXTURE_2D, 0, 3, img.w, img.h, 0, GL_BGRA, GL_UNSIGNED_BYTE, img.data);

  5. #5
    Senior Member Frequent Contributor _NK47's Avatar
    Join Date
    Mar 2008
    Posts
    574

    Re: gl blending

    your internal format is 3 though.

  6. #6
    Junior Member Newbie
    Join Date
    Oct 2011
    Posts
    8

    Re: gl blending

    Ok thanks a lot that's probably it.

    Thanks!

Similar Threads

  1. Avoid Blending with Background when Blending Quads
    By Aboleoneo in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-05-2017, 05:54 PM
  2. Replies: 1
    Last Post: 05-01-2013, 09:37 PM
  3. Bad Blending
    By glBomb in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-23-2006, 05:01 AM
  4. Blending
    By Swiftless in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-07-2005, 01:53 AM
  5. Blending
    By ltrain_riders in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-03-2002, 02:35 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