コード例 #1
0
ファイル: WindowsDisplay.java プロジェクト: ravenocean/lwjgl
  public void destroyWindow() {
    if (parent != null) {
      parent.removeFocusListener(parent_focus_tracker);
      parent_focus_tracker = null;
    }

    nReleaseDC(hwnd, hdc);
    nDestroyWindow(hwnd);
    freeLargeIcon();
    freeSmallIcon();
    resetCursorClipping();
  }
コード例 #2
0
ファイル: WindowsDisplay.java プロジェクト: ravenocean/lwjgl
  public void createWindow(DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y)
      throws LWJGLException {
    close_requested = false;
    is_dirty = false;
    isMinimized = false;
    isFocused = false;
    redoMakeContextCurrent = false;
    maximized = false;
    this.parent = parent;
    hasParent = parent != null;
    parent_hwnd = parent != null ? getHwnd(parent) : 0;
    this.hwnd =
        nCreateWindow(
            x,
            y,
            mode.getWidth(),
            mode.getHeight(),
            Display.isFullscreen() || isUndecorated(),
            parent != null,
            parent_hwnd);
    this.resizable = false;
    if (hwnd == 0) {
      throw new LWJGLException("Failed to create window");
    }
    this.hdc = getDC(hwnd);
    if (hdc == 0) {
      nDestroyWindow(hwnd);
      throw new LWJGLException("Failed to get dc");
    }

    try {
      if (drawable instanceof DrawableGL) {
        int format =
            WindowsPeerInfo.choosePixelFormat(
                getHdc(),
                0,
                0,
                (PixelFormat) drawable.getPixelFormat(),
                null,
                true,
                true,
                false,
                true);
        WindowsPeerInfo.setPixelFormat(getHdc(), format);
      } else {
        peer_info = new WindowsDisplayPeerInfo(true);
        ((DrawableGLES) drawable)
            .initialize(
                hwnd,
                hdc,
                EGL.EGL_WINDOW_BIT,
                (org.lwjgl.opengles.PixelFormat) drawable.getPixelFormat());
      }
      peer_info.initDC(getHwnd(), getHdc());
      showWindow(getHwnd(), SW_SHOWDEFAULT);

      updateWidthAndHeight();

      if (parent == null) {
        if (Display.isResizable()) {
          setResizable(true);
        }
        setForegroundWindow(getHwnd());
      } else {
        parent_focused = new AtomicBoolean(false);
        parent.addFocusListener(
            parent_focus_tracker =
                new FocusAdapter() {
                  public void focusGained(FocusEvent e) {
                    parent_focused.set(true);
                    clearAWTFocus();
                  }
                });
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                clearAWTFocus();
              }
            });
      }
      grabFocus();
    } catch (LWJGLException e) {
      nReleaseDC(hwnd, hdc);
      nDestroyWindow(hwnd);
      throw e;
    }
  }