예제 #1
0
  public static void run(
      GLWindow windowOffScreen,
      GLEventListener demo,
      GLWindow windowOnScreen,
      WindowListener wl,
      MouseListener ml,
      SurfaceUpdatedListener ul,
      int frames,
      boolean snapshot,
      boolean debug) {
    Assert.assertNotNull(windowOffScreen);
    Assert.assertNotNull(demo);

    setDemoFields(demo, windowOffScreen, windowOffScreen, debug);
    windowOffScreen.addGLEventListener(demo);

    if (null != windowOnScreen) {
      if (null != wl) {
        windowOnScreen.addWindowListener(wl);
      }
      if (null != ml) {
        windowOnScreen.addMouseListener(ml);
      }
      windowOnScreen.setVisible(true);
    }

    GLDrawable readDrawable = windowOffScreen.getContext().getGLDrawable();

    if (null == windowOnScreen) {
      if (snapshot) {
        Surface2File s2f = new Surface2File();
        windowOffScreen.addSurfaceUpdatedListener(s2f);
      }
    } else {
      ReadBuffer2Screen readDemo = new ReadBuffer2Screen(readDrawable);
      windowOnScreen.addGLEventListener(readDemo);
    }
    if (null != ul) {
      windowOffScreen.addSurfaceUpdatedListener(ul);
    }

    if (debug) {
      System.out.println("+++++++++++++++++++++++++++");
      System.out.println(windowOffScreen);
      System.out.println("+++++++++++++++++++++++++++");
    }

    while (windowOffScreen.getTotalFrames() < frames) {
      windowOffScreen.display();
    }
    windowOffScreen.removeAllSurfaceUpdatedListener();
  }
예제 #2
0
  protected void runTestGL(final GLCapabilitiesImmutable caps) throws InterruptedException {
    final Display nDisplay =
        NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null, false); // local display
    final Screen nScreen = NewtFactory.createScreen(nDisplay, 0); // screen 0
    final Window nWindow = NewtFactory.createWindow(nScreen, caps);

    final GLWindow glWindow = GLWindow.create(nWindow);
    Assert.assertNotNull(glWindow);
    glWindow.setTitle("Gears NewtAWTWrapper Test");

    glWindow.addGLEventListener(new GearsES2(1));

    final Animator animator = useAnimator ? new Animator(glWindow) : null;
    final QuitAdapter quitAdapter = new QuitAdapter();

    glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter));
    glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter));

    if (useAnimator) {
      animator.start();
    }

    int div = 3;
    glWindow.setSize(width / div, height / div);
    glWindow.setVisible(true);
    if (doResizeTest) {
      glWindow.display();
      final int[] expSurfaceSize =
          glWindow.getNativeSurface().convertToPixelUnits(new int[] {width / div, height / div});
      Assert.assertTrue(
          "Surface Size not reached: Expected "
              + expSurfaceSize[0]
              + "x"
              + expSurfaceSize[1]
              + ", Is "
              + glWindow.getSurfaceWidth()
              + "x"
              + glWindow.getSurfaceHeight(),
          AWTRobotUtil.waitForSize(glWindow, expSurfaceSize[0], expSurfaceSize[1]));
      Thread.sleep(600);

      div = 2;
      glWindow.setSize(width / div, height / div);
      glWindow.display();
      expSurfaceSize[0] = width / div;
      expSurfaceSize[1] = height / div;
      glWindow.getNativeSurface().convertToPixelUnits(expSurfaceSize);
      Assert.assertTrue(
          "Surface Size not reached: Expected "
              + expSurfaceSize[0]
              + "x"
              + expSurfaceSize[1]
              + ", Is "
              + glWindow.getSurfaceWidth()
              + "x"
              + glWindow.getSurfaceHeight(),
          AWTRobotUtil.waitForSize(glWindow, expSurfaceSize[0], expSurfaceSize[1]));
      Thread.sleep(600);

      div = 1;
      glWindow.setSize(width / div, height / div);
      glWindow.display();
      expSurfaceSize[0] = width / div;
      expSurfaceSize[1] = height / div;
      glWindow.getNativeSurface().convertToPixelUnits(expSurfaceSize);
      Assert.assertTrue(
          "Surface Size not reached: Expected "
              + expSurfaceSize[0]
              + "x"
              + expSurfaceSize[1]
              + ", Is "
              + glWindow.getSurfaceWidth()
              + "x"
              + glWindow.getSurfaceHeight(),
          AWTRobotUtil.waitForSize(glWindow, expSurfaceSize[0], expSurfaceSize[1]));
      Thread.sleep(600);
    }

    final long t0 = System.currentTimeMillis();
    long t1 = t0;
    while (!quitAdapter.shouldQuit() && t1 - t0 < duration) {
      Thread.sleep(100);
      t1 = System.currentTimeMillis();
    }

    if (useAnimator) {
      animator.stop();
    }
    glWindow.destroy();
  }