title: Contrast using Open GL ES
body: <p>I am trying to do contrast on image using Open GL ES. following is code for contrast in the source code [sample from apple] regarding same. but seems like I am not getting desired output. </p>
  
  <pre><code>-(void) DoContrast:(float) aContrast
  {
      GLfloat h = aContrast*0.5f;
  
      [EAGLContext setCurrentContext:context];
  
      glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
  
      glActiveTexture(GL_TEXTURE0);
      glVertexPointer(2, GL_FLOAT, 0, spriteVertices);
      glEnableClientState(GL_VERTEX_ARRAY);
      glTexCoordPointer(2, GL_SHORT, 0, spriteTexcoords);
      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB,      GL_MODULATE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB,         GL_TEXTURE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB,         GL_PRIMARY_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,    GL_REPLACE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA,       GL_TEXTURE);
  
      glActiveTexture(GL_TEXTURE1);
      glEnable(GL_TEXTURE_2D);
      glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB,      GL_ADD_SIGNED);
      glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB,         GL_PREVIOUS);
      glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB,         GL_PRIMARY_COLOR);
      glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB,     GL_SRC_ALPHA);
      glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE,        2);
      glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,    GL_REPLACE);
      glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA,       GL_PREVIOUS);
  
      glColor4f(h, h, h, 0.75 - 0.5 * h); // 2x extrapolation
      validateTexEnv();
      glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  
      glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
  
      [context presentRenderbuffer:GL_RENDERBUFFER_OES];
  
      glActiveTexture(GL_TEXTURE0);
      glDisable(GL_BLEND);
      glViewport(0, 0, backingWidth, backingHeight);
  
      [self drawView];
  }
  </code></pre>
  
  <p>Can anyone help me if I am doing something wrong here.</p>
  
  <p>thanks,</p>
  
  <p>Sagar</p>