 }
 
 __host__ void Render() {
-  // Set Background Color
-  glClearColor(0.4, 0.4, 0.4, 1.0);
+  
   // Clear screen
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-  // Reset transformations
+  
+  glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
-  
+
   // Perspective modifications
   glRotatef(rX, 1.0, 0.0, 0.0);
   glRotatef(rY, 0.0, 1.0, 0.0);
-
-  drawBoid();
-
-  //h_flock.update();
+  
+  glClearColor(0.0, 0.0, 0.0, 0.0);
+  glClear(GL_COLOR_BUFFER_BIT);
+  glColor3f(1.0, 0.0, 0.0);
+  glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
+
+  glBindBuffer(GL_ARRAY_BUFFER, positionsVBO);
+  glVertexPointer(4, GL_FLOAT, 0, 0);
+  glEnableClientState(GL_VERTEX_ARRAY);
+  glDrawArrays(GL_POINTS, 0, width * height); // Where the magic happens
+  glDisableClientState(GL_VERTEX_ARRAY);
+  
+  // Switch Buffers
+  glutSwapBuffers();
+  glutPostRedisplay();
 }
 
 __host__ void Keyboard(int key, int x, int y) {

#include "flock.h"
#include "vector3f.h"

static double device_time = 0.0;
double rX = 0.0;
double rY = 0.0;
int n = 0;
//Flock h_flock = Flock();

__global__ void gpu_boids_kernel(int n, Flock* dev_flock) {
   
}

__host__ void help() {
   fprintf(stderr,"./boids --help|-h --nboids|-n \n");
}

__host__ void gpu_boids(Flock* h_flock) {
  // Allocate Device Memory
  Flock* dev_flock = NULL;
  cudaMalloc(&dev_flock, sizeof(Boid)*n);
  // Create Cuda Events
  cudaEvent_t calc1_event, calc2_event;
  cudaEventCreate(&calc1_event);
  cudaEventCreate(&calc2_event);
  // Copy Host Memory to Device
  cudaMemcpy(dev_flock, h_flock, sizeof(Boid)*n, cudaMemcpyHostToDevice);
  cudaEventRecord(calc1_event);
  // Entering Kernel
  fprintf(stdout,"entering kernel.\n");
  gpu_boids_kernel<<<1,1>>>(n, dev_flock);
  cudaEventRecord(calc2_event);
  // Free Device Memory
  cudaFree(dev_flock);

  // Record device time
  float time;
  cudaEventElapsedTime(&time, calc1_event, calc2_event);
  device_time += time;

  // Destroy event timers
  cudaEventDestroy(calc1_event);
  cudaEventDestroy(calc2_event);

}

__host__ void drawBoid() {

void onGLUTExit() {
   fprintf(stdout, "De-Allocating memory.\n");
   //Deallocate(h_flock);
}

void createVBO(GLuint *vbo, struct cudaGraphicsResource **vbo_res, unsigned int vbo_res_flags) {
  
  // Create buffer object and register it with CUDA
  glGenBuffers(1, vbo);
  glBindBuffer(GL_ARRAY_BUFFER, *vbo);
  unsigned int size = mesh_width * mesh_height * 4 * sizeof(float);
  glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
  
  // Unbind Buffer
  glBindBuffer(GL_ARRAY_BUFFER, 0);
  
  // Register VBO
  checkCudaErrors( cudaGraphicsGLRegisterBuffer(vbo_res, *vbo, vbo_res_flags) );
}

void deleteVBO(GLuint *vbo, struct cudaGraphicsResource *vbo_res) {
  // Unregister with CUDA
  checkCudaErrors( cudaGraphicsUnregisterResource(vbo_res) );

  glBindBuffer(1, *vbo);
  glDeleteBuffers(1, vbo);
}

void runCUDA(struct cudaGraphicsResource ** vbo_resource) {
  // Map VBO to GL with CUDA
  float4* positions;
  checkCudaErrors( cudaGraphicsMapResources(1, vbo_resource, 0) );
  size_t num_bytes;
  checkCudaErrors( cudaGraphicsResourceGetMappedPointer((void ** )&positions,
		  &num_bytes,
		  vbo_resource) );

  launchKernel(positions, mesh_width, mesh_height, time); 
  // Unmap Buffer
  checkCudaErrors( cudaGraphicsUnmapResources(1, vbo_resource, 0) );
}

__host__ int main (int argc, char* argv[]) {
