示例#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
  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();
    }
  }