title: OpenGL How to use a invisible mask to hide objects behind it
body: <p>I have an OpenGL problem to solve. I have an object/mesh A, an object/mesh B and a background texture C. </p>
  
  <p>Initially the framebuffer is filled with background texture C. We draw both A &amp; B in the framebuffer. We want to keep object A visible, and object B always invisible.</p>
  
  <p>In the beginning, A is in front of B. During rotation, at a certain angle, B is in front of A based on the depth test result, but since B is always invisible, B's part should be filled with background C.</p>
  
  <p>Does anyone know a simple approach to solve this issue?</p>
  
  <p>Is stencil test a good approach? Basically set object B with a color, compare the color of B with background C, and show the background C when the test fail. </p>
  
  <p>Does anyone have any sample code I can read?</p>