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.
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:
Best