public AbstractGraphicsConfiguration chooseGraphicsConfiguration( Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { GraphicsDevice device = null; if (absScreen != null && !(absScreen instanceof AWTGraphicsScreen)) { throw new IllegalArgumentException( "This GraphicsConfigurationFactory accepts only AWTGraphicsScreen objects"); } if (null == absScreen) { absScreen = AWTGraphicsScreen.createScreenDevice(-1); } AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen; device = ((AWTGraphicsDevice) awtScreen.getDevice()).getGraphicsDevice(); if (capabilities != null && !(capabilities instanceof GLCapabilities)) { throw new IllegalArgumentException( "This GraphicsConfigurationFactory accepts only GLCapabilities objects"); } if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) { throw new IllegalArgumentException( "This GraphicsConfigurationFactory accepts only GLCapabilitiesChooser objects"); } if (DEBUG) { System.err.println("MacOSXAWTCGLGraphicsConfigurationFactory: got " + absScreen); } long displayHandle = 0; MacOSXGraphicsDevice macDevice = new MacOSXGraphicsDevice(); DefaultGraphicsScreen macScreen = new DefaultGraphicsScreen(macDevice, awtScreen.getIndex()); if (DEBUG) { System.err.println("MacOSXAWTCGLGraphicsConfigurationFactory: made " + macScreen); } GraphicsConfiguration gc = device.getDefaultConfiguration(); AWTGraphicsConfiguration.setupCapabilitiesRGBABits(capabilities, gc); if (DEBUG) { System.err.println("AWT Colormodel compatible: " + capabilities); } MacOSXCGLGraphicsConfiguration macConfig = (MacOSXCGLGraphicsConfiguration) GraphicsConfigurationFactory.getFactory(macDevice) .chooseGraphicsConfiguration(capabilities, chooser, macScreen); if (macConfig == null) { throw new GLException( "Unable to choose a GraphicsConfiguration: " + capabilities + ",\n\t" + chooser + "\n\t" + macScreen); } // FIXME: we have nothing to match .. so choose the default return new AWTGraphicsConfiguration( awtScreen, macConfig.getChosenCapabilities(), macConfig.getRequestedCapabilities(), gc, macConfig); }
public MacOSXAWTCGLGraphicsConfigurationFactory() { GraphicsConfigurationFactory.registerFactory( javax.media.nativewindow.awt.AWTGraphicsDevice.class, this); }