diff options
Diffstat (limited to 'src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java')
-rw-r--r-- | src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java b/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java index 5bed5ae..8fb4c9f 100644 --- a/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java +++ b/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java @@ -31,7 +31,6 @@ public class GLCLInteroperabilityDemo implements GLEventListener { private final GLUgl2 glu = new GLUgl2(); private final int MESH_SIZE = 256; - private final int BUFFER_SIZE = MESH_SIZE * MESH_SIZE * 4 * SIZEOF_FLOAT; private int width; private int height; @@ -149,17 +148,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, BUFFER_SIZE, 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); @@ -168,7 +168,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { } } - private void initCL() { + private void initCL(GL2 gl, int bufferSize) { CLProgram program; try { @@ -183,8 +183,9 @@ public class GLCLInteroperabilityDemo implements GLEventListener { commandQueue = clContext.getMaxFlopsDevice().createCommandQueue(); - clBuffer = clContext.createFromGLBuffer(glObjects[VERTICES], BUFFER_SIZE, CLGLBuffer.Mem.WRITE_ONLY); - System.out.println("clsize: "+clBuffer.getCLSize()); + 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()); |