title: OpenGL - Not able to copy data past a certain size to bound VBO
body: <p>I'm still trying to grasp the quirks of OpenGL but it doesn't help trying to learn on OSX which uses OpenGL 4.2 Core, which could be relevant.</p>
  
  <p>All I'm simply trying to do is copy an array of vertex data parsed from an object file, which shows up fine if I iterate through that data, into a bound VBO, however when I use <code>glGetBufferSubData</code> to return the contents of the currently bound VBO it shows the data fine for a few dozen lines then starts display what only I can see as corrupted data like so...</p>
  
  <pre><code>Vertex: (-0.437500, 0.328125, 0.765625)
  Vertex: (0.500000, 0.390625, 0.687500)
  Vertex: (-0.500000, 0.390625, 0.687500)
  Vertex: (0.546875, 0.437500, 0.578125)
  Vertex: (-0.546875, 0.437500, 0.578125)
  -------------------vvvvv corrupts here
  Vertex: (0.625000, 19188110749038498652920741888.000000, 12125095608195490978463744.000000)
  Vertex: (68291490374736750313472.000000, 70795556751816250086766057357312.000000, 0.000000)
  Vertex: (4360831549674110915425861632.000000, 4544202249129758853702852018176.000000, 50850084445497733730842814971904.000000)
  </code></pre>
  
  <p>This happens even if I try initializing a buffer of the same or similar size with all zeroes, it gets weird after some arbitrary amount. Here's a snippet to see what I'm doing, but I can't imagine what's going on.</p>
  
  <pre><code>// Parse an OBJ file
  compositeWavefrontObj com;
  parseObjFileVerticies("suzanne.obj", &amp;com);
  
  // Bind a vertex array object
  GLuint vao;
  glGenVertexArrays(1, &amp;vao);
  glBindVertexArray(vao);
  
  // copy vertex buffer data
  GLuint vbo;
  glGenBuffers(1, &amp;vbo);
  glBindBuffer(GL_ARRAY_BUFFER, vbo);
  glBufferData(GL_ARRAY_BUFFER, com.attrib-&gt;num_vertices*sizeof(GLfloat), 0, GL_STATIC_DRAW);
  glBufferSubData(GL_ARRAY_BUFFER, 0, com.attrib-&gt;num_vertices*sizeof(GLfloat), com.attrib-&gt;vertices);
  
  // Read back data from bound buffer object
  GLfloat *vertBuffer = malloc(sizeof(GLfloat) * com.attrib-&gt;num_vertices);
  glGetBufferSubData(GL_ARRAY_BUFFER, 0, com.attrib-&gt;num_vertices, vertBuffer);
  for (int i = 0; i &lt; com.attrib-&gt;num_vertices; ++i) {
      printf("Vertex: (%f,", *(vertBuffer+i));
      ++i;
      printf(" %f,", *(vertBuffer+i));
      ++i;
      printf(" %f)\n", *(vertBuffer+i));
  }
  printf("\n\n\n");
  </code></pre>