title: Drawing a line in modern OpenGL
body: <p>I simply want to draw a line to the screen. I'm using OpenGl 4.6. All tutorials I found used a <code>glVertexPointer</code>, which is deprecated as far as I can tell.</p>
  <p>I know how you can draw triangles using buffers, so I tried that with a line. It didn't work, merely displaying a black screen. (I'm using GLFW and GLEW, and I am using a vertex+fragment shader I already tested on the triangle)</p>
  <pre class="lang-cpp prettyprint-override"><code>// Make line
  float line[] = {
      0.0, 0.0,
      1.0, 1.0
  };
  
  unsigned int buffer; // The ID, kind of a pointer for VRAM
  glGenBuffers(1, &amp;buffer); // Allocate memory for the triangle
  glBindBuffer(GL_ARRAY_BUFFER, buffer); // Set the buffer as the active array
  glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(float), line, GL_STATIC_DRAW); // Fill the buffer with data
  glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0); // Specify how the buffer is converted to vertices
  glEnableVertexAttribArray(0); // Enable the vertex array
  
  // Loop until the user closes the window
  while (!glfwWindowShouldClose(window))
  {
      // Clear previous
      glClear(GL_COLOR_BUFFER_BIT);
  
      // Draw the line
      glDrawArrays(GL_LINES, 0, 2);
  
      // Swap front and back buffers
      glfwSwapBuffers(window);
  
      // Poll for and process events
      glfwPollEvents();
  }
  </code></pre>
  <p>Am I going in the right direction, or is a completely different approach the current best practice?</p>
  <p>If I am, how do I fix my code?</p>