diff options
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
7 files changed, 91 insertions, 69 deletions
diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index fad77d76d..9293cad7e 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -119,7 +119,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { GLDrawable zeroDrawable = null; try { final GLCapabilitiesImmutable caps = origDrawable.getRequestedGLCapabilities(); - final ProxySurface zeroSurface = createSurfacelessImpl(device, true, caps, caps, null, 64, 64); + final ProxySurface zeroSurface = createSurfacelessImpl(device, device, true, caps, caps, null, 64, 64); zeroDrawable = createOnscreenDrawableImpl(zeroSurface); zeroDrawable.setRealized(true); @@ -381,7 +381,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } if( chosenCaps.isFBO() && isFBOAvailable ) { // need to hook-up a native dummy surface since source may not have & use minimum GLCapabilities for it w/ same profile - final ProxySurface dummySurface = createDummySurfaceImpl(adevice, false, new GLCapabilities(chosenCaps.getGLProfile()), (GLCapabilitiesImmutable)config.getRequestedCapabilities(), null, 64, 64); + final ProxySurface dummySurface = createDummySurfaceImpl(adevice, adevice, false, new GLCapabilities(chosenCaps.getGLProfile()), (GLCapabilitiesImmutable)config.getRequestedCapabilities(), null, 64, 64); dummySurface.setUpstreamSurfaceHook(new DelegatedUpstreamSurfaceHookWithSurfaceSize(dummySurface.getUpstreamSurfaceHook(), target)); result = createFBODrawableImpl(dummySurface, chosenCaps, 0); } else { @@ -483,9 +483,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final GLRendererQuirks glrq = sr.getRendererQuirks(glp); final ProxySurface surface; if( null != glrq && !glrq.exist(GLRendererQuirks.NoSurfacelessCtx) ) { - surface = createSurfacelessImpl(device, true, glCapsMin, capsRequested, null, width, height); + surface = createSurfacelessImpl(deviceReq, device, true, glCapsMin, capsRequested, null, width, height); } else { - surface = createDummySurfaceImpl(device, true, glCapsMin, capsRequested, null, width, height); + surface = createDummySurfaceImpl(deviceReq, device, true, glCapsMin, capsRequested, null, width, height); } final GLDrawableImpl drawable = createOnscreenDrawableImpl(surface); return new GLFBODrawableImpl.ResizeableImpl(this, drawable, surface, capsChosen, 0); @@ -550,19 +550,22 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { @Override public final GLDrawable createDummyDrawable(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser) { - final AbstractGraphicsDevice device = createNewDevice ? getOrCreateSharedDevice(deviceReq) : deviceReq; - if(null == device) { - throw new GLException("No shared device for requested: "+deviceReq+", createNewDevice "+createNewDevice); - } - if( !createNewDevice ) { - device.lock(); + final AbstractGraphicsDevice device; + if( createNewDevice ) { + device = getOrCreateSharedDevice(deviceReq); + if(null == device) { + throw new GLException("No shared device for requested: "+deviceReq+", createNewDevice "+createNewDevice); + } + } else { + device = deviceReq; + deviceReq.lock(); } try { - final ProxySurface dummySurface = createDummySurfaceImpl(device, createNewDevice, capsRequested, capsRequested, chooser, 64, 64); + final ProxySurface dummySurface = createDummySurfaceImpl(deviceReq, device, createNewDevice, capsRequested, capsRequested, chooser, 64, 64); return createOnscreenDrawableImpl(dummySurface); } finally { if( !createNewDevice ) { - device.unlock(); + deviceReq.unlock(); } } } @@ -629,7 +632,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - return createDummySurfaceImpl(device, true, requestedCaps, requestedCaps, chooser, width, height); + return createDummySurfaceImpl(deviceReq, device, true, requestedCaps, requestedCaps, chooser, width, height); } /** @@ -638,9 +641,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * It is used to allow the creation of a {@link GLDrawable} and {@link GLContext} to query information. * It also allows creation of framebuffer objects which are used for rendering or using a shared GLContext w/o actually rendering to a usable framebuffer. * </p> - * @param device a valid platform dependent target device. - * @param createNewDevice if <code>true</code> a new device instance is created using <code>device</code> details, - * otherwise <code>device</code> instance is used as-is. + * @param deviceOrig originally requested device, a valid platform dependent target device or {@code null} denoting default device. + * @param device compatible or same device as {@code reqDevice}. If {@code reqDevice} is {@code null}, the default device is referenced. + * @param createNewDevice if {@code true}, a new device instance is created using {@code device} or {@code deviceOrig} details, + * otherwise {@code device} instance shall be used as-is. * @param chosenCaps * @param requestedCaps * @param chooser the custom chooser, may be null for default @@ -650,8 +654,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * The latter is platform specific and small * @return the created {@link ProxySurface} instance w/o defined surface handle but platform specific {@link UpstreamSurfaceHook}. */ - public abstract ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); + public abstract ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceOrig, AbstractGraphicsDevice device, + boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); /** * A surfaceless {@link ProxySurface} is a non-existing surface and will not be used as a render target. @@ -659,9 +663,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * It is used to allow the creation of a {@link GLDrawable} and {@link GLContext} w/o default framebuffer to query information. * It also allows creation of framebuffer objects which are used for rendering or using a shared GLContext w/o actually rendering to a usable framebuffer. * </p> + * @param deviceOrig originally requested device, a valid platform dependent target device or {@code null} denoting default device. * @param device a valid platform dependent target device. - * @param createNewDevice if <code>true</code> a new device instance is created using <code>device</code> details, - * otherwise <code>device</code> instance is used as-is. + * @param createNewDevice if {@code true}, a new device instance is created using {@code device} or {@code deviceOrig} details, + * otherwise {@code device} instance shall be used as-is. * @param chosenCaps * @param requestedCaps * @param chooser the custom chooser, may be null for default @@ -671,8 +676,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * The latter is platform specific and small * @return the created {@link ProxySurface} instance w/o defined surface handle but platform specific {@link UpstreamSurfaceHook}. */ - public abstract ProxySurface createSurfacelessImpl(AbstractGraphicsDevice device, boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); + public abstract ProxySurface createSurfacelessImpl(AbstractGraphicsDevice deviceOrig, AbstractGraphicsDevice device, + boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); //--------------------------------------------------------------------------- // diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index afe6a3e5a..c69013c92 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -1,6 +1,6 @@ /* + * Copyright (c) 2010-2023 JogAmp Community. All rights reserved. * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -744,7 +744,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { // Includes mapping DRM_GBM EGL device to EGL default shared resources (default behavior), surfaceless. hasKHRSurfacelessTried = true; final AbstractGraphicsDevice zdevice = useDefaultDevice ? defaultDevice : adevice; // reuse - final EGLSurface zeroSurface = createSurfacelessImpl(zdevice, false, reqCapsAny, reqCapsAny, null, 64, 64); + final EGLSurface zeroSurface = createSurfacelessImpl(adevice, zdevice, false, reqCapsAny, reqCapsAny, null, 64, 64); resEGLDevice[0] = (EGLGraphicsDevice) zeroSurface.getGraphicsConfiguration().getScreen().getDevice(); if ( DEBUG_SHAREDCTX ) { System.err.println("EGLDrawableFactory.MapGLVersions.0: "+resEGLDevice[0]); @@ -826,7 +826,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { System.err.println("EGLDrawableFactory.MapGLVersions.1: "+resEGLDevice[0]); System.err.println("EGLDrawableFactory.MapGLVersions.1: "+eglFeatures); } - downstreamSurface = createDummySurfaceImpl(resEGLDevice[0], false, reqCapsAny, reqCapsAny, null, 64, 64); + downstreamSurface = createDummySurfaceImpl(resEGLDevice[0], resEGLDevice[0], false, reqCapsAny, reqCapsAny, null, 64, 64); if( null != downstreamSurface ) { downstreamSurface.createNotify(); surface = downstreamSurface; @@ -840,7 +840,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { System.err.println("EGLDrawableFactory.MapGLVersions.2: "+eglFeatures); } - downstreamSurface = createDummySurfaceImpl(resEGLDevice[0], false, reqCapsPBuffer, reqCapsPBuffer, null, 64, 64); + downstreamSurface = createDummySurfaceImpl(resEGLDevice[0], resEGLDevice[0], false, reqCapsPBuffer, reqCapsPBuffer, null, 64, 64); if( null != downstreamSurface ) { downstreamSurface.createNotify(); surface = downstreamSurface; @@ -1137,8 +1137,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - public final EGLSurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + public final EGLSurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceOrig, final AbstractGraphicsDevice device, + final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + final AbstractGraphicsDevice device0 = null != deviceOrig ? deviceOrig : device; // prefer orig for native display ID final UpstreamSurfaceHook ush; final int nativeVisualID; if( isDRM_GBM ) { @@ -1149,15 +1150,16 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { chosenCaps = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(chosenCaps); // complete validation in EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(..) above nativeVisualID = VisualIDHolder.VID_UNDEFINED; } - return createMutableSurfaceImpl2(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, nativeVisualID, ush); + return createMutableSurfaceImpl2(device0, createNewDevice, chosenCaps, requestedCaps, chooser, nativeVisualID, ush); } @Override - public final EGLSurface createSurfacelessImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + public final EGLSurface createSurfacelessImpl(final AbstractGraphicsDevice deviceOrig, final AbstractGraphicsDevice device, + final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + final AbstractGraphicsDevice device0 = null != deviceOrig ? deviceOrig : device; // prefer orig for native display ID chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); final boolean[] ownDevice = { false }; - final EGLGraphicsConfiguration config = evalConfig(ownDevice, deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, VisualIDHolder.VID_UNDEFINED); + final EGLGraphicsConfiguration config = evalConfig(ownDevice, device0, createNewDevice, chosenCaps, requestedCaps, chooser, VisualIDHolder.VID_UNDEFINED); return EGLSurface.createSurfaceless(config, new GenericUpstreamSurfacelessHook(width, height), ownDevice[0]); } diff --git a/src/jogl/classes/jogamp/opengl/ios/eagl/IOSEAGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/ios/eagl/IOSEAGLDrawableFactory.java index 71904d1a6..329b76783 100644 --- a/src/jogl/classes/jogamp/opengl/ios/eagl/IOSEAGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/ios/eagl/IOSEAGLDrawableFactory.java @@ -402,32 +402,35 @@ public class IOSEAGLDrawableFactory extends GLDrawableFactoryImpl { final GLCapabilitiesImmutable capsChosen, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser, final UpstreamSurfaceHook upstreamHook) { final IOSGraphicsDevice device; + final boolean owning; if( createNewDevice || !(deviceReq instanceof IOSGraphicsDevice) ) { device = new IOSGraphicsDevice(deviceReq.getUnitID()); + owning = true; } else { device = (IOSGraphicsDevice)deviceReq; + owning = false; } final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); final IOSEAGLGraphicsConfiguration config = IOSEAGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, true); if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface(config, 0, upstreamHook, createNewDevice); + return new WrappedSurface(config, 0, upstreamHook, owning); } @Override - public final ProxySurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + public final ProxySurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceOrig, final AbstractGraphicsDevice device, + final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, + return createMutableSurfaceImpl(device, createNewDevice, chosenCaps, requestedCaps, chooser, new IOSDummyUpstreamSurfaceHook(width, height)); } @Override - public final ProxySurface createSurfacelessImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + public final ProxySurface createSurfacelessImpl(AbstractGraphicsDevice deviceOrig, final AbstractGraphicsDevice device, + final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new GenericUpstreamSurfacelessHook(width, height)); + return createMutableSurfaceImpl(device, createNewDevice, chosenCaps, requestedCaps, chooser, new GenericUpstreamSurfacelessHook(width, height)); } @Override diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 97c595955..2b5ac4d95 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -259,7 +259,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { throw new GLException("Couldn't get default GLProfile for device: "+device); } final GLCapabilitiesImmutable caps = new GLCapabilities(glp); - drawable = createOnscreenDrawableImpl(createDummySurfaceImpl(device, false, caps, caps, null, 64, 64)); + drawable = createOnscreenDrawableImpl(createDummySurfaceImpl(device, device, false, caps, caps, null, 64, 64)); drawable.setRealized(true); context = (MacOSXCGLContext) drawable.createContext(null); @@ -408,32 +408,35 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { final GLCapabilitiesImmutable capsChosen, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser, final UpstreamSurfaceHook upstreamHook) { final MacOSXGraphicsDevice device; + final boolean owning; if( createNewDevice || !(deviceReq instanceof MacOSXGraphicsDevice) ) { device = new MacOSXGraphicsDevice(deviceReq.getUnitID()); + owning = true; } else { device = (MacOSXGraphicsDevice)deviceReq; + owning = false; } final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); final MacOSXCGLGraphicsConfiguration config = MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, true); if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface(config, 0, upstreamHook, createNewDevice); + return new WrappedSurface(config, 0, upstreamHook, owning); } @Override - public final ProxySurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + public final ProxySurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceOrig, final AbstractGraphicsDevice device, + final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, + return createMutableSurfaceImpl(device, createNewDevice, chosenCaps, requestedCaps, chooser, new OSXDummyUpstreamSurfaceHook(width, height)); } @Override - public final ProxySurface createSurfacelessImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + public final ProxySurface createSurfacelessImpl(AbstractGraphicsDevice deviceOrig, final AbstractGraphicsDevice device, + final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new GenericUpstreamSurfacelessHook(width, height)); + return createMutableSurfaceImpl(device, createNewDevice, chosenCaps, requestedCaps, chooser, new GenericUpstreamSurfacelessHook(width, height)); } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 2a1e149d0..01e04f6de 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -1,5 +1,5 @@ /** - * Copyright 2012 JogAmp Community. All rights reserved. + * Copyright 2012-2023 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index d65027f0d..16d6a8532 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -316,7 +316,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { throw new GLException("Couldn't get default GLProfile for device: "+device); } final GLCapabilitiesImmutable caps = new GLCapabilities(glp); - final GLDrawableImpl drawable = createOnscreenDrawableImpl(createDummySurfaceImpl(device, false, caps, caps, null, 64, 64)); + final GLDrawableImpl drawable = createOnscreenDrawableImpl(createDummySurfaceImpl(device, device, false, caps, caps, null, 64, 64)); drawable.setRealized(true); context = (GLContextImpl) drawable.createContext(null); @@ -549,42 +549,48 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { final GLCapabilitiesImmutable capsChosen, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser, final UpstreamSurfaceHook upstreamHook) { final WindowsGraphicsDevice device; + final boolean owning; if(createNewDevice || !(deviceReq instanceof WindowsGraphicsDevice)) { device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); + owning = true; } else { device = (WindowsGraphicsDevice)deviceReq; + owning = false; } final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); final WindowsWGLGraphicsConfiguration config = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen); if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface(config, 0, upstreamHook, createNewDevice); + return new WrappedSurface(config, 0, upstreamHook, owning); } @Override - public final ProxySurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { - final WindowsGraphicsDevice device; - if( createNewDevice || !(deviceReq instanceof WindowsGraphicsDevice) ) { - device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); + public final ProxySurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceOrig, final AbstractGraphicsDevice device, + final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + final WindowsGraphicsDevice device0; + final boolean owning; + if( createNewDevice || !(device instanceof WindowsGraphicsDevice) ) { + device0 = new WindowsGraphicsDevice(device.getConnection(), device.getUnitID()); + owning = true; } else { - device = (WindowsGraphicsDevice)deviceReq; + device0 = (WindowsGraphicsDevice)device; + owning = false; } - final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device0, 0); chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); final WindowsWGLGraphicsConfiguration config = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(chosenCaps, requestedCaps, chooser, screen); if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+chosenCaps+" on "+screen); } - return new GDISurface(config, 0, new GDIDummyUpstreamSurfaceHook(width, height), createNewDevice); + return new GDISurface(config, 0, new GDIDummyUpstreamSurfaceHook(width, height), owning); } @Override - public final ProxySurface createSurfacelessImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + public final ProxySurface createSurfacelessImpl(final AbstractGraphicsDevice deviceOrig, final AbstractGraphicsDevice device, + final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new GenericUpstreamSurfacelessHook(width, height)); + return createMutableSurfaceImpl(device, createNewDevice, chosenCaps, requestedCaps, chooser, new GenericUpstreamSurfacelessHook(width, height)); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 85482679b..3177915dd 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -260,7 +260,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } final GLCapabilitiesImmutable caps = new GLCapabilities(glp); - final GLDrawableImpl drawable = createOnscreenDrawableImpl(createDummySurfaceImpl(device, false, caps, caps, null, 64, 64)); + final GLDrawableImpl drawable = createOnscreenDrawableImpl(createDummySurfaceImpl(device, device, false, caps, caps, null, 64, 64)); drawable.setRealized(true); final X11GLCapabilities chosenCaps = (X11GLCapabilities) drawable.getChosenGLCapabilities(); final boolean glxForcedOneOne = !chosenCaps.hasFBConfig(); @@ -522,31 +522,34 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser, final UpstreamSurfaceHook upstreamHook) { final X11GraphicsDevice device; + final boolean owning; if( createNewDevice || !(deviceReq instanceof X11GraphicsDevice) ) { device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true /* owner */); + owning = true; } else { device = (X11GraphicsDevice) deviceReq; + owning = false; } final X11GraphicsScreen screen = new X11GraphicsScreen(device, device.getDefaultScreen()); final X11GLXGraphicsConfiguration config = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED); if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface(config, 0, upstreamHook, createNewDevice); + return new WrappedSurface(config, 0, upstreamHook, owning); } @Override - public final ProxySurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + public final ProxySurface createDummySurfaceImpl(final AbstractGraphicsDevice deviceOrig, final AbstractGraphicsDevice device, + final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new X11DummyUpstreamSurfaceHook(width, height)); + return createMutableSurfaceImpl(device, createNewDevice, chosenCaps, requestedCaps, chooser, new X11DummyUpstreamSurfaceHook(width, height)); } @Override - public final ProxySurface createSurfacelessImpl(final AbstractGraphicsDevice deviceReq, final boolean createNewDevice, - GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { + public final ProxySurface createSurfacelessImpl(AbstractGraphicsDevice deviceOrig, final AbstractGraphicsDevice device, + final boolean createNewDevice, GLCapabilitiesImmutable chosenCaps, final GLCapabilitiesImmutable requestedCaps, final GLCapabilitiesChooser chooser, final int width, final int height) { chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new GenericUpstreamSurfacelessHook(width, height)); + return createMutableSurfaceImpl(device, createNewDevice, chosenCaps, requestedCaps, chooser, new GenericUpstreamSurfacelessHook(width, height)); } @Override |