 	assert(n > 0);
 	cudaMalloc((void**) &d_boids, boids_bytes);
 	assert(d_boids);
+	cudaBindTexture(0, boids_texture, d_boids, n * sizeof(boid));
+	check_cuda_error();
 	return d_boids;
 }
 


#define square(x) ((x)*(x))
#define MAX_SPEED 4

#define check_cuda_error() {\
	if (cudaError_t e = cudaGetLastError()) { \

	}
	cudaMemcpy(d_boids, sp->boids, boids_bytes, cudaMemcpyHostToDevice);
	check_cuda_error();
	reload_distance_cache(d_distance_cache, sp->n);
	calculate_all_forces(d_boids, sp->n, sp->eps, d_distance_cache);
	apply_all_forces(d_boids, sp->n, sp->dt, sp->width, sp->height);
	cudaThreadSynchronize();
