Index: new-game.cpp
===================================================================
--- new-game.cpp	(revision 72802572b93fe6c54bae4fa36a60a5df9b28e789)
+++ new-game.cpp	(revision 05e43cfaad1e2aa6e293a3c0313b5f939192ce71)
@@ -43,4 +43,6 @@
    mat4 model_mat;
    GLuint shader_program;
+   GLvoid* vbo_offset;
+   unsigned int num_points;
 };
 
@@ -233,7 +235,4 @@
    };
 
-   // Each point is made of 3 floats
-   int numPoints = (sizeof(points) / sizeof(float)) / 3;
-
    GLfloat points2[] = {
        0.5f,  0.5f,  0.0f,
@@ -263,7 +262,4 @@
    };
 
-   // Each point is made of 3 floats
-   int numPoints2 = (sizeof(points2) / sizeof(float)) / 3;
-
    mat4 T_model, R_model;
 
@@ -271,4 +267,6 @@
    objects.push_back(SceneObject());
    objects[0].shader_program = 0;
+   objects[0].vbo_offset = (GLvoid*) (0 * sizeof(float) * 3);
+   objects[0].num_points = 6;
 
    T_model = translate(mat4(), vec3(0.45f, 0.0f, 0.0f));
@@ -287,4 +285,6 @@
    objects.push_back(SceneObject());
    objects[1].shader_program = 0;
+   objects[1].vbo_offset = (GLvoid*) (6 * sizeof(float) * 3);
+   objects[1].num_points = 6;
 
    T_model = translate(mat4(), vec3(-0.5f, 0.0f, -1.00f));
@@ -311,5 +311,8 @@
    glGenBuffers(1, &points_vbo);
    glBindBuffer(GL_ARRAY_BUFFER, points_vbo);
-   glBufferData(GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW);
+   glBufferData(GL_ARRAY_BUFFER, sizeof(points) + sizeof(points2), NULL, GL_DYNAMIC_DRAW);
+
+   glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(points), points);
+   glBufferSubData(GL_ARRAY_BUFFER, sizeof(points), sizeof(points2), points2);
 
    GLuint colors_vbo = 0;
@@ -321,16 +324,7 @@
    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao);
-   glBindBuffer(GL_ARRAY_BUFFER, points_vbo);
-   glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-   glBindBuffer(GL_ARRAY_BUFFER, colors_vbo);
-   glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
 
    glEnableVertexAttribArray(0);
    glEnableVertexAttribArray(1);
-
-   GLuint points2_vbo = 0;
-   glGenBuffers(1, &points2_vbo);
-   glBindBuffer(GL_ARRAY_BUFFER, points2_vbo);
-   glBufferData(GL_ARRAY_BUFFER, sizeof(points2), points2, GL_STATIC_DRAW);
 
    GLuint colors2_vbo = 0;
@@ -347,10 +341,4 @@
    glGenVertexArrays(1, &vao2);
    glBindVertexArray(vao2);
-   glBindBuffer(GL_ARRAY_BUFFER, points2_vbo);
-   glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-   // glBindBuffer(GL_ARRAY_BUFFER, colors2_vbo);
-   // glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-   glBindBuffer(GL_ARRAY_BUFFER, vt_vbo);
-   glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, NULL);
 
    glEnableVertexAttribArray(0);
@@ -515,33 +503,22 @@
          glUniformMatrix4fv(model_test_loc, 1, GL_FALSE, value_ptr(objects[*it].model_mat));
 
+         glBindBuffer(GL_ARRAY_BUFFER, points_vbo);
+         glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, objects[*it].vbo_offset);
+
          if (selectedObject == &objects[*it]) {
             if (*it == 1) {
-               glBindBuffer(GL_ARRAY_BUFFER, points2_vbo);
-               glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-
                glBindBuffer(GL_ARRAY_BUFFER, colors2_vbo);
-               glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-
-               glDrawArrays(GL_TRIANGLES, 0, numPoints2);
             } else {
-               glBindBuffer(GL_ARRAY_BUFFER, points_vbo);
-               glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-
                glBindBuffer(GL_ARRAY_BUFFER, colors_vbo);
                glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors_new, GL_STATIC_DRAW);
-               glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-
-               glDrawArrays(GL_TRIANGLES, 0, numPoints);
             }
          } else {
-            glBindBuffer(GL_ARRAY_BUFFER, points_vbo);
-            glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-
             glBindBuffer(GL_ARRAY_BUFFER, colors_vbo);
             glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors, GL_STATIC_DRAW);
-            glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
-
-            glDrawArrays(GL_TRIANGLES, 0, numPoints);
          }
+
+         glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
+
+         glDrawArrays(GL_TRIANGLES, 0, objects[*it].num_points);
       }
 
@@ -552,5 +529,11 @@
          glUniformMatrix4fv(model_mat_loc, 1, GL_FALSE, value_ptr(objects[*it].model_mat));
 
-         glDrawArrays(GL_TRIANGLES, 0, numPoints2);
+         glBindBuffer(GL_ARRAY_BUFFER, points_vbo);
+         glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, objects[*it].vbo_offset);
+
+         glBindBuffer(GL_ARRAY_BUFFER, vt_vbo);
+         glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, NULL);
+
+         glDrawArrays(GL_TRIANGLES, 0, objects[*it].num_points);
       }
 
