summaryrefslogtreecommitdiffstats
path: root/balls.cl
blob: bb1755de95dc6d2a58407d486a36a76e0c735273 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#define RADIUS 0.15f

__kernel void
balls(__global float2 *positions, __global float2 *vertices) {
	size_t ball, nsegs;
	float2 center;
	float theta;

	ball = get_group_id(0);
	center = positions[ball];

	nsegs = get_local_size(0)-2; /* Number of edge segments. */
	theta = 2.0f * M_PI_F * get_local_id(0) / nsegs;

	vertices[get_global_id(0)].x = center.x + RADIUS * cos(theta);
	vertices[get_global_id(0)].y = center.y + RADIUS * sin(theta);

	vertices[ball*get_local_size(0)] = center;
}