Esempio n. 1
0
 /**
  * Returns whether the two display modes are equal.
  *
  * @return whether the two display modes are equal
  */
 public boolean equals(DisplayMode dm) {
   if (dm == null) {
     return false;
   }
   return (getHeight() == dm.getHeight()
       && getWidth() == dm.getWidth()
       && getBitDepth() == dm.getBitDepth()
       && getRefreshRate() == dm.getRefreshRate());
 }
Esempio n. 2
0
 MacOSXFrame(
     DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y)
     throws LWJGLException {
   setResizable(false);
   addWindowListener(this);
   addComponentListener(this);
   canvas = new MacOSXGLCanvas();
   canvas.setFocusTraversalKeysEnabled(false);
   add(canvas, BorderLayout.CENTER);
   boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
   setUndecorated(fullscreen || undecorated);
   if (fullscreen) {
     try {
       AccessController.doPrivileged(
           new PrivilegedExceptionAction() {
             public Object run() throws Exception {
               getDevice().setFullScreenWindow(MacOSXFrame.this);
               getDevice().setDisplayMode(requested_mode);
               java.awt.DisplayMode real_mode = getDevice().getDisplayMode();
               /**
                * For some strange reason, the display mode is sometimes silently capped even
                * though the mode is reported as supported
                */
               if (requested_mode.getWidth() != real_mode.getWidth()
                   || requested_mode.getHeight() != real_mode.getHeight()) {
                 getDevice().setFullScreenWindow(null);
                 if (isDisplayable()) dispose();
                 throw new LWJGLException(
                     "AWT capped mode: requested mode = "
                         + requested_mode.getWidth()
                         + "x"
                         + requested_mode.getHeight()
                         + " but got "
                         + real_mode.getWidth()
                         + " "
                         + real_mode.getHeight());
               }
               return null;
             }
           });
     } catch (PrivilegedActionException e) {
       throw new LWJGLException(e);
     }
   }
   pack();
   resize(x, y, mode.getWidth(), mode.getHeight());
   setVisible(true);
   requestFocus();
   canvas.requestFocus();
   updateBounds();
 }
Esempio n. 3
0
  /**
   * @param dim
   * @param mode
   * @param fullscreen
   * @return enum rserr_t
   */
  public int GLimp_SetMode(Dimension dim, int mode, boolean fullscreen) {

    // TODO: jgw
    fullscreen = false;

    GlState.gl.log("GLimp_SetMode");

    Dimension newDim = new Dimension(dim.width, dim.height);

    /*
     * fullscreen handling
     */

    GlState.gl.log("determining old display mode");
    if (GlState.oldDisplayMode == null) {
      GlState.oldDisplayMode = getDisplayMode();
    }

    // destroy the existing window
    GlState.gl.shutdow();

    GlState.gl.log("searching new display mode");
    DisplayMode displayMode = DisplayModes.findDisplayMode(newDim);
    GlState.gl.log("copying w/h");
    newDim.width = displayMode.getWidth();
    newDim.height = displayMode.getHeight();

    GlState.gl.log("setting mode: " + displayMode);

    this.width = newDim.width;
    this.height = newDim.height;

    GlState.gl.log("storing mode");
    GlState.vid.width = newDim.width;
    GlState.vid.height = newDim.height;

    // let the sound and input subsystems know about the new window
    GlState.gl.log("newWindow notification");
    Window.NewWindow(GlState.vid.width, GlState.vid.height);
    return GlConstants.rserr_ok;
  }