#ifdef _WIN32
	#define WIN32_LEAN_AND_MEAN
#endif

#include "ritkCudaMacros.h"
#include "KinectImageCudaDepthToWorldFilterKernel.h"


extern "C"
void
CUDARangeToWorldKernel(const cudaArray *InputImageArray, float3 *DeviceOutput, int w, int h, float X2Z, float Y2Z)
{
	// Set input image texture parameters and bind texture to the array. Texture is defined in the kernel
	InputImageTexture.addressMode[0] = cudaAddressModeClamp;
	InputImageTexture.addressMode[1] = cudaAddressModeClamp;
	InputImageTexture.filterMode = cudaFilterModePoint;
	InputImageTexture.normalized = false;
	ritkCudaSafeCall(cudaBindTextureToArray(InputImageTexture, InputImageArray));
	
	// Kernel Invocation
	dim3 DimBlock(16,16);
	dim3 DimGrid(DivUp(w,DimBlock.x),DivUp(h,DimBlock.y));
	CUDAKinectRangeToWorldKernel<16,16><<<DimGrid,DimBlock>>>(DeviceOutput, w, h, X2Z, Y2Z);

	// Unbind texture
	ritkCudaSafeCall(cudaUnbindTexture(InputImageTexture));
}
