From ce55087cc7868d949318e08dc751aae946f7035b Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Sun, 21 Nov 2010 21:29:20 +0100 Subject: propper shutdown in MultiDeviceFractal demo. --- .../opencl/demos/fractal/MultiDeviceFractal.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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) { } -- cgit v1.2.3