diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-10-26 21:14:06 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-10-26 21:14:06 -0400 |
| commit | d0b7c4c404f5e7b05c66a527d536805c5845e30c (patch) | |
| tree | d683b08323d53ab97acfb409b9f17db3e0529c24 /balls.cl | |
| parent | c026f83acd9d69b6f8cc1196adf47628666a5e57 (diff) | |
| download | balls-d0b7c4c404f5e7b05c66a527d536805c5845e30c.zip | |
filled circle
Diffstat (limited to 'balls.cl')
| -rw-r--r-- | balls.cl | 30 |
1 files changed, 14 insertions, 16 deletions
@@ -1,22 +1,20 @@ -#define RADIUS 0.75 +#define RADIUS 0.75f __kernel void -balls(__global float4 *vertices, float tick) { - uint id; - int longitude, latitude; - float sign, phi, theta; +balls(__global float2 *position, __global float2 *vertices) { + size_t id, nsegs; + float theta; - id = get_global_id(0); - - longitude = id / 16; - latitude = id % 16; + position[0].x = 0.0f; + position[0].y = 0.0f; - sign = -2.0f * (longitude % 2) + 1.0f; - phi = 2.0f * M_PI_F * longitude / 16 + tick; - theta = M_PI_F * latitude / 16; + /* Center of circle. */ + vertices[0].x = position[0].x; + vertices[0].y = position[0].y; - vertices[id].x = RADIUS * sin(theta) * cos(phi); - vertices[id].y = RADIUS * sign * cos(theta); - vertices[id].z = RADIUS * sin(theta) * sin(phi); - vertices[id].w = 1.0f; + id = get_global_id(0); + nsegs = get_global_size(0)-1; + theta = 2.0f * M_PI_F * id / nsegs; + vertices[id+1].x = position[0].x + RADIUS * cos(theta); + vertices[id+1].y = position[0].y + RADIUS * sin(theta); } |