     
     modelViewProjectionMatrix = GLKMatrix4Multiply(projectionMatrix, modelViewMatrix)
     
-//    rotation += Float(self.timeSinceLastUpdate * 0.5)
+  }
+  
+  func drawLine(from : (x: GLfloat, y: GLfloat), to: (x: GLfloat, y: GLfloat), width: GLfloat) {
+    let width = width / pointScale
+    
+    // Calculate the rotation for this vector
+    let rotation_angle = atan2(to.y-from.y, to.x-from.x)
+
+    let length = sqrt(pow(to.y-from.y, 2) + pow(to.x-from.x, 2))
+    var baseMatrix = GLKMatrix4Identity
+    baseMatrix = GLKMatrix4Translate(baseMatrix, from.x, from.y, 0.1)
+    baseMatrix = GLKMatrix4Rotate(baseMatrix, (0.5*3.1415926)-rotation_angle, 0, 0, -1)
+    baseMatrix = GLKMatrix4Scale(baseMatrix, width, length, 1)
+    baseMatrix = GLKMatrix4Translate(baseMatrix, -0.5, 0, 0)
+    
+    var mvp = GLKMatrix4Multiply(projectionMatrix, baseMatrix)
+    withUnsafePointer(&mvp, {
+      glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX], 1, 0, UnsafePointer($0));
+    })
+    glDrawArrays(GLenum(GL_TRIANGLES), 0, 6)
+  }
+  
+  func drawTriangle(point : (x: GLfloat, y: GLfloat), rotation : GLfloat, height : GLfloat)
+  {
+//    let height = height / pointScale
+    
+    var baseMatrix = GLKMatrix4Identity
+    baseMatrix = GLKMatrix4Translate(baseMatrix, point.x, point.y, 0.1)
+    baseMatrix = GLKMatrix4Rotate(baseMatrix, rotation, 0, 0, -1)
+    baseMatrix = GLKMatrix4Scale(baseMatrix, height, height, 1)
+    
+    var mvp = GLKMatrix4Multiply(projectionMatrix, baseMatrix)
+    withUnsafePointer(&mvp, {
+      glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX], 1, 0, UnsafePointer($0));
+    })
+    glDrawArrays(GLenum(GL_TRIANGLES), 6, 3)
+    
+  }
+  
+  func drawHUDCenter() {
+    let hudOff = (gSquareVertexData.count + gTriangleData.count)/3
+    var baseMatrix = GLKMatrix4MakeTranslation(0.5, 0.5, 0)
+    var mvp = GLKMatrix4Multiply(projectionMatrix, baseMatrix)
+    withUnsafePointer(&mvp, {
+      glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX], 1, 0, UnsafePointer($0));
+    })
+    glDrawArrays(GLenum(GL_TRIANGLE_STRIP), GLint(hudOff), GLint(gCenterHUD.count/3))
+    baseMatrix = GLKMatrix4Scale(baseMatrix, -1, 1, 1)
+    mvp = GLKMatrix4Multiply(projectionMatrix, baseMatrix)
+    withUnsafePointer(&mvp, {
+      glUniformMatrix4fv(uniforms[UNIFORM_MODELVIEWPROJECTION_MATRIX], 1, 0, UnsafePointer($0));
+    })
+    
+    glDrawArrays(GLenum(GL_TRIANGLE_STRIP), GLint(hudOff), GLint(gCenterHUD.count/3))
+  }
+  
+  func PseudoLog10(x : Double) -> Double
+  {
+    
+    if abs(x) <= 1.0 {
+      return x
+    }
+    return (1.0 + log10(abs(x))) * sign(x)
+  }
+  
+  func InversePseudoLog10(x : Double) -> Double
+  {
+    if abs(x) <= 1.0 {
+      return x
+    }
+    return pow(10, abs(x)-1)*sign(x)
   }
   
   override func glkView(view: GLKView, drawInRect rect: CGRect) {

//      glUniformMatrix3fv(uniforms[UNIFORM_NORMAL_MATRIX], 1, 0, UnsafePointer($0));
//    })
    
    glDrawArrays(GLenum(GL_TRIANGLES), 0, 3)
    glUniform3f(uniforms[UNIFORM_COLOR], 1.0, 0.0, 0.0)
    glDrawArrays(GLenum(GL_TRIANGLES), 3, 3)
    
    //glInsertEventMarkerEXT(0, "com.apple.GPUTools.event.debug-frame")
  }
  
  // MARK: -  OpenGL ES 2 shader compilation

    
    glGenBuffers(1, &vertexBuffer)
    glBindBuffer(GLenum(GL_ARRAY_BUFFER), vertexBuffer)
    let vertexCount = gSquareVertexData.count + gTriangleData.count + gCenterHUD.count
//    glBufferData(GLenum(GL_ARRAY_BUFFER), GLsizeiptr(sizeof(GLfloat) * vertexCount), &gSquareVertexData, GLenum(GL_STATIC_DRAW))

    glBufferData(GLenum(GL_ARRAY_BUFFER), GLsizeiptr(sizeof(GLfloat) * vertexCount), nil, GLenum(GL_STATIC_DRAW))
    // Copy all data into the buffer
    glBufferSubData(GLenum(GL_ARRAY_BUFFER), 0, GLsizeiptr(sizeof(GLfloat)*gSquareVertexData.count), &gSquareVertexData)
//    copy_to_buffer(gSquareVertexData, offset: 0)
//    copy_to_buffer(gTriangleData, offset: gSquareVertexData.count)
//    copy_to_buffer(gCenterHUD, offset: gSquareVertexData.count + gTriangleData.count)
    
//    
    glBufferSubData(GLenum(GL_ARRAY_BUFFER), sizeof(GLfloat)*gSquareVertexData.count,
      GLsizeiptr(sizeof(GLfloat)*gTriangleData.count), &gTriangleData)
    glBufferSubData(GLenum(GL_ARRAY_BUFFER), sizeof(GLfloat)*(gSquareVertexData.count + gTriangleData.count),
      GLsizeiptr(sizeof(GLfloat)*gCenterHUD.count), &gCenterHUD)
    
//
    glEnableVertexAttribArray(GLuint(GLKVertexAttrib.Position.rawValue))
    glVertexAttribPointer(GLuint(GLKVertexAttrib.Position.rawValue), 3, GLenum(GL_FLOAT), GLboolean(GL_FALSE), 12, BUFFER_OFFSET(0))
//    glEnableVertexAttribArray(GLuint(GLKVertexAttrib.Normal.rawValue))
