diff options
author | Sven Gothel <[email protected]> | 2015-09-02 04:25:43 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-09-02 04:25:43 +0200 |
commit | 8a3b6e38269d54a73a766f79df8d7f037eae823b (patch) | |
tree | 40e12358a74e03ba7fea6845210b6c44826625b9 /src/nativewindow | |
parent | d3db8fc5f03f280cef0d485b93dc8de5a2db9399 (diff) |
NativeWindowFactory.createDevice(..): Support creating EGLGraphicsDevice using reflection for 'jogamp.opengl.egl.EGLDisplayUtil'
Diffstat (limited to 'src/nativewindow')
-rw-r--r-- | src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java index 811e3767b..d2db09adf 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowFactory.java @@ -62,6 +62,7 @@ import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.UpstreamWindowHookMutableSizePos; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsDevice; @@ -689,7 +690,28 @@ public abstract class NativeWindowFactory { } else if( NativeWindowFactory.TYPE_MACOSX == nwt ) { return new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } else if( NativeWindowFactory.TYPE_EGL == nwt ) { - throw new UnsupportedOperationException("n/a for windowing system: "+nwt); + final EGLGraphicsDevice device; + if( own ) { + Object odev = null; + try { + // EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + odev = ReflectionUtil.callStaticMethod("jogamp.opengl.egl.EGLDisplayUtil", "eglCreateEGLGraphicsDevice", + new Class<?>[] { Long.class, String.class, Integer.class}, + new Object[] { 0L /* EGL.EGL_DEFAULT_DISPLAY */, DefaultGraphicsDevice.getDefaultDisplayConnection(nwt), AbstractGraphicsDevice.DEFAULT_UNIT }, + NativeWindowFactory.class.getClassLoader()); + } catch (final Exception e) { + throw new NativeWindowException("EGLDisplayUtil.eglCreateEGLGraphicsDevice failed", e); + } + if( odev instanceof EGLGraphicsDevice ) { + device = (EGLGraphicsDevice)odev; + device.open(); + } else { + throw new NativeWindowException("EGLDisplayUtil.eglCreateEGLGraphicsDevice failed"); + } + } else { + device = new EGLGraphicsDevice(0, 0 /* EGL.EGL_NO_DISPLAY */, displayConnection, AbstractGraphicsDevice.DEFAULT_UNIT, null); + } + return device; } else if( NativeWindowFactory.TYPE_AWT == nwt ) { throw new UnsupportedOperationException("n/a for windowing system: "+nwt); } else { @@ -743,6 +765,4 @@ public abstract class NativeWindowFactory { } throw new UnsupportedOperationException("n/a for windowing system: "+nwt); } - - } |