diff options
author | Sven Gothel <[email protected]> | 2011-05-18 05:58:26 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-05-18 05:58:26 +0200 |
commit | be2915e8eb6c1b230514a93c25a08f05217db8ea (patch) | |
tree | 867693b667db614c94bfd5ad2c69aefeef3ac896 /src/com/jogamp/opencl/demos/joglinterop | |
parent | bb3cc47fefe772fdb9977daf34d7f7289183ad7d (diff) |
sync with JOCL c6f97a2e6ea1d337f371152a2fee65ee1dd4c5d5
Diffstat (limited to 'src/com/jogamp/opencl/demos/joglinterop')
-rw-r--r-- | src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java b/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java index fbd3775..19f9e42 100644 --- a/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java +++ b/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java @@ -147,17 +147,18 @@ public class GLCLInteroperabilityDemo implements GLEventListener { // gl.glBufferData(GL2.GL_ELEMENT_ARRAY_BUFFER, ib.capacity() * SIZEOF_INT, ib, GL2.GL_STATIC_DRAW); // gl.glBindBuffer(GL2.GL_ELEMENT_ARRAY_BUFFER, 0); + final int bsz = MESH_SIZE * MESH_SIZE * 4 * SIZEOF_FLOAT; gl.glEnableClientState(GL2.GL_VERTEX_ARRAY); gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, glObjects[VERTICES]); - gl.glBufferData(GL2.GL_ARRAY_BUFFER, MESH_SIZE * MESH_SIZE * 4 * SIZEOF_FLOAT, null, GL2.GL_DYNAMIC_DRAW); + gl.glBufferData(GL2.GL_ARRAY_BUFFER, bsz, null, GL2.GL_DYNAMIC_DRAW); gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0); - gl.glDisableClientState(GL2.GL_VERTEX_ARRAY); + gl.glDisableClientState(GL2.GL_VERTEX_ARRAY); pushPerspectiveView(gl); gl.glFinish(); // init OpenCL - initCL(); + initCL(gl, bsz); // start rendering thread Animator animator = new Animator(drawable); @@ -166,7 +167,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { } } - private void initCL() { + private void initCL(GL2 gl, int bufferSize) { CLProgram program; try { @@ -181,7 +182,9 @@ public class GLCLInteroperabilityDemo implements GLEventListener { commandQueue = clContext.getMaxFlopsDevice().createCommandQueue(); - clBuffer = clContext.createFromGLBuffer(glObjects[VERTICES], CLGLBuffer.Mem.WRITE_ONLY); + clBuffer = clContext.createFromGLBuffer(glObjects[VERTICES], + bufferSize /* gl.glGetBufferSize(glObjects[VERTICES]*/, + CLGLBuffer.Mem.WRITE_ONLY); System.out.println("cl buffer type: " + clBuffer.getGLObjectType()); System.out.println("shared with gl buffer: " + clBuffer.getGLObjectID()); @@ -230,9 +233,9 @@ public class GLCLInteroperabilityDemo implements GLEventListener { kernel.setArg(2, step += 0.05f); - commandQueue.putAcquireGLObject(clBuffer.ID) + commandQueue.putAcquireGLObject(clBuffer) .put2DRangeKernel(kernel, 0, 0, MESH_SIZE, MESH_SIZE, 0, 0) - .putReleaseGLObject(clBuffer.ID) + .putReleaseGLObject(clBuffer) .finish(); } |