protected static X11GLXGraphicsConfiguration chooseGraphicsConfigurationStatic( Capabilities capabilities, CapabilitiesChooser chooser, AbstractGraphicsScreen absScreen) { if (absScreen == null) { throw new IllegalArgumentException("AbstractGraphicsScreen is null"); } if (!(absScreen instanceof X11GraphicsScreen)) { throw new IllegalArgumentException("Only X11GraphicsScreen are allowed here"); } X11GraphicsScreen x11Screen = (X11GraphicsScreen) absScreen; if (capabilities != null && !(capabilities instanceof GLCapabilities)) { throw new IllegalArgumentException( "This NativeWindowFactory accepts only GLCapabilities objects"); } if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) { throw new IllegalArgumentException( "This NativeWindowFactory accepts only GLCapabilitiesChooser objects"); } if (capabilities == null) { capabilities = new GLCapabilities(null); } boolean onscreen = capabilities.isOnscreen(); boolean usePBuffer = ((GLCapabilities) capabilities).isPBuffer(); GLCapabilities caps2 = (GLCapabilities) capabilities.clone(); if (!caps2.isOnscreen()) { // OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN caps2.setDoubleBuffered(false); } X11GLXGraphicsConfiguration res; res = chooseGraphicsConfigurationFBConfig( (GLCapabilities) caps2, (GLCapabilitiesChooser) chooser, x11Screen); if (null == res) { if (usePBuffer) { throw new GLException( "Error: Couldn't create X11GLXGraphicsConfiguration based on FBConfig"); } res = chooseGraphicsConfigurationXVisual( (GLCapabilities) caps2, (GLCapabilitiesChooser) chooser, x11Screen); } if (null == res) { throw new GLException("Error: Couldn't create X11GLXGraphicsConfiguration"); } if (DEBUG) { System.err.println( "X11GLXGraphicsConfiguration.chooseGraphicsConfigurationStatic(" + x11Screen + "," + caps2 + "): " + res); } return res; }
public static CapabilitiesImmutable fixCaps( boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { PixelFormat pf = new PixelFormat(); PixelFormat.getPixelFormatInfo(format, pf); final CapabilitiesImmutable res; int r, g, b, a; switch (format) { case PixelFormat.RGBA_8888: r = 8; g = 8; b = 8; a = 8; break; case PixelFormat.RGBX_8888: r = 8; g = 8; b = 8; a = 0; break; case PixelFormat.RGB_888: r = 8; g = 8; b = 8; a = 0; break; case PixelFormat.RGB_565: r = 5; g = 6; b = 5; a = 0; break; case PixelFormat.RGBA_5551: r = 5; g = 5; b = 5; a = 1; break; case PixelFormat.RGBA_4444: r = 4; g = 4; b = 4; a = 4; break; case PixelFormat.RGB_332: r = 3; g = 3; b = 2; a = 0; break; default: throw new InternalError("Unhandled pixelformat: " + format); } final boolean change = matchFormatPrecise || rCaps.getRedBits() > r && rCaps.getGreenBits() > g && rCaps.getBlueBits() > b && rCaps.getAlphaBits() > a; if (change) { Capabilities nCaps = (Capabilities) rCaps.cloneMutable(); nCaps.setRedBits(r); nCaps.setGreenBits(g); nCaps.setBlueBits(b); nCaps.setAlphaBits(a); res = nCaps; } else { res = rCaps; } Log.d(MD.TAG, "fixCaps: format: " + format); Log.d(MD.TAG, "fixCaps: requested: " + rCaps); Log.d(MD.TAG, "fixCaps: chosen: " + res); return res; }