コード例 #1
0
ファイル: WindowDriver.java プロジェクト: swkzr/jogl
  @Override
  protected void createNativeImpl() {
    Log.d(
        MD.TAG,
        "createNativeImpl 0 - surfaceHandle 0x"
            + Long.toHexString(surfaceHandle)
            + ", format [a "
            + androidFormat
            + ", n "
            + nativeFormat
            + "], "
            + getX()
            + "/"
            + getY()
            + " "
            + getWidth()
            + "x"
            + getHeight()
            + " - "
            + Thread.currentThread().getName());

    if (0 != getParentWindowHandle()) {
      throw new NativeWindowException("Window parenting not supported (yet)");
    }
    if (0 == surfaceHandle) {
      throw new InternalError("XXX");
    }

    final EGLGraphicsDevice eglDevice =
        (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice();
    final EGLGraphicsConfiguration eglConfig =
        EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(
            capsByFormat,
            (GLCapabilitiesImmutable) getRequestedCapabilities(),
            (GLCapabilitiesChooser) capabilitiesChooser,
            getScreen().getGraphicsScreen(),
            nativeFormat,
            isAndroidFormatTransparent(androidFormat));
    if (eglConfig == null) {
      throw new NativeWindowException(
          "Error choosing GraphicsConfiguration creating window: " + this);
    }
    final int nativeVisualID = eglConfig.getVisualID(VisualIDHolder.VIDType.NATIVE);
    Log.d(MD.TAG, "nativeVisualID 0x" + Integer.toHexString(nativeVisualID));
    if (VisualIDHolder.VID_UNDEFINED != nativeVisualID) {
      setSurfaceVisualID0(surfaceHandle, nativeVisualID);
    }

    eglSurface =
        EGL.eglCreateWindowSurface(
            eglDevice.getHandle(), eglConfig.getNativeConfig(), surfaceHandle, null);
    if (EGL.EGL_NO_SURFACE == eglSurface) {
      throw new NativeWindowException(
          "Creation of window surface failed: "
              + eglConfig
              + ", surfaceHandle 0x"
              + Long.toHexString(surfaceHandle)
              + ", error "
              + toHexString(EGL.eglGetError()));
    }

    // propagate data ..
    setGraphicsConfiguration(eglConfig);
    setWindowHandle(surfaceHandle);
    focusChanged(false, true);
    Log.d(MD.TAG, "createNativeImpl X: eglSurfaceHandle 0x" + Long.toHexString(eglSurface));
  }