title: Problems with Rendering a quad in OpenGL by using indeces
body: <p>I want to draw a quad with <code>OpenGL</code>, but it doesn't work, since I introduced indexing. Without indexes my code worked fine and I could use <code>glDrawArrays</code> : </p>
  
  <pre><code>#define GLEW_STATIC
  #include &lt;GL\glew.h&gt;
  #include &lt;GLFW\glfw3.h&gt;
  #include &lt;GL\glew.h&gt;
  #include &lt;glm.hpp&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  #define WIDTH 800
  #define HEIGHT 600
  #define TITLE "Dynamic"
  
  GLFWwindow* window;
  int vaoID;
  
  
  std::vector&lt;float&gt; vertices = {-0.5f, 0.5f, 0,      -0.5f, -0.5f, 0,        0.5f, -0.5f, 0, 0,      0.5f, 0.5f, 0};
  std::vector&lt;int&gt; indices = { 0, 1, 3,   3, 1, 2 };
  void loadToVAO(std::vector&lt;float&gt; vertices, std::vector&lt;int&gt; indices);
  
  void update() {
      loadToVAO(vertices, indices);
      while (!glfwWindowShouldClose(window)) {
          glfwPollEvents();
          glClear(GL_COLOR_BUFFER_BIT);
          glClearColor(1, 0, 0, 1);
          //glDrawArrays(GL_TRIANGLES, 0, 6);
          glDrawElements(GL_TRIANGLES, 6, GL_INT, 0);
          glfwSwapBuffers(window);
      }
  }
  
  int main() {
      if (!glfwInit())
          std::cout &lt;&lt; "Couldn't initialize GLFW!" &lt;&lt; std::endl;
  
      window = glfwCreateWindow(WIDTH, HEIGHT, TITLE, NULL, NULL);
      glfwMakeContextCurrent(window);
      glfwSwapInterval(1);
  
      if (GLEW_OK != glewInit())
          std::cout &lt;&lt; "GLEW is not working!" &lt;&lt; std::endl;
  
      std::cout &lt;&lt; "Your GL version: " &lt;&lt; glGetString(GL_VERSION) &lt;&lt; std::endl;
      //glEnable(GL_CULL_FACE);
      //glCullFace(GL_BACK);
      update();
  }
  
  void loadToVAO(std::vector&lt;float&gt; vertices, std::vector&lt;int&gt; indices) {
      GLuint vertexVBO;
      GLuint indicesVBO;
      GLuint vaoID;
      glGenBuffers(1, &amp;vertexVBO);
      glGenVertexArrays(1, &amp;vaoID);
      glBindVertexArray(vaoID);
      glGenBuffers(1, &amp;indicesVBO);
      glBindBuffer(GL_ARRAY_BUFFER, vertexVBO);
      glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indicesVBO);
      glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices) * sizeof(int), &amp;indices[0], GL_STATIC_DRAW);
      glBufferData(GL_ARRAY_BUFFER, sizeof(vertices) * sizeof(float), &amp;vertices[0], GL_STATIC_DRAW);
      glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
      glEnableVertexAttribArray(0);
  }
  </code></pre>