title: OpenGL, a very basic shader not working
body: <p>I am learning OpenGL through <a href="https://www.youtube.com/user/TheChernoProject" rel="nofollow noreferrer">TheCherno Project</a>.
  The code below is from there and I faithfully reproduce it for my learning purpose. I have also added both vertex and fragment shaders as well.</p>
  
  <p>My issue here is in my square output I don't see the color at all and I am guessing it is using the default shader.</p>
  
  <pre><code> int main(void)
   {
   GLFWwindow* window;
  
  /* Initialize the library */
  if (!glfwInit())
      return -1;
  
  /* Create a windowed mode window and its OpenGL context */
  window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
  if (!window)
  {
      glfwTerminate();
      return -1;
  }
  
  /* Make the window's context current */
  glfwMakeContextCurrent(window);
  
  if (glewInit() != GLEW_OK)
      std::cout &lt;&lt; "ERROR GLEW" &lt;&lt; std::endl;
  
  std::cout &lt;&lt; glGetString(GL_VERSION) &lt;&lt; std::endl;
  
  float positions[] = {
          -0.5f,-0.5f,    //0
           0.5f, -0.5f,   //1
           0.5f, 0.5f,    //2
          -0.5f, 0.5f     //3
  };
  
  unsigned int indices[] = {
          0, 1, 2,
          2, 3, 0
  };
  
  unsigned int buffer;
  glGenBuffers(1, &amp;buffer);
  glBindBuffer(GL_ARRAY_BUFFER, buffer);
  glBufferData(GL_ARRAY_BUFFER, 6 * 2 * sizeof(float), positions, GL_STATIC_DRAW);
  
  
  glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0);
  glEnableVertexAttribArray(0);
  
  
  unsigned int ibo;
  glGenBuffers(1, &amp;ibo);
  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
  glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6 * sizeof(unsigned int), indices, GL_STATIC_DRAW);
  
  ShaderSourceProgram shader = ParseShader("res/shaders/Basic.shader");
  //std::cout &lt;&lt; "VERTEX" &lt;&lt; std::endl;
  //std::cout &lt;&lt; shader.VertexShader &lt;&lt; std::endl;
  unsigned int shaderProgram = CreateShader(shader.VertexShader, shader.FragmentShader);
  glUseProgram(shaderProgram);
  
  /* Loop until the user closes the window */
  while (!glfwWindowShouldClose(window))
  {
      /* Render here */
      glClear(GL_COLOR_BUFFER_BIT);
  
      //glDrawArrays(GL_TRIANGLES, 0, 6);
      glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr);
  
      /* Swap front and back buffers */
      glfwSwapBuffers(window);
  
      /* Poll for and process events */
      glfwPollEvents();
  }
  
  glDeleteProgram(shaderProgram);
  
  glfwTerminate();
  return 0;
  }
  </code></pre>
  
  <p>The shaders:</p>
  
  <pre><code>#shader vertex
  #version 330 core
  layout(location = 0)in vec4 position;
  
  void main()
  {
      gl_Position = position;
  };
  
  #shader fragment
  #version 330 core
  out vec4 color;
  
  void main()
  {
      color = vec4(0.0,1.0,0.0,1.0);
  };
  </code></pre>
  
  <p><strong>EDIT:</strong> <a href="https://github.com/jxgeoffrey/OpenGL/blob/master/OpenGL/src/Source.cpp" rel="nofollow noreferrer">Please click here for the entire project (github)</a></p>