title: Rendering cube on top of square having video feed as texture
body: <p>I am trying to develop a POC which helps to visualize a 3D object on camera feed. The kind 3D object I have, easily gets rendered using <a href="https://github.com/ricardo-rendoncepeda/mtl2opengl" rel="nofollow">this</a> project. And I am referring <a href="https://developer.apple.com/library/ios/samplecode/GLCameraRipple/Introduction/Intro.html" rel="nofollow">Camera Ripple</a> code by Apple for showing camera feed. Both of these are separate objects in the same context. Each of these uses its own shader program. I am confused how to switch from one program to another.</p>
  
  <p>My  <code>glkview:drawInRect:</code> method looks like this </p>
  
  <pre><code>    - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
  {
  glClear(GL_COLOR_BUFFER_BIT);
  glUseProgram(_program);
  if (_ripple)
  {
      glDrawElements(GL_TRIANGLE_STRIP, [_ripple getIndexCount], GL_UNSIGNED_SHORT, 0);
  }
  
  glUseProgram(_program1);
  
  glClearColor(1.0, 1.0, 1.0, 1.0);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
  // Set View Matrices
  [self updateViewMatrices];
  glUniformMatrix4fv(_uniforms.uProjectionMatrix, 1, 0, _projectionMatrix1.m);
  glUniformMatrix4fv(_uniforms.uModelViewMatrix, 1, 0, _modelViewMatrix1.m);
  glUniformMatrix3fv(_uniforms.uNormalMatrix, 1, 0, _normalMatrix1.m);
  
  // Attach Texture
  glUniform1i(_uniforms.uTexture, 0);
  
  // Set View Mode
  glUniform1i(_uniforms.uMode, self.viewMode.selectedSegmentIndex);
  
  // Enable Attributes
  glEnableVertexAttribArray(_attributes.aVertex);
  glEnableVertexAttribArray(_attributes.aNormal);
  glEnableVertexAttribArray(_attributes.aTexture);
  
  // Load OBJ Data
  glVertexAttribPointer(_attributes.aVertex, 3, GL_FLOAT, GL_FALSE, 0, cubeOBJVerts);
  glVertexAttribPointer(_attributes.aNormal, 3, GL_FLOAT, GL_FALSE, 0, cubeOBJNormals);
  glVertexAttribPointer(_attributes.aTexture, 2, GL_FLOAT, GL_FALSE, 0, cubeOBJTexCoords);
  
  // Load MTL Data
  for(int i=0; i&lt;cubeMTLNumMaterials; i++)
  {
      glUniform3f(_uniforms.uAmbient, cubeMTLAmbient[i][0], cubeMTLAmbient[i][1], cubeMTLAmbient[i][2]);
      glUniform3f(_uniforms.uDiffuse, cubeMTLDiffuse[i][0], cubeMTLDiffuse[i][1], cubeMTLDiffuse[i][2]);
      glUniform3f(_uniforms.uSpecular, cubeMTLSpecular[i][0], cubeMTLSpecular[i][1], cubeMTLSpecular[i][2]);
      glUniform1f(_uniforms.uExponent, cubeMTLExponent[i]);
  
      // Draw scene by material group
      glDrawArrays(GL_TRIANGLES, cubeMTLFirst[i], cubeMTLCount[i]);
  }
  
  // Disable Attributes
  glDisableVertexAttribArray(_attributes.aVertex);
  glDisableVertexAttribArray(_attributes.aNormal);
  glDisableVertexAttribArray(_attributes.aTexture);
  }
  </code></pre>
  
  <p>this cause a crash by throwing this error <code>gpus_ReturnGuiltyForHardwareRestart</code></p>