@Override protected final ProxySurface createMutableSurfaceImpl( AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final X11GraphicsDevice device; if (createNewDevice || !(deviceReq instanceof X11GraphicsDevice)) { device = new X11GraphicsDevice( X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true /* owner */); } else { device = (X11GraphicsDevice) deviceReq; } 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); }
public static boolean XineramaIsEnabled(X11GraphicsDevice device) { if (null == device) { throw new IllegalArgumentException("X11 Display device is NULL"); } device.lock(); try { return XineramaIsEnabled(device.getHandle()); } finally { device.unlock(); } }
@Override public boolean isDeviceSupported(final AbstractGraphicsDevice device) { final boolean res; final X11GraphicsDevice x11Device = new X11GraphicsDevice( X11Util.openDisplay(device.getConnection()), device.getUnitID(), true /* owner */); x11Device.lock(); try { res = GLXUtil.isGLXAvailableOnServer(x11Device); } finally { x11Device.unlock(); x11Device.close(); } if (DEBUG) { System.err.println( "GLX " + (res ? "is" : "not") + " available on device/server: " + x11Device); } return res; }
@Override protected final ProxySurface createProxySurfaceImpl( AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { final X11GraphicsDevice device = new X11GraphicsDevice( X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true /* owner */); final X11GraphicsScreen screen = new X11GraphicsScreen(device, screenIdx); final int xvisualID = X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); if (VisualIDHolder.VID_UNDEFINED == xvisualID) { throw new GLException( "Undefined VisualID of window 0x" + Long.toHexString(windowHandle) + ", window probably invalid"); } if (DEBUG) { System.err.println( "X11GLXDrawableFactory.createProxySurfaceImpl 0x" + Long.toHexString(windowHandle) + ": visualID 0x" + Integer.toHexString(xvisualID)); } final X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( capsRequested, capsRequested, chooser, screen, xvisualID); if (DEBUG) { System.err.println( "X11GLXDrawableFactory.createProxySurfaceImpl 0x" + Long.toHexString(windowHandle) + ": " + cfg); } return new WrappedSurface(cfg, windowHandle, upstream, true); }
@Override public SharedResourceRunner.Resource createSharedResource(String connection) { final X11GraphicsDevice sharedDevice = new X11GraphicsDevice( X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); sharedDevice.lock(); try { final X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, sharedDevice.getDefaultScreen()); GLXUtil.initGLXClientDataSingleton(sharedDevice); final String glXServerVendorName = GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_VENDOR); final boolean glXServerMultisampleAvailable = GLXUtil.isMultisampleAvailable( GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_EXTENSIONS)); final GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: " + sharedDevice); } final GLCapabilitiesImmutable caps = new GLCapabilities(glp); final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl( createDummySurfaceImpl(sharedDevice, false, caps, caps, null, 64, 64)); sharedDrawable.setRealized(true); final X11GLCapabilities chosenCaps = (X11GLCapabilities) sharedDrawable.getChosenGLCapabilities(); final boolean glxForcedOneOne = !chosenCaps.hasFBConfig(); final VersionNumber glXServerVersion; if (glxForcedOneOne) { glXServerVersion = versionOneOne; } else { glXServerVersion = GLXUtil.getGLXServerVersionNumber(sharedDevice); } final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); if (null == sharedContext) { throw new GLException("Couldn't create shared context for drawable: " + sharedDrawable); } boolean madeCurrent = false; sharedContext.makeCurrent(); try { madeCurrent = sharedContext.isCurrent(); } finally { sharedContext.release(); } if (sharedContext.hasRendererQuirk(GLRendererQuirks.DontCloseX11Display)) { X11Util.markAllDisplaysUnclosable(); } if (DEBUG) { System.err.println("SharedDevice: " + sharedDevice); System.err.println("SharedScreen: " + sharedScreen); System.err.println("SharedContext: " + sharedContext + ", madeCurrent " + madeCurrent); System.err.println("GLX Server Vendor: " + glXServerVendorName); System.err.println( "GLX Server Version: " + glXServerVersion + ", forced " + glxForcedOneOne); System.err.println("GLX Server Multisample: " + glXServerMultisampleAvailable); System.err.println("GLX Client Vendor: " + GLXUtil.getClientVendorName()); System.err.println("GLX Client Version: " + GLXUtil.getClientVersionNumber()); System.err.println("GLX Client Multisample: " + GLXUtil.isClientMultisampleAvailable()); } return new SharedResource( sharedDevice, sharedScreen, sharedDrawable, sharedContext, glXServerVersion, glXServerVendorName, glXServerMultisampleAvailable && GLXUtil.isClientMultisampleAvailable()); } catch (Throwable t) { throw new GLException( "X11GLXDrawableFactory - Could not initialize shared resources for " + connection, t); } finally { sharedDevice.unlock(); } }
@Override public SharedResourceRunner.Resource createSharedResource( final AbstractGraphicsDevice adevice) { final X11GraphicsDevice device = new X11GraphicsDevice( X11Util.openDisplay(adevice.getConnection()), adevice.getUnitID(), true /* owner */); GLContextImpl context = null; boolean contextIsCurrent = false; device.lock(); try { final X11GraphicsScreen screen = new X11GraphicsScreen(device, device.getDefaultScreen()); GLXUtil.initGLXClientDataSingleton(device); final String glXServerVendorName = GLX.glXQueryServerString(device.getHandle(), 0, GLX.GLX_VENDOR); final boolean glXServerMultisampleAvailable = GLXUtil.isMultisampleAvailable( GLX.glXQueryServerString(device.getHandle(), 0, GLX.GLX_EXTENSIONS)); final GLProfile glp = GLProfile.get(device, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); if (null == glp) { 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)); drawable.setRealized(true); final X11GLCapabilities chosenCaps = (X11GLCapabilities) drawable.getChosenGLCapabilities(); final boolean glxForcedOneOne = !chosenCaps.hasFBConfig(); final VersionNumber glXServerVersion; if (glxForcedOneOne) { glXServerVersion = versionOneOne; } else { glXServerVersion = GLXUtil.getGLXServerVersionNumber(device); } context = (GLContextImpl) drawable.createContext(null); if (null == context) { throw new GLException("Couldn't create shared context for drawable: " + drawable); } contextIsCurrent = GLContext.CONTEXT_NOT_CURRENT != context.makeCurrent(); final boolean allowsSurfacelessCtx; if (contextIsCurrent && context.getGLVersionNumber().compareTo(GLContext.Version3_0) >= 0) { allowsSurfacelessCtx = probeSurfacelessCtx(context, true /* restoreDrawable */); } else { setNoSurfacelessCtxQuirk(context); allowsSurfacelessCtx = false; } if (context.hasRendererQuirk(GLRendererQuirks.DontCloseX11Display)) { X11Util.markAllDisplaysUnclosable(); } if (DEBUG_SHAREDCTX) { System.err.println("SharedDevice: " + device); System.err.println("SharedScreen: " + screen); System.err.println("SharedContext: " + context + ", madeCurrent " + contextIsCurrent); System.err.println(" allowsSurfacelessCtx " + allowsSurfacelessCtx); System.err.println("GLX Server Vendor: " + glXServerVendorName); System.err.println( "GLX Server Version: " + glXServerVersion + ", forced " + glxForcedOneOne); System.err.println("GLX Server Multisample: " + glXServerMultisampleAvailable); System.err.println("GLX Client Vendor: " + GLXUtil.getClientVendorName()); System.err.println("GLX Client Version: " + GLXUtil.getClientVersionNumber()); System.err.println("GLX Client Multisample: " + GLXUtil.isClientMultisampleAvailable()); } return new SharedResource( device, screen, drawable, context, glXServerVersion, glXServerVendorName, glXServerMultisampleAvailable && GLXUtil.isClientMultisampleAvailable()); } catch (final Throwable t) { throw new GLException( "X11GLXDrawableFactory - Could not initialize shared resources for " + adevice, t); } finally { if (contextIsCurrent) { context.release(); } device.unlock(); } }