summaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl')
-rw-r--r--src/com/mbien/opencl/demos/joglinterop/JoglInterop.cl23
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);
+}
+