 #include <GL/glut.h>
 #include <GL/gl.h>
 #endif
-
+// CUDA
 #include <cuda_runtime.h>
 #include <cuda_gl_interop.h>
 #include <helper_cuda.h>
-#include <helper_cuda_gl.h> 
-
+#include <helper_cuda_gl.h>
+// COMMON
 #include <aligned_allocator.h>
-
+// Headers
 #include "boid.h"
 #include "flock.h"
 #include "vector3f.h"
 
+// Simulation Variables
 double rX = 0.0;
 double rY = 0.0;
 float sim_time = 0.0;
 int n = 0;
-int window_width = 1000;
-int window_height = 1000;
-int mesh_width = 500;
-int mesh_height = 500;
+// Constants
+const unsigned int window_width = 512;
+const unsigned int window_height = 512;
+const unsigned int mesh_width = 256;
+const unsigned int mesh_height = 256;
+//VBO
 GLuint positionsVBO;
 struct cudaGraphicsResource* positionsVBO_CUDA;
 
-__global__ void kernel(float4* positions, unsigned int mesh_width, unsigned int mesh_height, float time) {
+__global__ void kernel(float4* positions, unsigned int width, unsigned int height, float t) {
    unsigned int x = blockIdx.x * blockDim.x + threadIdx.x;
    unsigned int y = blockIdx.y * blockDim.y + threadIdx.y;
 
-   float u = x / (float)mesh_width;
-   float v = y / (float)mesh_height;
+   float u = x / (float)width;
+   float v = y / (float)height;
    u = u * 2.0f - 1.0f;
    v = v * 2.0f - 1.0f;
 
    float freq = 4.0f;
-   float w = sinf(u * freq + time)
-	   * cosf(v * freq + time) * 0.5f;
-
-   positions[y * mesh_width + x] = make_float4(u, w, v, 1.0f);
+   float w = sinf(u * freq + t)
+	   * cosf(v * freq + t) * 0.5f;
+
+   positions[y * width + x] = make_float4(u, w, v, 1.0f);
 }
 
 __host__ void help() {

// De-allocation of Memory after GLUT stops
__host__ void onGLUTExit() {
   fprintf(stdout, "De-Allocating memory.\n");
   //Deallocate(h_flock);
}

__host__ 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) );
}

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

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

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

  }

  // Request display update
  glutPostRedisplay();
}

__host__ void idleSim() {
  glutPostRedisplay();
}

// Called when OpenGL Window is resized to handle scaling
