示例#1
0
文件: Window.java 项目: rsantina/jogl
  protected void createNativeImpl() {
    if (0 != getParentWindowHandle()) {
      throw new NativeWindowException("GDL Window does not support window parenting");
    }
    AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen();
    AbstractGraphicsDevice aDevice = getScreen().getDisplay().getGraphicsDevice();

    config =
        GraphicsConfigurationFactory.getFactory(aDevice)
            .chooseGraphicsConfiguration(
                capsRequested, capsRequested, capabilitiesChooser, aScreen);
    if (config == null) {
      throw new NativeWindowException(
          "Error choosing GraphicsConfiguration creating window: " + this);
    }

    synchronized (Window.class) {
      setWindowHandle(nextWindowHandle++); // just a marker

      surfaceHandle =
          CreateSurface(
              aDevice.getHandle(),
              getScreen().getWidth(),
              getScreen().getHeight(),
              x,
              y,
              width,
              height);
      if (surfaceHandle == 0) {
        throw new NativeWindowException("Error creating window");
      }
    }
  }
  protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
      CapabilitiesImmutable capsChosen,
      CapabilitiesImmutable capsRequested,
      CapabilitiesChooser chooser,
      AbstractGraphicsScreen absScreen) {
    if (!(absScreen instanceof X11GraphicsScreen)) {
      throw new IllegalArgumentException("Only X11GraphicsScreen are allowed here");
    }

    if (!(capsChosen instanceof GLCapabilitiesImmutable)) {
      throw new IllegalArgumentException(
          "This NativeWindowFactory accepts only GLCapabilities objects - chosen");
    }

    if (!(capsRequested instanceof GLCapabilitiesImmutable)) {
      throw new IllegalArgumentException(
          "This NativeWindowFactory accepts only GLCapabilities objects - requested");
    }

    if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) {
      throw new IllegalArgumentException(
          "This NativeWindowFactory accepts only GLCapabilitiesChooser objects");
    }

    if (!GLXUtil.isGLXAvailableOnServer((X11GraphicsDevice) absScreen.getDevice())) {
      if (null != fallbackX11GraphicsConfigurationFactory) {
        if (DEBUG) {
          System.err.println(
              "No GLX available, fallback to "
                  + fallbackX11GraphicsConfigurationFactory.getClass().getSimpleName()
                  + " for: "
                  + absScreen);
        }
        return fallbackX11GraphicsConfigurationFactory.chooseGraphicsConfiguration(
            capsChosen, capsRequested, chooser, absScreen);
      }
      throw new InternalError(
          "No GLX and no fallback GraphicsConfigurationFactory available for: " + absScreen);
    }
    return chooseGraphicsConfigurationStatic(
        (GLCapabilitiesImmutable) capsChosen, (GLCapabilitiesImmutable) capsRequested,
        (GLCapabilitiesChooser) chooser, (X11GraphicsScreen) absScreen);
  }
 static void registerFactory() {
   final GraphicsConfigurationFactory newFactory = new X11GLXGraphicsConfigurationFactory();
   final GraphicsConfigurationFactory oldFactory =
       GraphicsConfigurationFactory.registerFactory(
           com.jogamp.nativewindow.x11.X11GraphicsDevice.class, newFactory);
   if (oldFactory == newFactory) {
     throw new InternalError("GraphicsConfigurationFactory lifecycle impl. error");
   }
   if (null == oldFactory) {
     throw new InternalError("Missing fallback GraphicsConfigurationFactory");
   }
   fallbackX11GraphicsConfigurationFactory = oldFactory;
 }
 void updateGraphicsConfiguration() {
   CapabilitiesImmutable capsChosen = getChosenCapabilities();
   EGLGraphicsConfiguration newConfig =
       (EGLGraphicsConfiguration)
           GraphicsConfigurationFactory.getFactory(getScreen().getDevice(), capsChosen)
               .chooseGraphicsConfiguration(
                   capsChosen,
                   getRequestedCapabilities(),
                   chooser,
                   getScreen(),
                   VisualIDHolder.VID_UNDEFINED);
   if (null != newConfig) {
     // FIXME: setScreen( ... );
     setChosenCapabilities(newConfig.getChosenCapabilities());
     if (DEBUG) {
       System.err.println("updateGraphicsConfiguration(1): " + this);
     }
   }
 }
示例#5
0
文件: AWTCanvas.java 项目: swkzr/jogl
  private static AWTGraphicsConfiguration chooseGraphicsConfiguration(
      CapabilitiesImmutable capsChosen,
      CapabilitiesImmutable capsRequested,
      CapabilitiesChooser chooser,
      GraphicsDevice device) {
    final AbstractGraphicsScreen aScreen =
        null != device
            ? AWTGraphicsScreen.createScreenDevice(device, AbstractGraphicsDevice.DEFAULT_UNIT)
            : AWTGraphicsScreen.createDefault();
    AWTGraphicsConfiguration config =
        (AWTGraphicsConfiguration)
            GraphicsConfigurationFactory.getFactory(AWTGraphicsDevice.class, capsChosen.getClass())
                .chooseGraphicsConfiguration(
                    capsChosen, capsRequested, chooser, aScreen, VisualIDHolder.VID_UNDEFINED);
    if (config == null) {
      throw new NativeWindowException("Error: Couldn't fetch AWTGraphicsConfiguration");
    }

    return config;
  }
