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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:15:53+00:00 2026-05-28T00:15:53+00:00

let me explain the title a little. In the framebuffer I have some color

  • 0

let me explain the title a little. In the framebuffer I have some color values (for simplicity I am going to refer only to one color channel in binary e.g. 00000001 in a specific pixel). Then in that specific value I am going to write a new value. The OpenGL should examine the incoming value and the value that already exists in that pixel and keep the max of both. In other words I want it to perform a BITWISE OR between the incoming and the existing value. So, if the existing value is 00000001 and the incoming is 00000010 then the result must be 00000011.

In OpenGL ES 1.1 I think this was easily achieved using the glLogicOp (http://www.opengl.org/sdk/docs/man/xhtml/glLogicOp.xml) function. But this is NOT supported in OpenGL ES 2.0 (WHY WHY WHY they removed it?? 🙁 ), and I cannot think of a blending function that can achieve a similar result (I think this is impossible using blending). Should I use the stencil buffer or another trick in order to achieve my goal?

Can you describe the steps for it?

P.S. I know everything is possible using shaders but this will require a huge effort to implement now. If it is the only solution then please give me directions for this approach.

Thanks in advance.

  • 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-28T00:15:54+00:00Added an answer on May 28, 2026 at 12:15 am

    I must admit I was not so clear in my question. Anyway, I will refine the problem and present a resolution to it here.

    I have many different kind of arbitrary shapes (the user can create as many of them he wants and crazily deform them) and I want to develop a method to detect from the color of a pixel on the screen how many of the shapes the user picked (the user has just touched on that pixel).

    So, I color code the shapes with let’s say some kind of color ids. I work in the binary level:
    the first shape on the screen has color id 00000001 the second shape has id 00000010 and so on. So, with a byte (in the red channel let’s say) I can store up to 8 different color ids. The max number of shapes is 32 if I use an RGBA8888 format.

    The algorithm that I initially developed was doing blending between the source color id and the destination color id with a glBlendFunc(GL_ONE, GL_ONE), and everything seemed to work fine. So if a touched pixel with color 00010101, then it meant that the first, third and fifth shapes were touched. BUT, there are some non-convex shapes (if this is the right word for folding shapes) that can be created by the user. In this case if the shape with color id 00000001 is folded by the user then the overlapping pixels will get id 00000010, because the shape writes 00000001 when it is first drawn on the framebuffer and then the overlapping pixels of the same shape add another 00000001 due to blending.

    So, if in some way I could do a BITWISE OR (NOT logical as I initially mentioned in my question) between the color ids that were written in the framebuffer then the problem would be solved. Indeed this is the case with OpenGL ES 1.1, by using the glLogicOp(GL_OR) function. UNFORTUNATELY this is not available on OpenGL ES 2.0 and again one shader, one more pass etc must be created which I think is overkill and difficult to maintain.

    The solution for OpenGL ES 2.0 is this:

    1. Clear the color of RenderTexture B to glClearColor(0,0,0,0)
    2. FOR each shape
    3. Clear the color of Rendertexture A to glClearColor(0,0,0,0)
    4. Draw the shape on Rendertexture A using a fragment shader that writes as a color its color id.
    5. Blend with GL_ONE, GL_ONE the Rendertexture A with the contents of Rendertexture B
    6. END FOR
    7. RenderTexture B has all the info we need.
    8. When the user touches the screen, sample the corresponding pixel from RenderTexture B using glReadPixel and find out from the binary code the touched shapes.

    Best

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

Sidebar

Related Questions

the title might be a little bit confusing, let me explain, ;) I have
Title might be a bit confusing, so let me explain. I have a website
It's hard to put this into the title, so let me explain. I have
The title is not clear so let me explain: In my apps, I have
Perhaps a confusing title but let me explain the issue through steps: I have
I know my title is a little unclear but let me explain. I am
I apologize for vague title so let me explain. Suppose you have a page
Ok, that title is going to be a little bit confusing. Let me try
Maybe the title is a little bit obscure, but let me explain... In a
Ok Title may not be clear so let me explain. I have 2 classes,

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.