title: OpenGLESv2 Shader glGetAttribLocation returns -1
body: <p>Hey, I try to code a OpenGL ES 2 engine but at shader creation the function glGetAttribLocation returns -1 which means </p>
  
  <blockquote>
    <p>The named attribute variable is not an
    active    attribute in the specified
    program object or the name starts with
    the reserved prefix   "gl_".</p>
  </blockquote>
  
  <p>But it IS defined in the shader and doesnt start with gl_.
  Whats wrong with my code?</p>
  
  <p>C++ Code:</p>
  
  <pre><code>glprogram = glCreateProgram();
  
  glvertshader = glCreateShader(GL_VERTEX_SHADER);
  glfragshader = glCreateShader(GL_FRAGMENT_SHADER);
  
  glShaderSource(glvertshader, 1, vertsrc, NULL);
  glShaderSource(glfragshader, 1, fragsrc, NULL);
  
  GLint ret;
  
  glCompileShader(glvertshader);
  glGetShaderiv(glvertshader, GL_COMPILE_STATUS, &amp;ret);
  if(!ret)
  {
      ///error handling - stripped for the internet
  }
  
  glCompileShader(glfragshader);
  glGetShaderiv(glfragshader, GL_COMPILE_STATUS, &amp;ret);
  if(!ret)
  {
      ///error handling - stripped for the internet
  }
  
  glAttachShader(glprogram, glvertshader);
  glAttachShader(glprogram, glfragshader);
  
  glLinkProgram(glprogram);
  
  glGetProgramiv(glprogram, GL_LINK_STATUS, &amp;ret);
  if(!ret)
  {
      ///error handling - stripped for the internet
  }
  
  glattributes[0] = glGetAttribLocation(glprogram, "vertex");
  glattributes[1] = glGetAttribLocation(glprogram, "texcoord_vs");
  
  
  
  std::cout &lt;&lt; "texcoord " &lt;&lt; glGetAttribLocation(glprogram, "texcoord_vs";
  </code></pre>
  
  <p>Vert shader:</p>
  
  <pre><code>// Vertex Shader for OpenGL ES
  uniform mat4 projmat;
  uniform mat4 modviewmat;
  
  attribute vec2 vertex;
  attribute vec2 texcoord_vs;
  
  varying vec2 texcoord_fs;
  
  void main()
  {
      texcoord_fs = texcoord_vs;
      gl_Position = projmat*modviewmat*vec4(vertex, 0.0, 1.0);
  }
  </code></pre>
  
  <p>edit: correct shader code and the error is with texcoord_vs.</p>