diff options
Diffstat (limited to 'src/com/jogamp/opencl/demos')
-rw-r--r-- | src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java | 12 | ||||
-rw-r--r-- | src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java | 11 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java b/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java index f03c0b8..e38b7b8 100644 --- a/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java +++ b/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java @@ -12,7 +12,6 @@ import com.jogamp.opencl.CLKernel; import com.jogamp.opencl.CLPlatform; import com.jogamp.opencl.CLProgram; import com.jogamp.opencl.CLProgram.CompilerOptions; -import com.jogamp.opencl.util.CLPlatformFilters; import com.jogamp.opencl.util.CLProgramConfiguration; import com.jogamp.opengl.util.awt.TextRenderer; import java.awt.Color; @@ -124,6 +123,7 @@ public class MultiDeviceFractal implements GLEventListener { textRenderer = new TextRenderer(frame.getFont().deriveFont(Font.BOLD, 14), true, true, null, false); } + @Override public void init(GLAutoDrawable drawable) { if(clContext == null) { @@ -281,11 +281,12 @@ public class MultiDeviceFractal implements GLEventListener { // setup one empty PBO per slice for (int i = 0; i < slices; i++) { + int length = width*height * SIZEOF_INT / slices; gl.glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo[i]); - gl.glBufferData(GL_PIXEL_UNPACK_BUFFER, width*height * SIZEOF_INT / slices, null, GL_STREAM_DRAW); + gl.glBufferData(GL_PIXEL_UNPACK_BUFFER, length, null, GL_STREAM_DRAW); gl.glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); - pboBuffers[i] = clContext.createFromGLBuffer(pbo[i], WRITE_ONLY); + pboBuffers[i] = clContext.createFromGLBuffer(pbo[i], length, WRITE_ONLY); } @@ -350,6 +351,7 @@ public class MultiDeviceFractal implements GLEventListener { } // rendering cycle + @Override public void display(GLAutoDrawable drawable) { GL gl = drawable.getGL(); @@ -439,6 +441,7 @@ public class MultiDeviceFractal implements GLEventListener { textRenderer.endRendering(); } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { if(this.width == width && this.height == height) @@ -541,6 +544,7 @@ public class MultiDeviceFractal implements GLEventListener { win.dispose(); } + @Override public void dispose(GLAutoDrawable drawable) { } @@ -550,7 +554,7 @@ public class MultiDeviceFractal implements GLEventListener { GLProfile.initSingleton(false); SwingUtilities.invokeLater(new Runnable() { - public void run() { + @Override public void run() { new MultiDeviceFractal(512, 512); } }); diff --git a/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java b/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java index 2e630c6..5bed5ae 100644 --- a/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java +++ b/src/com/jogamp/opencl/demos/joglinterop/GLCLInteroperabilityDemo.java @@ -31,6 +31,7 @@ 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; @@ -81,7 +82,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { // ib.rewind(); SwingUtilities.invokeLater(new Runnable() { - public void run() { + @Override public void run() { initUI(); } }); @@ -111,6 +112,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { } + @Override public void init(GLAutoDrawable drawable) { if(clContext == null) { @@ -149,7 +151,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { 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, BUFFER_SIZE, null, GL2.GL_DYNAMIC_DRAW); gl.glBindBuffer(GL2.GL_ARRAY_BUFFER, 0); gl.glDisableClientState(GL2.GL_VERTEX_ARRAY); @@ -181,7 +183,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { commandQueue = clContext.getMaxFlopsDevice().createCommandQueue(); - clBuffer = clContext.createFromGLBuffer(glObjects[VERTICES], CLGLBuffer.Mem.WRITE_ONLY); + clBuffer = clContext.createFromGLBuffer(glObjects[VERTICES], BUFFER_SIZE, CLGLBuffer.Mem.WRITE_ONLY); System.out.println("clsize: "+clBuffer.getCLSize()); System.out.println("cl buffer type: " + clBuffer.getGLObjectType()); @@ -196,6 +198,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { } + @Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); @@ -264,6 +267,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { } + @Override public void reshape(GLAutoDrawable drawable, int arg1, int arg2, int width, int height) { this.width = width; this.height = height; @@ -272,6 +276,7 @@ public class GLCLInteroperabilityDemo implements GLEventListener { pushPerspectiveView(gl); } + @Override public void dispose(GLAutoDrawable drawable) { } public static void main(String[] args) { |