예제 #1
0
파일: MonitorMode.java 프로젝트: dcsch/jogl
 private final int getRotatedWH(final boolean width) {
   final DimensionImmutable d = sizeAndRRate.surfaceSize.getResolution();
   final boolean swap = MonitorMode.ROTATE_90 == rotation || MonitorMode.ROTATE_270 == rotation;
   if ((width && swap) || (!width && !swap)) {
     return d.getHeight();
   }
   return d.getWidth();
 }
예제 #2
0
 public JoglNewtWindow(
     final JoglCanvasRenderer canvasRenderer,
     final DisplaySettings settings,
     final boolean onscreen,
     final boolean bitmapRequested,
     final boolean pbufferRequested,
     final boolean fboRequested,
     final CapsUtil capsUtil) {
   _capsUtil = capsUtil;
   // FIXME rather pass the monitor(s) to the constructor, create a screen to get the primary
   // monitor
   _newtWindow =
       GLWindow.create(
           capsUtil.getCapsForSettingsWithHints(
               settings, onscreen, bitmapRequested, pbufferRequested, fboRequested));
   _monitorDevices = new ArrayList<>();
   // uses the primary monitor by default
   _newtWindow.getScreen().createNative();
   final MonitorDevice primaryMonitor = _newtWindow.getScreen().getPrimaryMonitor();
   _monitorDevices.add(primaryMonitor);
   // disables HiDPI, see https://github.com/gouessej/Ardor3D/issues/14
   _newtWindow.setSurfaceScale(
       new float[] {ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE});
   _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer);
   final int width, height;
   if (settings.isFullScreen() && settings.getWidth() == 0 || settings.getHeight() == 0) {
     // FIXME use all available monitor devices to compute the size
     final DimensionImmutable currentResolution =
         primaryMonitor.queryCurrentMode().getSurfaceSize().getResolution();
     width = currentResolution.getWidth();
     height = currentResolution.getHeight();
   } else {
     width = settings.getWidth();
     height = settings.getHeight();
   }
   _settings =
       new DisplaySettings(
           width,
           height,
           settings.getColorDepth(),
           settings.getFrequency(),
           settings.getAlphaBits(),
           settings.getDepthBits(),
           settings.getStencilBits(),
           settings.getSamples(),
           settings.isFullScreen(),
           settings.isStereo(),
           settings.getShareContext(),
           settings.getRotation());
   _canvasRenderer = canvasRenderer;
   _canvasRenderer._doSwap = true; // true - do swap in renderer.
   setAutoSwapBufferMode(false); // false - doesn't swap automatically in JOGL itself
 }
예제 #3
0
 /** Applies all settings not related to OpenGL (screen resolution, screen size, etc...) */
 protected void applySettings() {
   _newtWindow.setUndecorated(_settings.isFullScreen());
   if (_settings.isFullScreen()) {
     _newtWindow.setFullscreen(_monitorDevices);
     for (final MonitorDevice monitorDevice : _monitorDevices) {
       List<MonitorMode> monitorModes = monitorDevice.getSupportedModes();
       final MonitorMode currentMode = monitorDevice.getCurrentMode();
       if (monitorDevice == _monitorDevices.get(0)) {
         final Dimension dimension;
         // the resolution is taken into account only if it is valid
         if (_settings.getWidth() > 0 && _settings.getHeight() > 0) {
           dimension = new Dimension(_settings.getWidth(), _settings.getHeight());
         } else {
           final DimensionImmutable currentResolution =
               currentMode.getSurfaceSize().getResolution();
           dimension = new Dimension(currentResolution.getWidth(), currentResolution.getHeight());
         }
         monitorModes = MonitorModeUtil.filterByResolution(monitorModes, dimension);
       } else {
         // FIXME the display settings should store the size of the other monitors
       }
       // if the frequency may be valid (greater than zero), it tries to use it
       final List<MonitorMode> byRateMonitorModes;
       if (_settings.getFrequency() > 0) {
         byRateMonitorModes = MonitorModeUtil.filterByRate(monitorModes, _settings.getFrequency());
       } else {
         // if the frequency is set to zero, it tries to preserve the refresh rate
         if (_settings.getFrequency() == 0) {
           byRateMonitorModes =
               MonitorModeUtil.filterByRate(monitorModes, currentMode.getRefreshRate());
         } else {
           // otherwise it picks the highest available rate
           byRateMonitorModes = MonitorModeUtil.getHighestAvailableRate(monitorModes);
         }
       }
       if (!byRateMonitorModes.isEmpty()) {
         monitorModes = byRateMonitorModes;
       }
       final List<MonitorMode> byBppMonitorModes;
       switch (_settings.getColorDepth()) {
         case 16:
         case 24:
         case 32:
           {
             byBppMonitorModes =
                 MonitorModeUtil.filterByBpp(monitorModes, _settings.getColorDepth());
             break;
           }
         case 0:
           {
             byBppMonitorModes =
                 MonitorModeUtil.filterByBpp(
                     monitorModes, currentMode.getSurfaceSize().getBitsPerPixel());
             break;
           }
         case -1:
           {
             byBppMonitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes);
             break;
           }
         default:
           {
             byBppMonitorModes = monitorModes;
           }
       }
       if (!byBppMonitorModes.isEmpty()) {
         monitorModes = byBppMonitorModes;
       }
       if (_settings.getRotation() == MonitorMode.ROTATE_0
           || _settings.getRotation() == MonitorMode.ROTATE_90
           || _settings.getRotation() == MonitorMode.ROTATE_180
           || _settings.getRotation() == MonitorMode.ROTATE_270) {
         final List<MonitorMode> rotatedMonitorModes =
             MonitorModeUtil.filterByRotation(monitorModes, _settings.getRotation());
         if (!rotatedMonitorModes.isEmpty()) {
           monitorModes = rotatedMonitorModes;
         }
       }
       monitorDevice.setCurrentMode(monitorModes.get(0));
     }
   } else {
     _newtWindow.setFullscreen(false);
   }
 }