title: Hide parts of image in OpenGL ES
body: <p>I'm using GLKView to render some sprites in a iOS app.</p>
  
  <p>My question is, how can I remove/draw only parts of one image? For example, I have a background, and on top of it an image (both sprites). I want to take some random rectangles out of the image on top, so the background will be visible in those rectangles. Is that possible?</p>
  
  <p>I'm creating my textures like this:</p>
  
  <pre><code>   - (id)initWithFile:(NSString *)fileName effect:(GLKBaseEffect *)effect position:(GLKVector2)position{
      if ((self = [super init])) {
          self.effect = effect;
  
          NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [NSNumber numberWithBool:YES],
                                    GLKTextureLoaderOriginBottomLeft, 
                                    nil];
  
          NSError * error;    
          NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:nil];
          self.textureInfo = [GLKTextureLoader textureWithContentsOfFile:path options:options error:&amp;error];
  
  
          self.contentSize = CGSizeMake(self.textureInfo.width, self.textureInfo.height);
  
  
          TexturedQuad newQuad;
          newQuad.bl.geometryVertex = CGPointMake(0, 0);
          newQuad.br.geometryVertex = CGPointMake(self.textureInfo.width, 0);
          newQuad.tl.geometryVertex = CGPointMake(0, self.textureInfo.height);
          newQuad.tr.geometryVertex = CGPointMake(self.textureInfo.width, self.textureInfo.height);
  
          newQuad.bl.textureVertex = CGPointMake(0, 0);
          newQuad.br.textureVertex = CGPointMake(1, 0);
          newQuad.tl.textureVertex = CGPointMake(0, 1);
          newQuad.tr.textureVertex = CGPointMake(1, 1);
          self.quad = newQuad;
  
  
          self.position = position;
  
          self.frameHeight = self.textureInfo.height;
  
      }
      return self;
  }
  </code></pre>
  
  <p>And then render them like this</p>
  
  <pre><code>- (void)render { 
  
      self.effect.texture2d0.name = self.textureInfo.name;
      self.effect.texture2d0.enabled = YES;        
  
      self.effect.transform.modelviewMatrix = self.modelMatrix;
  
      [self.effect prepareToDraw];
  
      long offset = (long)&amp;_quad;
  
      glEnableVertexAttribArray(GLKVertexAttribPosition);
      glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
  
      glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, sizeof(TexturedVertex), (void *) (offset + offsetof(TexturedVertex, geometryVertex)));
      glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, sizeof(TexturedVertex), (void *) (offset + offsetof(TexturedVertex, textureVertex)));
  
      glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  
  }
  </code></pre>