예제 #1
0
  private void run(int type, PerfModule pm) {
    int width = 800;
    int height = 480;
    pmod = pm;
    System.err.println("Perftst.run()");
    try {
      GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2());
      // For emulation library, use 16 bpp
      caps.setRedBits(5);
      caps.setGreenBits(6);
      caps.setBlueBits(5);
      caps.setDepthBits(16);

      Window nWindow = null;
      if (0 != (type & USE_AWT)) {
        Display nDisplay =
            NewtFactory.createDisplay(NativeWindowFactory.TYPE_AWT, null); // local display
        Screen nScreen =
            NewtFactory.createScreen(NativeWindowFactory.TYPE_AWT, nDisplay, 0); // screen 0
        nWindow = NewtFactory.createWindow(NativeWindowFactory.TYPE_AWT, nScreen, caps);
        window = GLWindow.create(nWindow);
      } else {
        window = GLWindow.create(caps);
      }

      window.addMouseListener(this);
      window.addGLEventListener(this);
      // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_CURRENT); // default
      // window.setEventHandlerMode(GLWindow.EVENT_HANDLER_GL_NONE); // no current ..

      // Size OpenGL to Video Surface
      window.setSize(width, height);
      window.setFullscreen(true);
      window.setVisible(true);

      window.display();

      // Shut things down cooperatively
      window.destroy();
      window.getFactory().shutdown();
      System.out.println("Perftst shut down cleanly.");
    } catch (Throwable t) {
      t.printStackTrace();
    }
  }
예제 #2
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;
  }
예제 #3
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();
  }