コード例 #1
0
    @Override
    public void init(GLAutoDrawable drawable) {
      super.init(drawable);
      drawable.getGL().setSwapInterval(SwapInterval);
      t0 = Platform.currentTimeMillis();

      final Window win = (Window) drawable.getUpstreamWidget();
      final MonitorDevice monitor = win.getMainMonitor();
      final float[] pixelsPerMM = new float[2];
      monitor.getPixelsPerMM(pixelsPerMM);
      final float[] dotsPerInch = new float[] {pixelsPerMM[0] * 25.4f, pixelsPerMM[1] * 25.4f};
      dpiH = dotsPerInch[1];
      System.err.println(getFontInfo());
      System.err.println(
          "fontSize "
              + fontSizeFixed
              + ", dotsPerMM "
              + pixelsPerMM[0]
              + "x"
              + pixelsPerMM[1]
              + ", dpi "
              + dotsPerInch[0]
              + "x"
              + dotsPerInch[1]
              + ", pixelSize "
              + font.getPixelSize(fontSizeFixed, dotsPerInch[1] /* dpi display */));
    }
コード例 #2
0
ファイル: TestGLDebug00NEWT.java プロジェクト: since2014/jogl
  WindowContext createWindow(final GLProfile glp, final boolean debugGL) {
    final GLCapabilities caps = new GLCapabilities(glp);
    //
    // Create native windowing resources .. X11/Win/OSX
    //
    final Display display = NewtFactory.createDisplay(null); // local display
    Assert.assertNotNull(display);

    final Screen screen = NewtFactory.createScreen(display, 0); // screen 0
    Assert.assertNotNull(screen);

    final Window window = NewtFactory.createWindow(screen, caps);
    Assert.assertNotNull(window);
    window.setSize(128, 128);
    window.setVisible(true);

    final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp);
    final GLDrawable drawable = factory.createGLDrawable(window);
    Assert.assertNotNull(drawable);

    drawable.setRealized(true);

    final GLContext context = drawable.createContext(null);
    Assert.assertNotNull(context);

    context.enableGLDebugMessage(debugGL);

    final int res = context.makeCurrent();
    Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW == res || GLContext.CONTEXT_CURRENT == res);

    return new WindowContext(window, context);
  }
コード例 #3
0
ファイル: AWTAdapter.java プロジェクト: rothwell/jogl
 void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event) {
   try {
     newtWindow.getScreen().getDisplay().enqueueEvent(wait, event);
   } catch (NullPointerException npe) {
     /* that's ok .. window might be down already */
   }
 }
コード例 #4
0
 static void destroyWindow(final Window window, final boolean last) {
   if (null == window) {
     return;
   }
   final Screen screen = window.getScreen();
   final Display display = screen.getDisplay();
   window.destroy();
   // System.err.println("************* Destroyed: "+window);
   if (last) {
     Assert.assertEquals(false, screen.isNativeValid());
     Assert.assertEquals(false, display.isNativeValid());
   } else {
     Assert.assertEquals(true, screen.isNativeValid());
     Assert.assertEquals(true, display.isNativeValid());
   }
   Assert.assertEquals(false, window.isNativeValid());
   Assert.assertEquals(false, window.isVisible());
 }
コード例 #5
0
ファイル: AWTAdapter.java プロジェクト: rothwell/jogl
 /**
  * Create a pipeline adapter, AWT EventListener.<br>
  * Once attached to an AWT component, it sends the converted AWT events to the NEWT downstream
  * window.<br>
  * This is only supported with EDT enabled!
  */
 public AWTAdapter(com.jogamp.newt.Window downstream) {
   if (null == downstream) {
     throw new RuntimeException("Argument downstream is null");
   }
   this.newtListener = null;
   this.newtWindow = downstream;
   if (null == newtWindow.getScreen().getDisplay().getEDTUtil()) {
     throw new RuntimeException("EDT not enabled");
   }
 }
