Index: pong.cpp
===================================================================
--- pong.cpp	(revision 4046b512410310ef75fc095a1b52613c4a3cab78)
+++ pong.cpp	(revision 237ec283524806ce8da95be9a601a3d79fcb0479)
@@ -87,7 +87,10 @@
    // glFrontFace(GL_CW);
 
-   unsigned int numBallPoints = 3;
-
-   GLfloat* points = createCirclePoints(numBallPoints, 0.0f, 0.0f, 0.2f);
+   unsigned int numBallPoints = 36;
+
+   GLfloat ballRadius = 0.2f;
+   GLfloat paddleThickness = 0.1f;
+
+   GLfloat* points = createCirclePoints(numBallPoints, 0.0f, 0.0f, ballRadius);
    GLfloat* colors = createCircleColors(numBallPoints);
 
@@ -117,6 +120,6 @@
    };
 
-   GLuint ball_points_vbo = createDataBuffer(numBallPoints*3*sizeof(GLfloat), points);
-   GLuint ball_colors_vbo = createDataBuffer(numBallPoints*3*sizeof(GLfloat), colors);
+   GLuint ball_points_vbo = createDataBuffer(numBallPoints*9*sizeof(GLfloat), points);
+   GLuint ball_colors_vbo = createDataBuffer(numBallPoints*9*sizeof(GLfloat), colors);
    GLuint ball_vao = createArrayBuffer(ball_points_vbo, ball_colors_vbo);
 
@@ -147,7 +150,15 @@
       previous_seconds = current_seconds;
 
-      if (fabs(last_position) > 1.0f) {
+      if (last_position > 1.0f-ballRadius) {
          speed = -speed;
       }
+
+      if (last_position < -1.0f+ballRadius+paddleThickness &&
+         fabs(last_paddle_pos) < 0.15f) {
+         speed = -speed;
+      }
+
+      // if the ball hits the paddle on a corner, I should make it bounce
+      // off at an angle
 
       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -163,6 +174,5 @@
       glDrawArrays(GL_TRIANGLES, 0, sizeof(points_paddle)/sizeof(GLfloat)/3);
 
-      // model[12] = last_position + speed*elapsed_seconds;
-      model[12] = 0.0f;
+      model[12] = last_position + speed*elapsed_seconds;
       last_position = model[12];
       model[13] = 0.0f;
@@ -173,5 +183,5 @@
       glEnableVertexAttribArray(1);
 
-      glDrawArrays(GL_TRIANGLES, 0, numBallPoints);
+      glDrawArrays(GL_TRIANGLES, 0, numBallPoints*3);
 
       glfwPollEvents();
@@ -250,25 +260,27 @@
 
 GLfloat* createCirclePoints(unsigned int smoothness, GLfloat centerX, GLfloat centerY, GLfloat radius) {
-   GLfloat* points = new GLfloat[smoothness*3];
-
-   points[0] = 0.0f;
-   points[1] = 0.5f;
-   points[2] = 0.5f;
-   points[3] = -0.5f;
-   points[4] = -0.5f;
-   points[5] = 0.5f;
-   points[6] = 0.5f;
-   points[7] = -0.5f;
-   points[8] = 0.5f;
-
-   cout << "Sphere center: (" << centerX << ", " << centerY << ")" << endl;
-
-   smoothness *= 2;
+   GLfloat* points = new GLfloat[smoothness*9];
+
+   GLfloat curX, curY, nextX, nextY;
+   curX = centerX;
+   curY = centerY+radius;
+
    for (unsigned int i=0; i<smoothness; i++) {
-      double radians = PI/2 + 2*PI * i/smoothness;
-      cout << radians << endl;;      
-      GLfloat x = centerX + cos(radians)*radius;
-      GLfloat y = centerY + sin(radians)*radius;
-      cout << "point " << i << ": (" << x << ", " << y << ")" << endl;
+      double radians = PI/2 + 2*PI * (i+1)/smoothness;
+      nextX = centerX + cos(radians)*radius;
+      nextY = centerY + sin(radians)*radius;
+
+      points[i*9] = curX;
+      points[i*9+1] = curY;
+      points[i*9+2] = 0.5f;
+      points[i*9+3] = nextX;
+      points[i*9+4] = nextY;
+      points[i*9+5] = 0.5f;
+      points[i*9+6] = centerX;
+      points[i*9+7] = centerY;
+      points[i*9+8] = 0.5f;
+
+      curX = nextX;
+      curY = nextY;
    }
 
@@ -277,14 +289,11 @@
 
 GLfloat* createCircleColors(unsigned int smoothness) {
-   GLfloat* colors = new GLfloat[smoothness*3];
-
-   for (unsigned int i=0; i<smoothness; i++) {
+   GLfloat* colors = new GLfloat[smoothness*9];
+
+   for (unsigned int i=0; i<smoothness*3; i++) {
       colors[i*3] = 0.0f;
       colors[i*3+1] = 1.0f;
       colors[i*3+2] = 0.0f;
    }
-   colors[smoothness*3-3] = 0.0f;
-   colors[smoothness*3-2] = 0.0f;
-   colors[smoothness*3-1] = 1.0f;
 
    return colors;
