コード例 #1
0
ファイル: JoglNewtWindow.java プロジェクト: gouessej/Ardor3D
 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
 }
コード例 #2
0
 public JoglNewtWindow(
     final JoglCanvasRenderer canvasRenderer,
     final DisplaySettings settings,
     final boolean onscreen,
     final boolean bitmapRequested,
     final boolean pbufferRequested,
     final boolean fboRequested) {
   _newtWindow =
       GLWindow.create(
           CapsUtil.getCapsForSettings(
               settings, onscreen, bitmapRequested, pbufferRequested, fboRequested));
   _drawerGLRunnable = new JoglDrawerRunnable(canvasRenderer);
   _settings = settings;
   _canvasRenderer = canvasRenderer;
   setAutoSwapBufferMode(false);
 }
コード例 #3
0
ファイル: JoglNewtWindow.java プロジェクト: gouessej/Ardor3D
  @Override
  @MainThread
  public void init() {
    if (_inited) {
      return;
    }

    // Set the size very early to prevent the default one from being used (typically when exiting
    // full screen mode)
    setSize(_settings.getWidth(), _settings.getHeight());
    // Make the window visible to realize the OpenGL surface.
    setVisible(true);
    if (_newtWindow.isRealized()) {
      final GLCapabilitiesImmutable glCaps = _newtWindow.getChosenGLCapabilities();
      _settings =
          _capsUtil.getSettingsForCaps(
              glCaps,
              _settings.getWidth(),
              _settings.getHeight(),
              _settings.getFrequency(),
              _settings.isFullScreen(),
              _settings.getShareContext(),
              _settings.getRotation());
      _newtWindow.addWindowListener(
          new WindowAdapter() {
            @Override
            public void windowDestroyNotify(final WindowEvent e) {
              _isClosing = true;
            }

            // public void windowResized(final WindowEvent e) {
            // _newtWindow.invoke(true, new GLRunnable() {
            //
            // @Override
            // public boolean run(GLAutoDrawable glAutoDrawable) {
            // _canvasRenderer._camera.resize(_newtWindow.getWidth(), _newtWindow.getHeight());
            // _canvasRenderer._camera.setFrustumPerspective(_canvasRenderer._camera.getFovY(),
            // (float) _newtWindow.getWidth() / (float) _newtWindow.getHeight(),
            // _canvasRenderer._camera.getFrustumNear(),
            // _canvasRenderer._camera.getFrustumFar());
            // return true;
            // }
            // });
            // }
          });

      // Request the focus here as it cannot work when the window is not visible
      _newtWindow.requestFocus();
      applySettings();

      _canvasRenderer.setContext(getContext());

      _newtWindow.invoke(
          true,
          new GLRunnable() {
            @Override
            public boolean run(final GLAutoDrawable glAutoDrawable) {
              _canvasRenderer.init(_settings, _canvasRenderer._doSwap);
              return true;
            }
          });
      _inited = true;
    }
  }