title: OpenGL - mask with multiple textures
body: <p>I have implemented masking in OpenGL according to the following concept:</p>
  
  <ul>
  <li>The mask is composed of black and white colors.</li>
  <li>A foreground texture should only be visible in the white parts of the mask.</li>
  <li>A background texture should only be visible in the black parts of the mask.</li>
  </ul>
  
  <p>I can make the white part or the black part work as supposed by using glBlendFunc(), but not the two at the same time, because the foreground layer not only blends onto the mask, but also onto the background layer.</p>
  
  <p>Is there anyone who knows how to accomplish this in the best way? I have been searching the net and read something about fragment shaders. Is this the way to go?</p>