title: Android OpenGL ES 2.0 Vignette Mask
body: <p>I am on Android API Level 9. I have a Camera preview loaded into a SurfaceView. I am trying to  draw a vignette mask over this. In order to do so I am using a GLSurfaceView. I prepared a mask in XCode shader builder using the following fragment shader code (or is it a pixel shader?) which compiles successfully so far:</p>
  
  <pre><code>uniform sampler2D tex;
  
  void main()
  { 
  float innerAlpha = 0.0;
  float outerAlpha = 1.0;
  float len = 1.7;
  float startAdjustment = -0.2;
  float diff = 0.4;
  float alphaStep = outerAlpha / len;
  vec2 center = vec2(0.5, 0.5);
  vec2 foc1 = vec2(diff,0.);
  vec2 foc2 = vec2(-diff,0.);
  float r = distance(center+foc1,gl_TexCoord[0].xy) + distance(center+foc2,gl_TexCoord[0].xy);
  float alpha = r  - (diff * 2.0) * alphaStep - startAdjustment;
  vec4 vColor = vec4(0.,0.,0., innerAlpha + alpha);
  gl_FragColor = vColor;
  }
  </code></pre>
  
  <p>However, I do not know how to implement this into code for Android. Basically I think I would need to create a rectangle, which would cover the whole view and apply this kind of code generated texture on it. I just can not manage to figure out the actual code. Ideally, it should be in OpenGL ES 2.0.</p>
  
  <p>Edit1:</p>
  
  <p>@Tim - I tried to follow the tutorials here <a href="http://developer.android.com/training/graphics/opengl/draw.html" rel="nofollow">http://developer.android.com/training/graphics/opengl/draw.html</a> 
  and here 
  <a href="http://www.learnopengles.com/android-lesson-one-getting-started/" rel="nofollow">http://www.learnopengles.com/android-lesson-one-getting-started/</a> 
  and I basically understand, how to draw a triangle. But I do not understand, how to draw rectangle - I mean do I really need to draw two triangles actually or can I just define rectangle (or other complex shapes) right away? 
  As for the textures - in all tutorials I have seen, textures are actually being loaded from image files, but I would be interested in knowing, how can I actually kind of generate one using the pixel shader above.</p>