aboutsummaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-11-21 21:29:20 +0100
committerMichael Bien <[email protected]>2010-11-21 21:29:20 +0100
commitce55087cc7868d949318e08dc751aae946f7035b (patch)
treef4ace433096616641fedbda68a96026768ed26ac /src/com
parent5dbe8762cb190d207438da084b5b0cadd10a370a (diff)
propper shutdown in MultiDeviceFractal demo.
Diffstat (limited to 'src/com')
-rw-r--r--src/com/jogamp/opencl/demos/fractal/MultiDeviceFractal.java18
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) {
}