title: Opengl Shader, what's the gl_FragColor's alpha components?
body: <p>I think it'll be a little bit simple answer.<br/>
  But I can't find the answer with googling.<br/>
  It's OpenGLES shader thing. I am using cocos2d-x engine. </p>
  
  <p>This is my fragment shader code. </p>
  
  <pre><code>precision lowp float;
  varying vec2 v_texCoord;
  uniform sampler2D u_texture;
  uniform vec4 u_lightPosition;
  
  void main()
  {
      vec4 col=texture2D(u_texture,v_texCoord);
  
      mediump float lightDistance = distance(gl_FragCoord, u_lightPosition);
      mediump float alpha = 100.0/lightDistance;
      alpha = min(alpha, 1.0);
      alpha = max(alpha, 0.0);
      col.w = alpha;
      //col.a = alpha;
  
  
      gl_FragColor=col;
  
  }
  </code></pre>
  
  <p>I just want to give opacity in some circle area. So I change the color's w value because I thought it's the alpha value of the texel. But the result was very odd. 
  I am afraid it's not alpha value. 
  <br/></p>
  
  <p>Even if I set the value to 1.0 for testing, whole sprite change to be bright and white. </p>
  
  <p><br/>
  Its vertex shader is very normal, there is nothing special to attached. </p>
  
  <p><br/></p>
  
  <p>Any idea please. </p>
  
  <p><br/>
  <br/></p>
  
  <p><strong>Updated:</strong> For reference, I attach some result image.</p>
  
  <p>case 1) </p>
  
  <pre><code>col.w = alpha;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/fy9VW.png" alt="enter image description here"></p>
  
  <p>case 2)</p>
  
  <pre><code>col.w = 1.0
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/EH4B2.png" alt="enter image description here"></p>
  
  <p><br/>
  and normal texture before applying shader.) </p>
  
  <p><img src="https://i.stack.imgur.com/nG7VJ.png" alt="enter image description here"></p>