title: In OpenGL ES, how can I "clip" drawing to a rectangle?
body: <p>I am working on an Android application where I am using a single OpenGL ES instance.  In some instances, I am drawing a custom (rectangular) dialog ontop of everything else, with scrolling text, lines, etc.  The dialog does not take up the whole screen, and I am drawing content that is <em>larger</em> than the dialog box, which is scrolling across the dialog, like a marquee.</p>
  
  <p>Of course, since I am drawing this dialog <em>last</em> (ontop of every other view), all the vertices I am drawing are going to be visible, but I would like to tell OpenGL to <em>not</em> draw outside of the dialog rectangle for any of its rendering commands.  Like this...</p>
  
  <p><img src="https://i.stack.imgur.com/GHhL1.png" alt="Culling to rectangle"></p>
  
  <p>Most of my drawing is done with <code>glDrawArrays(...)</code> using <code>FloatBuffer</code> arrays.  What I would like is a way to specify to OpenGL that I want <em>any</em> drawing to be invisible outside of a specified region.</p>
  
  <p>I don't know much about culling, but this seems to be very related to what I'm looking for.  However, culling seems to only be for skipping the drawing of triangles that wouldn't be "seen" from the camera view in a 3D, whereas I would like to 'skip' the drawing of any triangles outside of an arbitrary rectangle within the viewport.</p>