Search code examples
opengltexturesalpha-transparency

glBlendFunc() with 32-bit RGBA textures


I have a texture that is semi-transparent with varying opacity at different locations. I have the main texture bitmap, and a mask bitmap. When the program executes, the alpha values from the mask bitmap are loaded into the alpha values of the main texture bitmap. The areas that I want to be transparent have a value of 255 alpha, and the areas that I want to remain totally opaque have values of 0 alpha. There are in-between values also for mid-transparency.

I have tried all manner of glBlendFunc() settings, but it is either completely invisible or it acts on the RGB colors of the source texture.


Solution

  • Typically in OpenGL, 0 means transparent and 255 opaque, which is the opposite that you have.

    so something like:

    glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
    

    Should work.