And on the seventh Day, He exited from append mode Concept 1.2 - Combining Color - The hows! ========================================= Blending of incoming pixel color values with the existing ones is done as follows: 1 First specify how to compute the source and destination factors. Specify RGBA quadrapulets for both the source and the destination. 2 Multiply the RGBA quadrapulets with the corresponding RGBA values in the source and destination 3 Add up the corresponding components of the source and destination. eg. Say Source has the following values (Rs, Gs, Bs, As) Destination has the following (Rd, Gd, Bd, Ad) Source factor is the following (Sr, Sg, Sb, As) Destination factor is the following (Dr, Dg, Db, Ad) Then the above computation would result in the following : (RsSr + RdDr, GsSg + GdDg, BsSb + BdDb, AsSa + AdDa) Each component of this quadrupulet is eventually clamped to [0,1] The OpenGL function calls: ========================== void glBlendFunc(GLenum sfactor, GLenu dfactor); specify the source and the destination factor. To enable blending call : glEnable(GL_BLEND); Similarly use glDiable(GL_BLEND) to disable blending in your programs. The following table shows possible values for the glBendFunc. The RGBA values of the source and destination are indicated with the subscripts s and d, respectively. Subtraction of quadrupulets means subtracting them componentwise. The Relevant Factor column indicates whether the corresponding constant can be used to specify the source or destination blend factor or used for both. --------------------------------------------------------- Constant Relevant Computed to use in Factor Blend Factor GLenum sfactor and dfactor ========================================================= GL_ZERO source or (0,0,0,0) destination GL_ONE source or (1,1,1,1) destination GL_DST_COLOR source (Rd,Gd,Bd,Ad) GL_SRC_COLOR destination (Rs,Gs,Bs,As) GL_ONE_MINUS_DST_COLOR source (1,1,1,1) - (Rd,Gd,Bd,Ad) GL_ONE_MINUS_SRC_COLOR destination (1,1,1,1) - (Rs,Gs,Bs,As) GL_SRC_ALPHA source or (Ad,Ad,Ad,Ad) destination GL_ONE_MINUS_SRC_ALPHA source or (1,1,1,1) - destination (As,As,As,As) GL_DST_ALPHA source or (Ad,Ad,Ad,Ad) destination GL_ONE_MINUS_DST_ALPHA source or (1,1,1,1) - destination (Ad,Ad,Ad,Ad) GL_SRC_ALPHA_SATURATE source (f,f,f,1); f=min(As, 1-Ad) ========================================================