示例#6
0
 @Override
 protected void createNativeImpl() {
   final AbstractGraphicsConfiguration cfg =
       GraphicsConfigurationFactory.getFactory(
               getScreen().getDisplay().getGraphicsDevice(), capsRequested)
           .chooseGraphicsConfiguration(
               capsRequested,
               capsRequested,
               capabilitiesChooser,
               getScreen().getGraphicsScreen(),
               VisualIDHolder.VID_UNDEFINED);
   if (null == cfg) {
     throw new NativeWindowException(
         "Error choosing GraphicsConfiguration creating window: " + this);
   }
   setGraphicsConfiguration(cfg);
   reconfigureWindowImpl(
       getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true));
   if (0 == getWindowHandle()) {
     throw new NativeWindowException("Error creating window");
   }
 }
 public X11GLXGraphicsConfigurationFactory() {
   GraphicsConfigurationFactory.registerFactory(
       javax.media.nativewindow.x11.X11GraphicsDevice.class, this);
 }
  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);
 }
示例#10
0
  protected void createNativeImpl() {
    final ScreenDriver screen = (ScreenDriver) getScreen();
    final DisplayDriver display = (DisplayDriver) screen.getDisplay();
    final AbstractGraphicsDevice edtDevice = display.getGraphicsDevice();

    // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering
    final long renderDeviceHandle = X11Util.openDisplay(edtDevice.getConnection());
    if (0 == renderDeviceHandle) {
      throw new RuntimeException("Error creating display(EDT): " + edtDevice.getConnection());
    }
    renderDevice =
        new X11GraphicsDevice(
            renderDeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */);
    final AbstractGraphicsScreen renderScreen =
        new X11GraphicsScreen(renderDevice, screen.getIndex());

    final GraphicsConfigurationFactory factory =
        GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested);
    final AbstractGraphicsConfiguration cfg =
        factory.chooseGraphicsConfiguration(
            capsRequested,
            capsRequested,
            capabilitiesChooser,
            renderScreen,
            VisualIDHolder.VID_UNDEFINED);
    if (DEBUG_IMPLEMENTATION) {
      System.err.println(
          "X11Window.createNativeImpl() factory: " + factory + ", chosen config: " + cfg);
    }
    if (null == cfg) {
      throw new NativeWindowException(
          "Error choosing GraphicsConfiguration creating window: " + this);
    }
    final int visualID = cfg.getVisualID(VIDType.NATIVE);
    if (VisualIDHolder.VID_UNDEFINED == visualID) {
      throw new NativeWindowException("Chosen Configuration w/o native visual ID: " + cfg);
    }
    setGraphicsConfiguration(cfg);
    final int flags = getReconfigureFlags(0, true) & (FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED);
    edtDevice.lock();
    try {
      setWindowHandle(
          CreateWindow0(
              getParentWindowHandle(),
              edtDevice.getHandle(),
              screen.getIndex(),
              visualID,
              display.getJavaObjectAtom(),
              display.getWindowDeleteAtom(),
              getX(),
              getY(),
              getWidth(),
              getHeight(),
              autoPosition(),
              flags));
    } finally {
      edtDevice.unlock();
    }
    windowHandleClose = getWindowHandle();
    if (0 == windowHandleClose) {
      throw new NativeWindowException("Error creating window");
    }
  }
  protected AbstractGraphicsConfiguration chooseGraphicsConfigurationImpl(
      CapabilitiesImmutable capsChosen,
      CapabilitiesImmutable capsRequested,
      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, AbstractGraphicsDevice.DEFAULT_UNIT);
    }
    AWTGraphicsScreen awtScreen = (AWTGraphicsScreen) absScreen;
    device = ((AWTGraphicsDevice) awtScreen.getDevice()).getGraphicsDevice();

    if (!(capsChosen instanceof GLCapabilitiesImmutable)) {
      throw new IllegalArgumentException(
          "This GraphicsConfigurationFactory accepts only GLCapabilities objects - chosen");
    }

    if (!(capsRequested instanceof GLCapabilitiesImmutable)) {
      throw new IllegalArgumentException(
          "This GraphicsConfigurationFactory accepts only GLCapabilities objects - requested");
    }

    if (chooser != null && !(chooser instanceof GLCapabilitiesChooser)) {
      throw new IllegalArgumentException(
          "This GraphicsConfigurationFactory accepts only GLCapabilitiesChooser objects");
    }

    if (DEBUG) {
      System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: got " + absScreen);
    }
    GraphicsConfiguration gc = device.getDefaultConfiguration();
    WindowsGraphicsDevice winDevice =
        new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT);
    DefaultGraphicsScreen winScreen = new DefaultGraphicsScreen(winDevice, awtScreen.getIndex());
    if (DEBUG) {
      System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: made " + winScreen);
    }

    WindowsWGLGraphicsConfiguration winConfig =
        (WindowsWGLGraphicsConfiguration)
            GraphicsConfigurationFactory.getFactory(winDevice)
                .chooseGraphicsConfiguration(capsChosen, capsRequested, chooser, winScreen);

    if (winConfig == null) {
      throw new GLException(
          "Unable to choose a GraphicsConfiguration: "
              + capsChosen
              + ",\n\t"
              + chooser
              + "\n\t"
              + winScreen);
    }

    if (DEBUG) {
      System.err.println("WindowsAWTWGLGraphicsConfigurationFactory: chosen " + winConfig);
    }

    // We have nothing to match .. so choose the default
    return new AWTGraphicsConfiguration(
        awtScreen,
        winConfig.getChosenCapabilities(),
        winConfig.getRequestedCapabilities(),
        gc,
        winConfig);
  }