title: OpenGL Shader errors (storage qualifiers, undeclared identifiers and float conversions)
body: <p>I'm starting out with OpenGL and have made my first shaders (following <a href="https://www.youtube.com/watch?v=8n1GV99FJ2Y" rel="nofollow">a tutorial</a>). Despite following the tutorial to the letter, I got a few errors (unlike the tutorial-giver).</p>
  
  <p>Despite thorough and inventive googling, I have found no help or explaination of what's going wrong. </p>
  
  <p>The source for my shaders is as follows:</p>
  
  <p>basicVertex.vs:</p>
  
  <pre><code>#version 330
  
  layout (location = 0) in vec3 position;
  
  void main() 
  {
      gl_Position = vec4(position, 1.0);
  }
  
  
  
  basicFragment.fs:
  
  #version 330
  
  out vec4 fragColor;
  
  void main() 
  {
      fragColor = vec4(0.0, 1.0, 1.0); 
  }
  </code></pre>
  
  <p>and the errors are as follows:</p>
  
  <pre><code>Shader could not be run: 
  ERROR: 0:? : '' : storage qualifier not valid with layout qualifier id 
  ERROR: 0:7: 'gl_Position' : undeclared identifier 
  ERROR: 0:7: 'assign' :  cannot convert from '4-component vector of float' to 'float'
  </code></pre>
  
  <p>(that is the entire command-line output).</p>
  
  <p>Here's the Shader loading/compilation code:</p>
  
  <p>package uk.co.gossfunkel.citadel3d.shader;</p>
  
  <p>import static org.lwjgl.opengl.GL20.<em>;
  import static org.lwjgl.opengl.GL32.</em>;</p>
  
  <p>public class Shader {
          private int program;</p>
  
  <pre><code>    public Shader() throws ShaderLoadException {
              program = glCreateProgram();
  
              if (program == 0) {
                      throw new ShaderLoadException();
              }
      }
  
      public void bind() {
              glUseProgram(program);
      }
  
      public void addVertexShader(String text) throws ShaderLoadException {
              addProgram(text, GL_VERTEX_SHADER);
      }
  
      public void addGeometryShader(String text) throws ShaderLoadException {
              addProgram(text, GL_GEOMETRY_SHADER);
      }
  
      public void addFragmentShader(String text) throws ShaderLoadException {
              addProgram(text, GL_FRAGMENT_SHADER);
      }
  
      public void compileShader() throws ShaderLoadException {
              glLinkProgram(program);
  
              if (glGetProgrami(program, GL_LINK_STATUS) == 0) {
                      throw new ShaderLoadException(glGetShaderInfoLog(program, 1024));
              }
  
              glValidateProgram(program);
  
              if (glGetProgrami(program, GL_VALIDATE_STATUS) == 0) {
                      throw new ShaderLoadException(glGetShaderInfoLog(program, 1024));
              }
      }
  
      private void addProgram(String text, int type) throws ShaderLoadException {
              int shader = glCreateShader(type);
              if (shader == 0) {
                      throw new ShaderLoadException();
              }
              glShaderSource(shader, text);
              glCompileShader(shader);
  
              if (glGetShaderi(shader, GL_COMPILE_STATUS) == 0) {
                      throw new ShaderLoadException(glGetShaderInfoLog(shader, 1024));
              }
  
              glAttachShader(program, shader);
      }
  </code></pre>
  
  <p>}</p>
  
  <p>If anyone can direct me to solutions or suggest what's wrong, I'd love to hear it. However, please don't just say "learn more OpenGL", as that isn't helpful. Thanks!</p>