diff options
author | Michael Bien <[email protected]> | 2009-10-27 18:56:37 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2009-10-27 18:56:37 +0100 |
commit | 92e523588e6ebb9ef6b7ad3156930b8e0ea2597f (patch) | |
tree | 37b87f8bab234fad73da386fdd91455147fd9ba9 /src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl | |
parent | e15fbc28ae250f3f944c4061d28ef7c41799d2de (diff) |
initial import of JOGL-JOCL interoperability sample (WIP).
Diffstat (limited to 'src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl')
-rw-r--r-- | src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl b/src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl new file mode 100644 index 0000000..02356b2 --- /dev/null +++ b/src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl @@ -0,0 +1,23 @@ +/* + * Simple kernel to modify vertex positions in sine wave pattern + */ +__kernel void sineWave(__global float4 * pos, unsigned int width, unsigned int height, float time) { + + unsigned int x = get_global_id(0); + unsigned int y = get_global_id(1); + + // calculate uv coordinates + float u = x / (float) width; + float v = y / (float) height; + + u = u*2.0f - 1.0f; + v = v*2.0f - 1.0f; + + // calculate simple sine wave pattern + float freq = 4.0f; + float w = sin(u*freq + time) * cos(v*freq + time) * 0.5f; + + // write output vertex + pos[y*width+x] = (float4)(u, w, v, 1.0f); +} + |