title: How to use vao and buffers in OpenGL 4.5
body: <p>I'd like to render a triangle using OpenGL 4.5. I have found lot's of examples online using older versions of OpenGL but none using OpenGL 4.5 functions. Therefore I tried to "upgrade" some code myself. This is the old working code:</p>
  
  <pre><code>// Triangles to render
  vec3 vertices[2][3] = { { vec3(-0.90f, -0.90f, 1.0f), vec3(0.85f, -0.90f, 1.0f), vec3(-0.90f, 0.85f, 1.0f) },
                      { vec3(0.90f, -0.85f, 1.0f),  vec3(0.90f, 0.90f, 1.0f),  vec3(-0.85f, 0.90f, 1.0f) } };
  
  //Initialize
  glGenVertexArrays(1, &amp;vaos);
  glBindVertexArray(vaos);
  
  glGenBuffers(1, &amp;buffers);
  glBindBuffer(GL_ARRAY_BUFFER, buffers);
  glBufferData(GL_ARRAY_BUFFER, sizeof(triangles), triangles, GL_STATIC_DRAW);
  
  ShaderInfo shaders[] = {
      { GL_VERTEX_SHADER, "triangles.vert" },
      { GL_FRAGMENT_SHADER, "triangles.frag" },
      { GL_NONE, NULL }
  };
  program = LoadShaders(shaders);
  glUseProgram(program);
  
  glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
  glEnableVertexAttribArray(0);
  
  //Render
  GLint index;
  index = glGetUniformLocation(program, "projectionMatrix");
  glUniformMatrix3fv(index, 1, true, value_ptr(projectionMatrix));
  glClear(GL_COLOR_BUFFER_BIT);
  glBindVertexArray(vaos);
  glDrawArrays(GL_TRIANGLES, 0, nvertices);
  </code></pre>
  
  <p>And I "updated" it to this code, which doesn't appear to draw anything on screen:</p>
  
  <pre><code>// Same triangles
  // Initialize
  glCreateVertexArrays(1, &amp;vaos);
  glEnableVertexArrayAttrib(vaos, 0);
  glVertexArrayAttribFormat(vaos, 0, 3, GL_FLOAT, GL_FALSE, 0);
  
  glCreateBuffers(1, &amp;buffers);
  glNamedBufferData(buffers, sizeof(triangles), triangles, GL_STATIC_DRAW);
  
  glVertexArrayAttribBinding(vaos, 0, 0);
  glVertexArrayVertexBuffer(vaos, 0, buffers, 0, 0);
  
  ShaderInfo shaders[] = {
      { GL_VERTEX_SHADER, "triangles.vert" },
      { GL_FRAGMENT_SHADER, "triangles.frag" },
      { GL_NONE, NULL }
  };
  program = LoadShaders(shaders);
  glUseProgram(program);
  
  // Same render
  </code></pre>
  
  <p>Could someone tell me what I did wrong?</p>
  
  <p>Edit:
  triangle.frag</p>
  
  <pre><code>#version 450
  
  in vec4 gl_FragCoord;
  out vec4 fColor;
  
  void main ()
  {
      fColor = vec4 (0.0, 0.0, 1.0, 1.0);
  }
  </code></pre>
  
  <p>triangle.vert</p>
  
  <pre><code>#version 450
  
  layout (location = 0) in vec3 vPosition;
  
  uniform mat3 projectionMatrix;
  
  void main ()
  {
      vec3 tmp = projectionMatrix*vPosition;
      gl_Position = vec4 (tmp, 1.0f);
  }
  </code></pre>