summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/com/jogamp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-07-09 17:07:02 +0200
committerSven Gothel <[email protected]>2012-07-09 17:07:02 +0200
commit72a84b422327c6abb688339419d3552ec0e5c70c (patch)
treecb974b98f73bf930870c40f72d73ccec7ab995fe /src/nativewindow/classes/com/jogamp
parent4e70a4811a860255b53eeae7a841ca473e1aba86 (diff)
EGLGraphicsDevice adds desctruction callback and nativeDisplayID; EGLDisplayUtil adds creation of EGLGraphicsDevice.
Due to EGL's location in JOGL, supporting destruction of an EGLGraphicsDevice is solved (hack) temporary by passing an eglTerminate callback to it's ctor. Using EGLGraphicsDevice's close() method to also issue eglTerminate() simplifies the code. In future we shall move EGL to nativewindow!
Diffstat (limited to 'src/nativewindow/classes/com/jogamp')
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java43
-rw-r--r--src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java1
2 files changed, 39 insertions, 5 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java
index 4ee336176..d161f2f34 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java
@@ -36,25 +36,60 @@ import javax.media.nativewindow.*;
/** Encapsulates a graphics device on EGL platforms.
*/
-
public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
- boolean closeDisplay = false;
+ final long nativeDisplayID;
+ final EGLTerminateCallback eglTerminateCallback;
/**
+ * Hack to allow inject a EGL termination call.
+ * <p>
+ * FIXME: This shall be removed when relocated EGL to the nativewindow package,
+ * since then it can be utilized directly.
+ * </p>
+ */
+ public interface EGLTerminateCallback {
+ /**
+ * Implementation should issue an <code>EGL.eglTerminate(eglDisplayHandle)</code> call.
+ * @param eglDisplayHandle
+ */
+ void eglTerminate(long eglDisplayHandle);
+ }
+
+ /**
* Note that this is not an open connection, ie no native display handle exist.
* This constructor exist to setup a default device connection/unit.<br>
*/
public EGLGraphicsDevice(String connection, int unitID) {
super(NativeWindowFactory.TYPE_EGL, connection, unitID);
+ this.nativeDisplayID = 0;
+ this.eglTerminateCallback = null;
}
- /** Constructs a new EGLGraphicsDevice corresponding to the given EGL display handle. */
- public EGLGraphicsDevice(long eglDisplay, String connection, int unitID) {
+ public EGLGraphicsDevice(long nativeDisplayID, long eglDisplay, String connection, int unitID, EGLTerminateCallback eglTerminateCallback) {
super(NativeWindowFactory.TYPE_EGL, connection, unitID, eglDisplay);
+ this.nativeDisplayID = nativeDisplayID;
+ this.eglTerminateCallback = eglTerminateCallback;
}
+ public long getNativeDisplayID() { return nativeDisplayID; }
+
public Object clone() {
return super.clone();
}
+
+ public boolean close() {
+ if(null != eglTerminateCallback) {
+ if(DEBUG) {
+ System.err.println(Thread.currentThread().getName() + " - eglTerminate: "+this);
+ }
+ eglTerminateCallback.eglTerminate(handle);
+ }
+ return super.close();
+ }
+
+ @Override
+ public String toString() {
+ return "EGLGraphicsDevice[type EGL, connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", nativeDisplayID 0x"+Long.toHexString(nativeDisplayID)+"]";
+ }
}
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java
index 308756b54..a02332413 100644
--- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java
+++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java
@@ -46,7 +46,6 @@ import javax.media.nativewindow.ToolkitLock;
*/
public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneable {
- public static final boolean DEBUG = Debug.debug("GraphicsDevice");
final boolean closeDisplay;
/** Constructs a new X11GraphicsDevice corresponding to the given connection and default