blob: 0c235c1ce047228bc8d10ae4b79071ee9a6f9e05 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#define RADIUS 0.15f
__kernel void
move(__global float2 *positions, __global float2 *velocities) {
size_t id;
id = get_global_id(0);
positions[id] += velocities[id];
}
__kernel void
genVertices(__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;
}
|