diff options
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/egl')
3 files changed, 65 insertions, 31 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java index 88685faf7..4120b0167 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawable.java @@ -166,7 +166,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { if (!EGL.eglInitialize(eglDisplay, null, null)) { throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError())); } - EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay, AbstractGraphicsDevice.DEFAULT_UNIT); + EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, aConfig.getScreen().getIndex()); // yes, use the already choosen/requested Capabilities (x11,win32,..) GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) aConfig.getChosenCapabilities(); diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java index 737aa5519..f451cb9bc 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLDrawableFactory.java @@ -95,17 +95,20 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { public EGLDrawableFactory() { super(); - defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); + defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } static class SharedResource { - private EGLDrawable drawable; - private EGLContext context; - - SharedResource(EGLDrawable draw, EGLContext ctx) { - drawable = draw; - context = ctx; + private EGLGraphicsDevice device; + //private EGLDrawable drawable; + //private EGLContext context; + + SharedResource(EGLGraphicsDevice dev /*, EGLDrawable draw, EGLContext ctx */) { + device = dev; + // drawable = draw; + // context = ctx; } + EGLGraphicsDevice getDevice() { return device; } } HashMap/*<connection, SharedResource>*/ sharedMap = new HashMap(); EGLGraphicsDevice defaultDevice; @@ -121,8 +124,45 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return false; } + private SharedResource getOrCreateShared(AbstractGraphicsDevice device) { + String connection = device.getConnection(); + SharedResource sr; + synchronized(sharedMap) { + sr = (SharedResource) sharedMap.get(connection); + } + if(null==sr) { + long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY); + if (eglDisplay == EGL.EGL_NO_DISPLAY) { + throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError())); + } else if(DEBUG) { + System.err.println("eglDisplay(EGL_DEFAULT_DISPLAY): 0x"+Long.toHexString(eglDisplay)); + } + if (!EGL.eglInitialize(eglDisplay, null, null)) { + throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError())); + } + EGLGraphicsDevice sharedDevice = new EGLGraphicsDevice(eglDisplay, connection, device.getUnitID()); + sr = new SharedResource(sharedDevice); + synchronized(sharedMap) { + sharedMap.put(connection, sr); + } + if (DEBUG) { + System.err.println("!!! SharedDevice: "+sharedDevice); + } + } + return sr; + } + + protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) { - // FIXME: not implemented .. needs a dummy EGL surface + // FIXME: not implemented .. needs a dummy EGL surface - NEEDED ? + return null; + } + + protected AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device) { + SharedResource sr = getOrCreateShared(device); + if(null!=sr) { + return sr.getDevice(); + } return null; } @@ -152,19 +192,24 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) { - throw new GLException("Not yet implemented"); + if (target == null) { + throw new IllegalArgumentException("Null target"); + } + AbstractGraphicsConfiguration config = target.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + if(!caps.isPBuffer()) { + throw new GLException("Not yet implemented"); + } + // PBuffer GLDrawable Creation + return new EGLPbufferDrawable(this, target); } public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) { return true; } - protected GLDrawableImpl createGLPbufferDrawableImpl(NativeSurface target) { - return new EGLPbufferDrawable(this, target); - } - - protected NativeSurface createOffscreenSurfaceImpl(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { - ProxySurface ns = new ProxySurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(capsChosen, capsRequested, chooser)); + protected NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { + ProxySurface ns = new ProxySurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(device, capsChosen, capsRequested, chooser)); ns.setSize(width, height); return ns; } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java index a9c8652b0..fc2416cb9 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/egl/EGLGraphicsConfigurationFactory.java @@ -291,7 +291,7 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor } } - static EGLGraphicsConfiguration createOffscreenGraphicsConfiguration(GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsReq, GLCapabilitiesChooser chooser) { + static EGLGraphicsConfiguration createOffscreenGraphicsConfiguration(AbstractGraphicsDevice device, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsReq, GLCapabilitiesChooser chooser) { if(capsChosen.isOnscreen()) { throw new GLException("Error: Onscreen set: "+capsChosen); } @@ -303,21 +303,10 @@ public class EGLGraphicsConfigurationFactory extends GraphicsConfigurationFactor capsChosen = caps2; } - long eglDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY); - if (eglDisplay == EGL.EGL_NO_DISPLAY) { - throw new GLException("Failed to created EGL default display: error 0x"+Integer.toHexString(EGL.eglGetError())); - } else if(DEBUG) { - System.err.println("eglDisplay(EGL_DEFAULT_DISPLAY): 0x"+Long.toHexString(eglDisplay)); - } - if (!EGL.eglInitialize(eglDisplay, null, null)) { - throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError())); - } - EGLGraphicsDevice e = new EGLGraphicsDevice(eglDisplay, AbstractGraphicsDevice.DEFAULT_UNIT); - DefaultGraphicsScreen s = new DefaultGraphicsScreen(e, 0); - EGLGraphicsConfiguration eglConfig = chooseGraphicsConfigurationStatic(capsChosen, capsReq, chooser, s); + DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + EGLGraphicsConfiguration eglConfig = chooseGraphicsConfigurationStatic(capsChosen, capsReq, chooser, screen); if (null == eglConfig) { - EGL.eglTerminate(eglDisplay); - throw new GLException("Couldn't create EGLGraphicsConfiguration from "+s); + throw new GLException("Couldn't create EGLGraphicsConfiguration from "+screen); } else if(DEBUG) { System.err.println("Chosen eglConfig: "+eglConfig); } |