Blending Two Colours

Hi Everyone,

First post here so please be gentle :smiley:

I have a routine which draws a checked board to the screen. I have implemented this from a photoshop mockup which has the following layers


Checker Base

Base Texture

I have the base texture rendering correctly. I then iterate through my checkers and draw one ‚Äúchecker base‚ÄĚ quad and a ‚Äúchecker‚ÄĚ quad.

The ‚Äúchecker base‚ÄĚ is the same size/position it just acts as an underlay to the ‚Äúchecker‚ÄĚ.

The ‚Äúchecker base‚ÄĚ has RGBA (1.0, 1.0, 1.0, 0.2) so white with 20% transparency.

Whilst the ‚Äúchecker‚ÄĚ is either (r, g, b, 0.2) or (r, g, b, 0.8) depending on whether it is odd or even.

Current blending is: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

Basically I want to optimize the above into one draw for each checker as opposed to two.

How do I go about calculating the colour of the two merged quads ‚Äúchecker‚ÄĚ and ‚Äúchecker base‚ÄĚ ?

Not sure if this is what you are looking for, but the OpenGL blending calculations are described on the man page for glBlendFunc.