コード例 #6
0
ファイル: WindowImplAccess.java プロジェクト: hanjoyo/jogl
 public static final void windowDestroyNotify(Window win) {
   final WindowImpl winImpl = (WindowImpl) win.getDelegatedWindow();
   winImpl.runOnEDTIfAvail(
       true,
       new Runnable() {
         public void run() {
           winImpl.windowDestroyNotify(false);
         }
       });
 }
コード例 #7
0
  @Test
  public void testWindowNativeRecreate01Simple() throws InterruptedException {
    final Capabilities caps = new Capabilities();
    Assert.assertNotNull(caps);

    final Window window =
        createWindow(caps, -1, -1, width, height, true /* onscreen */, false /* undecorated */);
    destroyWindow(window, true);

    window.setVisible(true);
    Assert.assertEquals(true, window.isNativeValid());
    Assert.assertEquals(true, window.isVisible());
    Assert.assertEquals(width, window.getWidth());
    Assert.assertEquals(height, window.getHeight());

    destroyWindow(window, true);
  }
コード例 #8
0
ファイル: GLWindow.java プロジェクト: nightst4r/jogl
  /** Constructor. Do not call this directly -- use {@link #create()} instead. */
  protected GLWindow(Window window) {
    super(null, null, false /* always handle device lifecycle ourselves */);
    this.window = (WindowImpl) window;
    this.window.setWindowDestroyNotifyAction(
        new Runnable() {
          public void run() {
            defaultWindowDestroyNotifyOp();
          }
        });
    window.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowRepaint(WindowUpdateEvent e) {
            defaultWindowRepaintOp();
          }

          @Override
          public void windowResized(WindowEvent e) {
            defaultWindowResizedOp(getWidth(), getHeight());
          }
        });
    this.window.setLifecycleHook(new GLLifecycleHook());
  }
コード例 #9
0
  static Window createWindow(
      final Capabilities caps,
      final int x,
      final int y,
      final int width,
      final int height,
      final boolean onscreen,
      final boolean undecorated)
      throws InterruptedException {
    final boolean userPos = x >= 0 && y >= 0; // user has specified a position

    Assert.assertNotNull(caps);
    caps.setOnscreen(onscreen);
    // System.out.println("Requested: "+caps);

    //
    // Create native windowing resources .. X11/Win/OSX
    //
    final Window window = NewtFactory.createWindow(caps);
    Assert.assertNotNull(window);
    final Screen screen = window.getScreen();
    final Display display = screen.getDisplay();
    window.setUndecorated(onscreen && undecorated);
    if (userPos) {
      window.setPosition(x, y);
    }
    window.setSize(width, height);
    Assert.assertEquals(false, window.isNativeValid());
    Assert.assertEquals(false, window.isVisible());
    window.setVisible(true);
    // System.err.println("************* Created: "+window);

    Assert.assertEquals(true, display.isNativeValid());
    Assert.assertEquals(true, screen.isNativeValid());
    Assert.assertEquals(true, window.isVisible());
    Assert.assertEquals(true, window.isNativeValid());
    Assert.assertEquals(width, window.getWidth());
    Assert.assertEquals(height, window.getHeight());

    /**
     * we don't sync on position - unreliable test Point p0 = window.getLocationOnScreen(null);
     * Assert.assertEquals(p0.getX(), window.getX()); Assert.assertEquals(p0.getY(), window.getY());
     * if(userPos) { Assert.assertEquals(x, window.getX()); Assert.assertEquals(y, window.getY()); }
     */
    final CapabilitiesImmutable chosenCapabilities =
        window.getGraphicsConfiguration().getChosenCapabilities();
    Assert.assertNotNull(chosenCapabilities);
    Assert.assertTrue(chosenCapabilities.getGreenBits() >= 5);
    Assert.assertTrue(chosenCapabilities.getBlueBits() >= 5);
    Assert.assertTrue(chosenCapabilities.getRedBits() >= 5);
    Assert.assertEquals(chosenCapabilities.isOnscreen(), onscreen);

    return window;
  }