title: Error in Compiling Fragment Shader Program in OpenGL es , Android
body: <p>I'm new to OpenGL and today I was trying to compile some shader programs for GPGPU usage of OpenGL in android OS. 
  I have two questions:
  1) I only want to program fragment shader, Is it necessary to program the vertex shader too?
  2) I face some Errors while compiling my shader source code.
  My source code is defined as :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>final String src = "#version 310 es\n" +
              "uniform sampler2D texUnit;\n" +
              "uniform int sequence;\n" +
              "void main(void)\n" +
              "{\n" +
              "const vec3 DotValue = {0.299f , 0.587f , 0.114f};\n" +
              "vec2 texCoord = gl_TexCoord[0].xy;\n" +
              "vec4 CurrentPixelData  = texture2D(texUnit, texCoord);\n" +
              "float temp = CurrentPixelData.x * DotValue.x + CurrentPixelData.y * DotValue.y + CurrentPixelData.z * DotValue.z;\n" +
              "vec4 result = {temp,temp,temp,CurrentPixelData.w};\n" +
              "gl_FragColor = result;\n" +
              "}\n";</code></pre>
  </div>
  </div>
  </p>
  
  <p>and the code for creating the shader is:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>int fragment = GLES20.glCreateShader(GLES20.GL_FRAGMENT_SHADER);
          GLES20.glShaderSource(fragment,src);
          GLES20.glCompileShader(fragment);
  
  
  
          int[] compiled = new int[1];
          GLES20.glGetShaderiv(fragment, GLES20.GL_COMPILE_STATUS, compiled, 0); //compile[0] != 0 : compiled successfully
          if (compiled[0] == 0) {
              Log.e(TAG, "Could not compile shader: ");
              Log.e(TAG, GLES20.glGetShaderInfoLog(fragment));
              GLES20.glDeleteShader(fragment);
              fragment = 0;
          } else {
              Log.i(TAG, "Compiled shader with source length " + src.length());
          }</code></pre>
  </div>
  </div>
  </p>
  
  <p>But when i try to debug my application, there are several errors about shader compilation in the logcat:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    0:6: L0001: Expected token ';', found '{'
      0:7: L0002: Undeclared variable 'gl_TexCoord'
      0:8: L0002: No matching function for call to 'texture2D'
      0:9: L0002: Undeclared variable 'CurrentPixelData'
      0:10: L0001: Expected token ';', found '{'
      0:11: L0002: Undeclared variable 'gl_FragColor'</code></pre>
  </div>
  </div>
  </p>
  
  <p>Can anyone help me what is wrong with my code?
  Thanks in advance.  </p>