Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9235257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:59:06+00:00 2026-06-18T06:59:06+00:00

I explain my problem: I have three png image, the first has channel alpha,

  • 0

I explain my problem:

I have three png image, the first has channel alpha, the other two are RGB:

frame
mask
background

            frame                           mask                    background

I have to blend it all to obtain this result

enter image description here

now i know that i have to mask the third texture in this way:

if mask_pixel=white:
    blend_pixel=pixel with alpha 0
else if mask_pixel=black:
    blend_pixel=backgroud_pixel

and since now i have written this:

glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, background);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mask);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glActiveTexture(GL_TEXTURE2);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, frame);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
    glEnable (GL_BLEND);
        glBegin(GL_QUADS);
            glMultiTexCoord2f(GL_TEXTURE0, 0.0, 0.0);
            glMultiTexCoord2f(GL_TEXTURE1, 0.0, 0.0);
            glMultiTexCoord2f(GL_TEXTURE2, 0.0, 0.0);
            glVertex3f(-0.7, 0.0, 0.0);

            glMultiTexCoord2f(GL_TEXTURE0, 1.0, 0.0);
            glMultiTexCoord2f(GL_TEXTURE1, 1.0, 0.0);
            glMultiTexCoord2f(GL_TEXTURE2, 1.0, 0.0);
            glVertex3f(0.7, 0.0, 0.0);

            glMultiTexCoord2f(GL_TEXTURE0, 1.0, 1.0);
            glMultiTexCoord2f(GL_TEXTURE1, 1.0, 1.0);
            glMultiTexCoord2f(GL_TEXTURE2, 1.0, 1.0);
            glVertex3f(0.7, 2.6, 0.0);

            glMultiTexCoord2f(GL_TEXTURE0, 0.0, 1.0);
            glMultiTexCoord2f(GL_TEXTURE1, 0.0, 1.0);
            glMultiTexCoord2f(GL_TEXTURE2, 0.0, 1.0);
            glVertex3f(-0.7, 2.6, 0.0);
        glEnd();
    glDisable(GL_BLEND);
glActiveTexture (GL_TEXTURE2);
glDisable (GL_TEXTURE_2D);
glActiveTexture (GL_TEXTURE1);
glDisable (GL_TEXTURE_2D);
glActiveTexture (GL_TEXTURE0);
glDisable (GL_TEXTURE_2D);

but I am not sure how to use glTexEnvi to obtain the desired efect, any suggestion?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:59:07+00:00Added an answer on June 18, 2026 at 6:59 am

    yes! i have reached the answer on my own:

    glActiveTexture(GL_TEXTURE0);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_SUBTRACT);
    glActiveTexture(GL_TEXTURE1);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, mask);
    glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_SUBTRACT);
    glActiveTexture(GL_TEXTURE2);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture_open);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
        glEnable (GL_BLEND);
            glBegin(GL_QUADS);
                glMultiTexCoord2f(GL_TEXTURE0, 0.0, 0.0);
                glMultiTexCoord2f(GL_TEXTURE1, 0.0, 0.0);
                glMultiTexCoord2f(GL_TEXTURE2, 0.0, 0.0);
                glVertex3f(-0.7, 0.0, 0.0);
    
                glMultiTexCoord2f(GL_TEXTURE0, 1.0, 0.0);
                glMultiTexCoord2f(GL_TEXTURE1, 1.0, 0.0);
                glMultiTexCoord2f(GL_TEXTURE2, 1.0, 0.0);
                glVertex3f(0.7, 0.0, 0.0);
    
                glMultiTexCoord2f(GL_TEXTURE0, 1.0, 1.0);
                glMultiTexCoord2f(GL_TEXTURE1, 1.0, 1.0);
                glMultiTexCoord2f(GL_TEXTURE2, 1.0, 1.0);
                glVertex3f(0.7, 2.6, 0.0);
    
                glMultiTexCoord2f(GL_TEXTURE0, 0.0, 1.0);
                glMultiTexCoord2f(GL_TEXTURE1, 0.0, 1.0);
                glMultiTexCoord2f(GL_TEXTURE2, 0.0, 1.0);
                glVertex3f(-0.7, 2.6, 0.0);
            glEnd();
        glDisable(GL_BLEND);
    glActiveTexture (GL_TEXTURE2);
    glDisable (GL_TEXTURE_2D);
    glActiveTexture (GL_TEXTURE1);
    glDisable (GL_TEXTURE_2D);
    glActiveTexture (GL_TEXTURE0);
    glDisable (GL_TEXTURE_2D);
    

    in the mask image i have replaced the black with white and the white with trasparency

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to explain my problem. I have a first view in which I
to explain my problem, I'll give a simple example: My database has three tables:
I have one problem with my function in jQuery. First I will explain what
I have problem adding arraylist to list view, will explain about my problem here..
I have a problem concerning a HashMap in Java. To explain the problem in
The best way to explain my problem is by a example. I have a
I have Bitnami Rails stack installed on my Mac. To better explain my problem
Here a small piece of code for testing and explain the problem. I have
I have a problem and I will try to explain the issue: I have
I have a problem that is kind of difficult to explain. What I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.