/** * @param device * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen * @return */ public static AbstractGraphicsScreen getScreen(final AbstractGraphicsDevice device, final int screen) { return NativeWindowFactory.createScreen(device, screen); }
/** Constructs a new X11GraphicsDevice corresponding to the given native display handle and default * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}. * @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long) */ public X11GraphicsDevice(final long display, final int unitID, final boolean owner) { this(display, unitID, NativeWindowFactory.getDefaultToolkitLock(NativeWindowFactory.TYPE_X11, display), owner); }
/** Converts the given window object and it's {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration} into a {@link NativeWindow NativeWindow} which can be operated upon by a custom toolkit, e.g. {@link javax.media.opengl.GLDrawableFactory javax.media.opengl.GLDrawableFactory}.<br> The object may be a component for a particular window toolkit, such as an AWT Canvas. It may also be a NativeWindow object itself.<br> You shall utilize {@link javax.media.nativewindow.GraphicsConfigurationFactory GraphicsConfigurationFactory} to construct a proper {@link AbstractGraphicsConfiguration AbstractGraphicsConfiguration}.<br> The particular implementation of the NativeWindowFactory is responsible for handling objects from a particular window toolkit. The built-in NativeWindowFactory handles NativeWindow instances as well as AWT Components.<br> @throws IllegalArgumentException if the given window object could not be handled by any of the registered NativeWindowFactory instances @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen) */ public static NativeWindow getNativeWindow(final Object winObj, final AbstractGraphicsConfiguration config) throws IllegalArgumentException, NativeWindowException { if (winObj == null) { throw new IllegalArgumentException("Null window object"); } return getFactory(winObj.getClass()).getNativeWindowImpl(winObj, config); }
final AbstractGraphicsDevice aDevice = NativeWindowFactory.createDevice(upstreamWin.getDisplayConnection(), true /* own */); // open and own! (for upstreamLocOnScreen) final AbstractGraphicsScreen aScreen = NativeWindowFactory.createScreen(aDevice, upstreamWin.getScreenIndex()); upstreamSizePosHook = new UpstreamWindowHookMutableSizePos(upstreamWin.getX(), upstreamWin.getY(), upstreamWin.getWidth(), upstreamWin.getHeight(), browserWin = NativeWindowFactory.createWrappedWindow(aScreen, 0 /* surfaceHandle */, upstreamWin.getWindowHandle(), upstreamSizePosHook); upstreamLocOnScreen = NativeWindowFactory.getLocationOnScreen(browserWin); if(DEBUG) { System.err.println("JOGLNewtApplet3Run Configuration:");
private static final void initSingletonImpl() { NativeWindowFactory.initSingleton(); NativeWindowFactory.addCustomShutdownHook(false /* head */, new Runnable() { @Override public void run() { final String nwt = NativeWindowFactory.getNativeWindowType(true); GLDrawableFactory tmp = null; String factoryClassName = PropertyAccess.getProperty("jogl.gldrawablefactory.class.name", true);
/** * Provides the default {@link ToolkitLock} for <code>type</code>. * <ul> * <li> JAWT {@link ToolkitLock} if required and <code>type</code> is of {@link #TYPE_AWT} and AWT available,</li> * <li> {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise</li> * <li> {@link jogamp.nativewindow.NullToolkitLock} </li> * </ul> */ public static ToolkitLock getDefaultToolkitLock(final String type) { if( requiresToolkitLock ) { if( TYPE_AWT == type && isAWTAvailable() ) { // uses .intern()! return getAWTToolkitLock(); } return ResourceToolkitLock.create(); } return NativeWindowFactoryImpl.getNullToolkitLock(); }
public static JAWTWindow getNativeWindow(final java.awt.Component awtComp, final CapabilitiesImmutable capsRequested) { final AWTGraphicsConfiguration config = AWTGraphicsConfiguration.create(awtComp, null, capsRequested); final NativeWindow nw = NativeWindowFactory.getNativeWindow(awtComp, config); // a JAWTWindow if(! ( nw instanceof JAWTWindow ) ) { throw new NativeWindowException("Not an AWT NativeWindow: "+nw); } if(DEBUG_IMPLEMENTATION) { System.err.println("NewtFactoryAWT.getNativeWindow: "+awtComp+" -> "+nw); } return (JAWTWindow)nw; }
public static synchronized void unlockToolkit() { if (lockedToolkit) { lockedToolkit = false; if (headlessMode) { // Workaround for running (to some degree) in headless // environments but still supporting rendering via pbuffers // For full correctness, would need to implement a Lock class return; } if(j2dOk) { try { if( !((Boolean)isOGLPipelineActive.invoke(null, (Object[])null)).booleanValue() || !((Boolean)isQueueFlusherThread.invoke(null, (Object[])null)).booleanValue() ) { NativeWindowFactory.getAWTToolkitLock().unlock(); } } catch (final Exception e) { j2dOk=false; } } if(!j2dOk) { NativeWindowFactory.getAWTToolkitLock().unlock(); } } } }
/** * Provides the default {@link ToolkitLock} for <code>type</code> and <code>deviceHandle</code>. * <ul> * <li> JAWT {@link ToolkitLock} if required and <code>type</code> is of {@link #TYPE_AWT} and AWT available,</li> * <li> {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise</li> * <li> {@link jogamp.nativewindow.NullToolkitLock} </li> * </ul> */ public static ToolkitLock getDefaultToolkitLock(final String type, final long deviceHandle) { if( requiresToolkitLock ) { if( TYPE_AWT == type && isAWTAvailable() ) { // uses .intern()! return getAWTToolkitLock(); } return ResourceToolkitLock.create(); } return NativeWindowFactoryImpl.getNullToolkitLock(); }
private void createJAWTDrawableAndContext() { if ( !Beans.isDesignTime() ) { jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); jawtWindow.setSurfaceScale(reqPixelScale); jawtWindow.lockSurface(); try { drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); createContextImpl(drawable); jawtWindow.getCurrentSurfaceScale(hasPixelScale); jawtWindow.getNativeSurfaceScale(nativePixelScale); } finally { jawtWindow.unlockSurface(); } } } private boolean createContextImpl(final GLDrawable drawable) {
public static synchronized void lockToolkit() throws GLException { if (lockedToolkit) { throw new GLException("Toolkit already locked"); } lockedToolkit = true; if (headlessMode) { // Workaround for running (to some degree) in headless // environments but still supporting rendering via pbuffers // For full correctness, would need to implement a Lock class return; } if(j2dOk) { try { if( !((Boolean)isOGLPipelineActive.invoke(null, (Object[])null)).booleanValue() || !((Boolean)isQueueFlusherThread.invoke(null, (Object[])null)).booleanValue() ) { NativeWindowFactory.getAWTToolkitLock().lock(); } } catch (final Exception e) { j2dOk=false; } } if(!j2dOk) { NativeWindowFactory.getAWTToolkitLock().lock(); } }
/** * Create an instance with the system default {@link ToolkitLock}, * gathered via {@link NativeWindowFactory#getDefaultToolkitLock(String)}. * @param type */ public DefaultGraphicsDevice(final String type, final String connection, final int unitID) { this(type, connection, unitID, 0, NativeWindowFactory.getDefaultToolkitLock(type)); }
jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig);
/** * Create an instance with the system default {@link ToolkitLock}. * gathered via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}. * @param type * @param handle */ public DefaultGraphicsDevice(final String type, final String connection, final int unitID, final long handle) { this(type, connection, unitID, handle, NativeWindowFactory.getDefaultToolkitLock(type, handle)); }
/** * Provides the system default {@link ToolkitLock} for the default system windowing type. * @see #getNativeWindowType(boolean) * @see #getDefaultToolkitLock(java.lang.String) */ public static ToolkitLock getDefaultToolkitLock() { return getDefaultToolkitLock(nativeWindowingTypePure); }
final ToolkitLock lock = NativeWindowFactory.getDefaultToolkitLock(NativeWindowFactory.TYPE_AWT); final X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, lock, owner); final X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex());