 
     func updateVertexBuffer()
     {
+        vertexBufferIndex = (vertexBufferIndex + 1) % VERTEX_BUFFER_COUNT
         updateVertextBufferWithTextureQuad(position: screenpos(animation.currentState!.p0), at:0)
         updateVertextBufferWithTextureQuad(position: screenpos(animation.currentState!.p1), at:1)
         updateVertextBufferWithTextureQuad(position: screenpos(animation.currentState!.p2), at:2)

    
    func createVertexBuffer()
    {
        vertexBuffer = device.makeBuffer(length: MemoryLayout<Float>.size*36, options:.storageModeManaged) // TODO: fix hardcoded buffer size?
    }

    func createUniformsBuffer()

            x+w/2, y-h/2, //c
            x+w/2, y+h/2  //d
        ]
        let currentVertextBuffer = vertexBuffers[vertexBufferIndex]
        let arraySize = sizeofArray(vertexData)
        let bufferPointer = currentVertextBuffer.contents() + arraySize * index
        memcpy(bufferPointer, vertexData, arraySize)
        currentVertextBuffer.didModifyRange(NSMakeRange(arraySize * index, sizeofArray(vertexData)))
    }

    func screenpos(_ p: (x: Double, y: Double)) -> (x: Float, y: Float)
