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 7700479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:43:05+00:00 2026-05-31T22:43:05+00:00

I need to merge two bitmaps to use the resulting bitmap as a mask.

  • 0

I need to merge two bitmaps to use the resulting bitmap as a mask. Is there a way to do that in OpenGL-1.0 without affecting the previously drawn system.

Here is my algorithm:

1.- draw the background (opaque)
2.- draw the mask (this is a combination of two bitmaps)
3.- draw a bitmap (this need to be masked).

As a side note, I’m working with OpenGLES 1.0, so the shaders won’t work. Any help would be very appreciated!

Here is my draw function:

  public void onDrawFrame(GL10 gl) {

  // clear the screen and depth buffer
  gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

  // drawing
  gl.glLoadIdentity();

  // draw the background
     gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE, GL10.GL_REPLACE);
     gl.glTranslatef(0.0f, 0.0f, -3.72f);
     background.draw(gl);
  gl.glPopMatrix();

  gl.glPushMatrix();
     gl.glEnable(GL10.GL_BLEND);
     gl.glDisable(GL10.GL_DEPTH_TEST);

     // mask1 + mask2   
     gl.glLoadIdentity();
     gl.glTranslatef(0.0f, 0.0f, -3.72f);
     gl.glBlendFunc(GL10.GL_DST_COLOR, GL10.GL_ZERO);
     mask1.draw(gl);

     gl.glLoadIdentity();
     gl.glTranslatef(0.0f, y, -3.72f);
     gl.glBlendFunc(GL10.GL_DST_COLOR, GL10.GL_ZERO);
     mask2.draw(gl);

     gl.glLoadIdentity();
     gl.glTranslatef(0.0f, 0.0f, -3.72f);
     gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE);
     picture.draw(gl);

     gl.glDisable(GL10.GL_BLEND);
     gl.glEnable(GL10.GL_DEPTH_TEST);
     gl.glFlush();
  gl.glPopMatrix();

     y -= 0.2f;

  }
  • 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-05-31T22:43:07+00:00Added an answer on May 31, 2026 at 10:43 pm

    Have you looked at something like the stencil buffer for this? This answer doesn’t actually merge the bitmaps, but it does use their combination as a mask if that’s the result you’re looking for. You can use either the logical OR or logical AND of the masks (not sure what you want).

    Pseudocode I believe would go something like:

    glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 
    
    draw_background();
    
    glEnable(GL_STENCIL_TEST); //enable stencil buffer
    glStencilFunc(GL_ALWAYS, 0 , 0); //always pass stencil test
    glStencilOp(GL_KEEP,GL_KEEP,GL_INCR); //increment buffer on fragment draw
    
    draw_mask1();
    draw_mask2();
    
    if(OR masks) 
        glStencilFunc(GL_LEQUAL, 1, 0xffffffff); //OR masks: pass fragment if  (1 <= buffer)
    else if (AND masks)
        glStencilFunc(GL_LEQUAL, 2, 0xffffffff); //AND masks: pass fragment if (2 <= buffer)
    
    glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); //don't change buffer 
    
    draw_bitmap_to_be_masked(); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two bitmap images ..and i need to merge the bitmaps with precise
What's the best way to merge two texts in javascript, without any need for
I need to merge two NSDictionary s into one provided that if there are
I need to merge two SELECT statements. There are two tables in my database,
I have two tab delimited csv files (with headers) that I need to merge
I need help finding the most efficient way to merge two in-memory collections with
Is there a way to merge two primary keys into one and then cascade
Here’s a problem I’ve really been struggling with. I need to merge two sorted
Need to create a class that will do all things as the merge function.
I have two columns in a table. I need to merge these two columns

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.