title: openGL and vector
body: <p>I am using openGL and am currently passing it a vertex array. 
  It is run successfully when I pass OpenGL a vertex array with an array like</p>
  
  <pre><code>    GLfloat vertices[] = {
      0.500000000f, 0.500000000f, 0.500000000f, 1.00000000f, 0.000000000f, 0.000000000f,
      0.500000000f, -0.500000000f, 0.500000000f, 1.00000000f, 0.000000000f, 0.000000000f,
      0.500000000f, 0.500000000f, -0.500000000f, 1.00000000f, 0.000000000f, 0.000000000f};
  </code></pre>
  
  <p>The problem is that when I passing it with a vector instead of the array like </p>
  
  <pre><code>    std::vector&lt;GLfloat&gt; vertices = {
      0.500000000f, 0.500000000f, 0.500000000f, 1.00000000f, 0.000000000f, 0.000000000f,
      0.500000000f, -0.500000000f, 0.500000000f, 1.00000000f, 0.000000000f, 0.000000000f,
      0.500000000f, 0.500000000f, -0.500000000f, 1.00000000f, 0.000000000f, 0.000000000f};
  </code></pre>
  
  <p>then I can't see the triangle in my window.</p>
  
  <p>My code is almost like this
      <a href="https://learnopengl.com/code_viewer.php?code=getting-started/coordinate_systems_with_depth" rel="nofollow noreferrer">https://learnopengl.com/code_viewer.php?code=getting-started/coordinate_systems_with_depth</a></p>
  
  <p>And I changed this line </p>
  
  <pre><code>    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
  </code></pre>
  
  <p>into</p>
  
  <pre><code>    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), &amp;vertices[0], GL_STATIC_DRAW);
  </code></pre>
  
  <p>And I changed these lines</p>
  
  <pre><code>    // Position attribute
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)0);
      glEnableVertexAttribArray(0);
      // TexCoord attribute
      glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));
      glEnableVertexAttribArray(2);
  </code></pre>
  
  <p>into</p>
  
  <pre><code>    // Position attribute
      glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)0);
      glEnableVertexAttribArray(0);
      // NormalVector attribute
      glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, 6 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));
      glEnableVertexAttribArray(3);
  </code></pre>
  
  <p>because I need the normal vector information to do something else.</p>
  
  <p>Does anyone know how to use std::vector correctly?</p>
  
  <p>Thanks.</p>