example.cl (724B)
1 // This is the main function of the program. 2 // Runcl passes the following arguments to the program. 3 // - width: the width of the image in pixels 4 // - height: the height of the image in pixels 5 // - *out: the output of the program, formatted as an 3xwxh array of normalized rgm pixel colors 6 kernel void render(const int width, const int height, __global float *out) 7 { 8 // this gets the id of the particular instance 9 const int i = get_global_id(0); 10 11 if ( i < width * height ) 12 { 13 // this converts the id into normalized image coordinates 14 float x = (float)(i % width) / width; 15 float y = (float)(i / width) / height; 16 17 // output the rgb color to the out array 18 out[3*i] = x; 19 out[3*i+1] = x; 20 out[3*i+2] = x; 21 } 22 }