OpenGL Blending Filter

OpenGL Blending Filter

14.OpenGLBlendingFilter.zip


 glEnable(GL_BLEND);
 if (g_filter == 0)                     // Default (no blending) = Cs*1
  glBlendFunc(GL_ONE, GL_ZERO);
 else if (g_filter == 1)                // Draw background only = Cd*1
  glBlendFunc(GL_ZERO, GL_ONE);
 else if (g_filter == 2)                // Cs*1 + Cd*1
  glBlendFunc(GL_ONE, GL_ONE);
 else if (g_filter == 3)                // Alpha blending (back-to-front) = Cs*As + Cd*(1-As)
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 else if (g_filter == 4)                // Additive blending (brighten the scene) = Cs*As + Cd*1
  glBlendFunc(GL_SRC_ALPHA, GL_ONE);
 else if (g_filter == 5)                // Multiplicative blending = Cd*Cs
  glBlendFunc(GL_ZERO, GL_SRC_COLOR);
 else if (g_filter == 6)                // darken the scene = Cd*As
  glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
 else if (g_filter == 7)                 // Invert all the colors = Cs*(1-Cd)
  glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);

Leave a Reply

Your email address will not be published. Required fields are marked *