diff options
Diffstat (limited to 'src/com/jogamp/opencl/demos/fractal')
-rw-r--r-- | src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java b/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java index 3de851d..61002b0 100644 --- a/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java +++ b/src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java @@ -19,11 +19,14 @@ import java.awt.Dimension; import java.awt.Font; import java.awt.Frame; import java.awt.Point; +import java.awt.Window; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseWheelEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.io.IOException; import java.nio.IntBuffer; import java.util.logging.Level; @@ -105,7 +108,12 @@ public class MultiDeviceFractal implements GLEventListener { initSceneInteraction(); Frame frame = new Frame("JOCL Multi Device Mandelbrot Set"); -// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + MultiDeviceFractal.this.release(e.getWindow()); + } + }); canvas.setPreferredSize(new Dimension(width, height)); frame.add(canvas); frame.pack(); @@ -524,6 +532,14 @@ public class MultiDeviceFractal implements GLEventListener { return device.isDoubleFPAvailable() || device.isExtensionAvailable("cl_amd_fp64"); } + private void release(Window win) { + if(clContext != null) { + // releases all resources + clContext.release(); + } + win.dispose(); + } + public void dispose(GLAutoDrawable drawable) { } |