GL_COLOR_LOGIC_OP alternative

Hi All,

I am new to this forum so before I begin let me apologise in advance if this is posted in the wrong place and for any holes in my understanding of OpenGL.

I am the author of Looking Glass ( and I am working on replacing the legacy OpenGL renderer with an OpenGL ES renderer using shaders. Everything is going fine except that I have hit a roadblock with regards to rendering a mouse cursor. Standard RGB and color mask cursors are working fine, however monochrome cursors are not as they require logic operations which have been deprecated in OpenGL ES 2.

Currently I am rendering the desktop as a PBO streamed texture to a triangle strip, and then rendering the cursor as another triangle strip with blending using a uniform to specify the cursor size and position.

Please note that I have nearly no experience with shaders and I am learning this as I go, I may be asking some very dumb questions.

What is the best way to go about this? I would like to avoid rendering to a texture for sampling as this application needs to be as low latency as possible.

This is the legacy code I am working to re-implement - LookingGlass/opengl.c at 3ff712fea5dffd52844c8e454eee7b97f4d4421a · gnif/LookingGlass · GitHub

The AND portion is straightforward using blending with sfactor=GL_ZERO, dfactor=GL_SRC_COLOR.

For the XOR part, you need to [var]discard[/var] the zero (black) pixels in the fragment shader. Then you just need to invert the rendered pixels, which can be done by blending with sfactor=GL_ZERO, dfactor=GL_ONE_MINUS_DST_COLOR.

Awesome! Thanks, that works perfectly!

Edit: Almost, the xor blending suggested is backwards, it should be sfactor=GL_ONE_MINUS_DST_COLOR, dfactor=GL_ZERO