Example #1
0
 @BeforeClass
 public static void initClass() {
   glp = GLProfile.getGL2ES2();
   Assert.assertNotNull(glp);
   width = 640;
   height = 480;
 }
Example #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String[] urls0 =
        new String[] {
          System.getProperty("jnlp.media0_url2"),
          System.getProperty("jnlp.media0_url1"),
          System.getProperty("jnlp.media0_url0")
        };
    final URLConnection urlConnection0 = getResource(urls0, 0);
    if (null == urlConnection0) {
      throw new RuntimeException("no media reachable: " + Arrays.asList(urls0));
    }

    // also initializes JOGL
    final GLCapabilities capsMain = new GLCapabilities(GLProfile.getGL2ES2());
    capsMain.setBackgroundOpaque(false);

    // screen for layout params ..
    final com.jogamp.newt.Display dpy = NewtFactory.createDisplay(null);
    final com.jogamp.newt.Screen scrn = NewtFactory.createScreen(dpy, 0);
    scrn.addReference();

    try {
      final Animator animator = new Animator();

      // Main
      final MovieCube demoMain =
          new MovieCube(
              urlConnection0,
              GLMediaPlayer.STREAM_ID_AUTO,
              GLMediaPlayer.STREAM_ID_AUTO,
              -2.3f,
              0f,
              0f);
      final GLWindow glWindowMain = GLWindow.create(scrn, capsMain);
      glWindowMain.setFullscreen(true);
      setContentView(getWindow(), glWindowMain);
      glWindowMain.addMouseListener(showKeyboardMouseListener);
      glWindowMain.addGLEventListener(demoMain);
      animator.add(glWindowMain);
      glWindowMain.setVisible(true);

      // animator.setUpdateFPSFrames(60, System.err);
      animator.setUpdateFPSFrames(-1, null);
      animator.resetFPSCounter();
    } catch (IOException e) {
      e.printStackTrace();
    }

    scrn.removeReference();

    Log.d(TAG, "onCreate - X");
  }
Example #3
0
  private void testMultiSampleAAImpl(
      final boolean useFBO, final boolean usePBuffer, final int reqSamples)
      throws InterruptedException {
    final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false);
    final GLProfile glp = GLProfile.getGL2ES2();
    final GLCapabilities caps = new GLCapabilities(glp);
    final GLCapabilitiesChooser chooser = new MultisampleChooser01();

    caps.setAlphaBits(1);
    caps.setFBO(useFBO);
    caps.setPBuffer(usePBuffer);

    if (reqSamples > 0) {
      caps.setSampleBuffers(true);
      caps.setNumSamples(reqSamples);
    }

    final GLWindow window = GLWindow.create(caps);
    window.setCapabilitiesChooser(chooser);
    window.addGLEventListener(new MultisampleDemoES2(reqSamples > 0 ? true : false));
    window.addGLEventListener(
        new GLEventListener() {
          int displayCount = 0;

          public void init(final GLAutoDrawable drawable) {}

          public void dispose(final GLAutoDrawable drawable) {}

          public void display(final GLAutoDrawable drawable) {
            snapshot(displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
          }

          public void reshape(
              final GLAutoDrawable drawable,
              final int x,
              final int y,
              final int width,
              final int height) {}
        });
    window.setSize(512, 512);
    window.setVisible(true);
    window.requestFocus();

    Thread.sleep(durationPerTest);

    window.destroy();
  }
Example #4
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();
    }
  }
Example #5
0
  public static void main(String[] args) {
    GLProfile glp = GLProfile.getGL2ES2();
    GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(4);
    caps.setSampleBuffers(true);
    caps.setNumSamples(4);
    System.out.println("Requested: " + caps);

    final GLWindow window = GLWindow.create(caps);
    window.setPosition(10, 10);
    window.setSize(800, 400);
    window.setTitle("GPU UI Newt Demo 01");
    RenderState rs = RenderState.createRenderState(new ShaderState(), SVertex.factory());
    UIGLListener01 uiGLListener = new UIGLListener01(rs, DEBUG, TRACE);
    uiGLListener.attachInputListenerTo(window);
    window.addGLEventListener(uiGLListener);

    window.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
    window.setVisible(true);

    final Animator animator = new Animator();
    animator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err);
    animator.add(window);

    window.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_F4) {
              window.destroy();
            }
          }
        });
    window.addWindowListener(
        new WindowAdapter() {
          public void windowDestroyed(WindowEvent e) {
            animator.stop();
          }
        });

    animator.start();
  }
  public void testImpl(boolean useFFP, final InputStream istream)
      throws InterruptedException, IOException {
    final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false);
    GLProfile glp;
    if (useFFP && GLProfile.isAvailable(GLProfile.GL2)) {
      glp = GLProfile.getMaxFixedFunc(true);
    } else if (!useFFP && GLProfile.isAvailable(GLProfile.GL2ES2)) {
      glp = GLProfile.getGL2ES2();
    } else {
      System.err.println(getSimpleTestName(".") + ": GLProfile n/a, useFFP: " + useFFP);
      return;
    }
    final GLCapabilities caps = new GLCapabilities(glp);
    caps.setAlphaBits(1);

    final TextureData texData =
        TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.TGA);
    System.err.println("TextureData: " + texData);

    final GLWindow glad = GLWindow.create(caps);
    glad.setTitle("TestTGATextureGL2FromFileNEWT");
    // Size OpenGL to Video Surface
    glad.setSize(texData.getWidth(), texData.getHeight());

    // load texture from file inside current GL context to match the way
    // the bug submitter was doing it
    final GLEventListener gle =
        useFFP ? new TextureDraw01GL2Listener(texData) : new TextureDraw01ES2Listener(texData, 0);
    glad.addGLEventListener(gle);
    glad.addGLEventListener(
        new GLEventListener() {
          boolean shot = false;

          @Override
          public void init(GLAutoDrawable drawable) {}

          public void display(GLAutoDrawable drawable) {
            // 1 snapshot
            if (null != ((TextureDraw01Accessor) gle).getTexture() && !shot) {
              shot = true;
              snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
            }
          }

          @Override
          public void dispose(GLAutoDrawable drawable) {}

          @Override
          public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {}
        });

    Animator animator = new Animator(glad);
    animator.setUpdateFPSFrames(60, showFPS ? System.err : null);
    QuitAdapter quitAdapter = new QuitAdapter();
    glad.addKeyListener(quitAdapter);
    glad.addWindowListener(quitAdapter);
    glad.setVisible(true);
    animator.start();

    while (!quitAdapter.shouldQuit()
        && animator.isAnimating()
        && animator.getTotalFPSDuration() < duration) {
      Thread.sleep(100);
    }

    animator.stop();
    glad.destroy();
  }
  @Test
  public void testShaderState01Validation() throws InterruptedException {
    // preset ..
    final NEWTGLContext.WindowContext winctx =
        NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, true);
    final GLDrawable drawable = winctx.context.getGLDrawable();
    final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
    System.err.println(winctx.context);

    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());

    // test code ..
    final ShaderState st = new ShaderState();

    final ShaderCode rsVp =
        ShaderCode.create(
            gl,
            GL2ES2.GL_VERTEX_SHADER,
            1,
            RedSquare0.class,
            "shader",
            "shader/bin",
            "RedSquareShader");
    final ShaderCode rsFp =
        ShaderCode.create(
            gl,
            GL2ES2.GL_FRAGMENT_SHADER,
            1,
            RedSquare0.class,
            "shader",
            "shader/bin",
            "RedSquareShader");

    final ShaderProgram sp = new ShaderProgram();
    Assert.assertTrue(0 > sp.program());

    sp.add(gl, rsVp, System.err);
    sp.add(gl, rsFp, System.err);

    Assert.assertTrue(0 <= sp.program());
    Assert.assertTrue(!sp.inUse());
    Assert.assertTrue(!sp.linked());
    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());

    st.attachShaderProgram(gl, sp);

    // Allocate Vertex Array0
    final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, vertices0_loc);
    System.err.println("vertices0: " + vertices0);
    vertices0.enableBuffer(gl, false);
    Assert.assertEquals(vertices0_loc, vertices0.getLocation());
    st.ownAttribute(vertices0, true);

    // Allocate Color Array0
    final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, colors0_loc);
    System.err.println("colors0: " + colors0);
    colors0.enableBuffer(gl, false);
    Assert.assertEquals(colors0_loc, colors0.getLocation());
    st.ownAttribute(colors0, true);

    Assert.assertTrue(sp.link(gl, System.err));
    Assert.assertTrue(sp.linked());
    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());

    Assert.assertEquals(vertices0_loc, vertices0.getLocation());
    GLSLMiscHelper.validateGLArrayDataServerState(gl, st, vertices0);

    Assert.assertEquals(colors0_loc, colors0.getLocation());
    GLSLMiscHelper.validateGLArrayDataServerState(gl, st, colors0);

    Assert.assertEquals(null, ShaderState.getShaderState(gl));
    st.useProgram(gl, true);
    Assert.assertTrue(sp.inUse());
    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
    Assert.assertEquals(st, ShaderState.getShaderState(gl));

    // setup mgl_PMVMatrix
    final PMVMatrix pmvMatrix = new PMVMatrix();
    final GLUniformData pmvMatrixUniform =
        new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
    st.ownUniform(pmvMatrixUniform);

    st.uniform(gl, pmvMatrixUniform);
    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());
    Assert.assertEquals(pmvMatrixUniform, st.getUniform("mgl_PMVMatrix"));

    // Allocate Vertex Array1
    final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st);
    System.err.println("vertices1: " + vertices1);
    vertices1.enableBuffer(gl, false);
    GLSLMiscHelper.validateGLArrayDataServerState(gl, st, vertices1);
    st.ownAttribute(vertices1, true);

    // Allocate Color Array1
    final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl, st);
    System.err.println("colors1: " + colors1);
    colors1.enableBuffer(gl, false);
    GLSLMiscHelper.validateGLArrayDataServerState(gl, st, colors1);
    st.ownAttribute(colors0, true);

    // misc GL setup
    gl.glClearColor(0, 0, 0, 1);
    gl.glEnable(GL2ES2.GL_DEPTH_TEST);
    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());

    // reshape
    pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
    pmvMatrix.glLoadIdentity();
    pmvMatrix.gluPerspective(
        45.0F, (float) drawable.getWidth() / (float) drawable.getHeight(), 1.0F, 100.0F);
    pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW);
    pmvMatrix.glLoadIdentity();
    pmvMatrix.glTranslatef(0, 0, -10);
    st.uniform(gl, pmvMatrixUniform);
    gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());
    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());

    // display #1 vertices0 / colors0 (post-disable)
    GLSLMiscHelper.displayVCArrays(
        drawable, gl, st, true, vertices0, colors0, true, 1, durationPerTest);

    // display #2 #1 vertices1 / colors1 (post-disable)
    GLSLMiscHelper.displayVCArrays(
        drawable, gl, st, true, vertices1, colors1, true, 2, durationPerTest);

    // display #3 vertices0 / colors0 (post-disable)
    GLSLMiscHelper.displayVCArrays(
        drawable, gl, st, true, vertices0, colors0, true, 3, durationPerTest);

    // cleanup
    st.destroy(gl);

    NEWTGLContext.destroyWindow(winctx);
  }
  @Test(timeout = 120000)
  public void testShaderState01PerformanceDouble() throws InterruptedException {
    // preset ..
    final NEWTGLContext.WindowContext winctx =
        NEWTGLContext.createOnscreenWindow(GLProfile.getGL2ES2(), 480, 480, false);
    final GLDrawable drawable = winctx.context.getGLDrawable();
    final GL2ES2 gl = winctx.context.getGL().getGL2ES2();
    System.err.println(winctx.context);
    gl.setSwapInterval(0);

    Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError());

    // test code ..
    final ShaderState st = new ShaderState();

    final ShaderCode rsVp =
        ShaderCode.create(
            gl,
            GL2ES2.GL_VERTEX_SHADER,
            1,
            RedSquare0.class,
            "shader",
            "shader/bin",
            "RedSquareShader");
    final ShaderCode rsFp =
        ShaderCode.create(
            gl,
            GL2ES2.GL_FRAGMENT_SHADER,
            1,
            RedSquare0.class,
            "shader",
            "shader/bin",
            "RedSquareShader");

    final ShaderProgram sp = new ShaderProgram();
    sp.add(rsVp);
    sp.add(rsFp);

    sp.init(gl);
    Assert.assertTrue(sp.link(gl, System.err));

    st.attachShaderProgram(gl, sp);
    st.useProgram(gl, true);

    // setup mgl_PMVMatrix
    final PMVMatrix pmvMatrix = new PMVMatrix();
    final GLUniformData pmvMatrixUniform =
        new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf());
    st.ownUniform(pmvMatrixUniform);
    st.uniform(gl, pmvMatrixUniform);

    // Allocate Vertex Array0
    final GLArrayDataServer vertices0 = GLSLMiscHelper.createRSVertices0(gl, st, -1);
    st.ownAttribute(vertices0, true);
    vertices0.enableBuffer(gl, false);

    // Allocate Vertex Array1
    final GLArrayDataServer vertices1 = GLSLMiscHelper.createRSVertices1(gl, st);
    st.ownAttribute(vertices1, true);
    vertices1.enableBuffer(gl, false);

    // Allocate Color Array0
    final GLArrayDataServer colors0 = GLSLMiscHelper.createRSColors0(gl, st, -1);
    st.ownAttribute(colors0, true);
    colors0.enableBuffer(gl, false);

    // Allocate Color Array1
    final GLArrayDataServer colors1 = GLSLMiscHelper.createRSColors1(gl, st);
    st.ownAttribute(colors1, true);
    colors1.enableBuffer(gl, false);

    // misc GL setup
    gl.glClearColor(0, 0, 0, 1);
    gl.glEnable(GL2ES2.GL_DEPTH_TEST);

    // reshape
    pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION);
    pmvMatrix.glLoadIdentity();
    pmvMatrix.gluPerspective(
        45.0F, (float) drawable.getWidth() / (float) drawable.getHeight(), 1.0F, 100.0F);
    pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW);
    pmvMatrix.glLoadIdentity();
    pmvMatrix.glTranslatef(0, 0, -10);
    st.uniform(gl, pmvMatrixUniform);
    gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight());

    gl.setSwapInterval(0);

    // validation ..
    GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices0, colors0, true, 1, 0);
    GLSLMiscHelper.displayVCArrays(drawable, gl, st, true, vertices1, colors1, true, 2, 0);

    // warmup ..
    for (int frames = 0; frames < GLSLMiscHelper.frames_warmup; frames += 2) {
      GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true);
      GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true);
    }

    // measure ..
    long t0 = System.currentTimeMillis();
    int frames;

    for (frames = 0; frames < GLSLMiscHelper.frames_perftest; frames += 2) {
      GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices0, colors0, true);
      GLSLMiscHelper.displayVCArraysNoChecks(drawable, gl, true, vertices1, colors1, true);
    }
    final long t1 = System.currentTimeMillis();
    final long dt = t1 - t0;
    final double fps = (frames * 1000.0) / (double) dt;
    final String fpsS = String.valueOf(fps);
    final int fpsSp = fpsS.indexOf('.');
    System.err.println(
        "testShaderState01PerformanceDouble: "
            + dt / 1000.0
            + "s: "
            + frames
            + "f, "
            + fpsS.substring(0, fpsSp + 2)
            + " fps, "
            + dt / frames
            + " ms/f");

    // cleanup
    st.destroy(gl);

    NEWTGLContext.destroyWindow(winctx);
  }
  public void testImpl(final boolean keepTextureBound, final int texUnit)
      throws InterruptedException, IOException {
    final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false);
    GLProfile glp;
    if (GLProfile.isAvailable(GLProfile.GL2ES2)) {
      glp = GLProfile.getGL2ES2();
    } else {
      System.err.println(getSimpleTestName(".") + ": GLProfile n/a");
      return;
    }
    final GLCapabilities caps = new GLCapabilities(glp);

    final GLJPanel glc = new GLJPanel(caps);
    // final GLCanvas glc = new GLCanvas(caps);
    final Dimension glc_sz = new Dimension(640, 480);
    final Dimension glc_sz2 = new Dimension(800, 400);
    glc.setMinimumSize(glc_sz);
    glc.setPreferredSize(glc_sz);
    final JFrame frame = new JFrame("TestGLJPanelTextureStateAWT");
    Assert.assertNotNull(frame);
    frame.getContentPane().add(glc);

    final GLEventListener gle0;
    {
      final GearsES2 gle0sub = new GearsES2(0);
      // gle1sub.setClearBuffers(false);
      final TextureDraw02ES2ListenerFBO demo = new TextureDraw02ES2ListenerFBO(gle0sub, 1, texUnit);
      demo.setKeepTextureBound(keepTextureBound);
      demo.setClearBuffers(false);
      gle0 = demo;
    }

    final GLEventListener gle1;
    {
      final RedSquareES2 demo = new RedSquareES2(1);
      demo.setClearBuffers(false);
      gle1 = demo;
    }

    final boolean[] glelError = {false};

    glc.addGLEventListener(
        new GLEventListener() {
          int gle0X, gle0Y, gle0W, gle0H;
          int gle1X, gle1Y, gle1W, gle1H;
          int tX, tY, tW, tH;
          int shot = 0;

          void setupTex(GL gl) {
            // Note: FBObject uses diff defaults, i.e.: GL_NEAREST and GL_CLAMP_TO_EDGE
            if (keepTextureBound) {
              gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
              gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
              gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
              gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
            }
          }

          @Override
          public void init(GLAutoDrawable drawable) {
            // Initialize w/ arbitrary values !
            GL2ES2 gl = drawable.getGL().getGL2ES2();
            gl.glActiveTexture(GL.GL_TEXTURE0 + 1);
            gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
            gl.glActiveTexture(GL.GL_TEXTURE0 + 0);
            gl.glBindTexture(GL.GL_TEXTURE_2D, 0);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
            gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);

            gle0.init(drawable);
            gle1.init(drawable);
            setupTex(gl);
          }

          @Override
          public void dispose(GLAutoDrawable drawable) {
            gle0.dispose(drawable);
            gle1.dispose(drawable);
          }

          @Override
          public void display(GLAutoDrawable drawable) {
            GL2ES2 gl = drawable.getGL().getGL2ES2();

            gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            // test viewport
            {
              final int[] viewport = new int[] {0, 0, 0, 0};
              gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0);
              if (gle1X != viewport[0]
                  || gle1Y != viewport[1]
                  || gle1W != viewport[2]
                  || gle1H != viewport[3]) {
                final String msg =
                    "Expected "
                        + gle1X
                        + "/"
                        + gle1Y
                        + " "
                        + gle1W
                        + "x"
                        + gle1H
                        + ", actual "
                        + viewport[0]
                        + "/"
                        + viewport[1]
                        + " "
                        + viewport[2]
                        + "x"
                        + viewport[3];
                Assert.assertTrue("Viewport not restored: " + msg, false);
                glelError[0] = true;
              }
            }

            gl.glViewport(gle0X, gle0Y, gle0W, gle0H);
            gle0.display(drawable);

            gl.glViewport(gle1X, gle1Y, gle1W, gle1H);
            gle1.display(drawable);

            shot++;
            if (4 == shot) {
              gl.glViewport(tX, tY, tW, tH);
              snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null);
              gl.glViewport(gle1X, gle1Y, gle1W, gle1H); // restore viewport test
            }

            final TextureState ts =
                new TextureState(drawable.getGL(), GL.GL_TEXTURE_2D); // as set via gle0!
            // System.err.println("XXX: "+ts);
            Assert.assertEquals("Texture unit changed", GL.GL_TEXTURE0 + texUnit, ts.getUnit());
            if (keepTextureBound) {
              Assert.assertEquals(
                  "Texture mag-filter changed: " + ts, GL.GL_LINEAR, ts.getMagFilter());
              Assert.assertEquals(
                  "Texture mag-filter changed: " + ts, GL.GL_LINEAR, ts.getMinFilter());
              Assert.assertEquals("Texture wrap-s changed: " + ts, GL.GL_REPEAT, ts.getWrapS());
              Assert.assertEquals("Texture wrap-t changed: " + ts, GL.GL_REPEAT, ts.getWrapT());
              glelError[0] =
                  GL.GL_LINEAR != ts.getMagFilter()
                      || GL.GL_LINEAR != ts.getMinFilter()
                      || GL.GL_REPEAT != ts.getWrapS()
                      || GL.GL_REPEAT != ts.getWrapT();
            }
          }

          final int border = 5;

          @Override
          public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
            gle0X = x + border;
            gle0Y = y;
            gle0W = width / 2 - 2 * border;
            gle0H = height;
            // System.err.println("GLEL0 "+gle0X+"/"+gle0Y+" "+gle0W+"x"+gle0H);

            gle1X = gle0X + gle0W + 2 * border;
            gle1Y = y;
            gle1W = width / 2 - 2 * border;
            gle1H = height;
            // System.err.println("GLEL1 "+gle1X+"/"+gle1Y+" "+gle1W+"x"+gle1H);

            tX = x;
            tY = y;
            tW = width;
            tH = height;
            // System.err.println("Total "+tX+"/"+tY+" "+tW+"x"+tH);

            GL2ES2 gl = drawable.getGL().getGL2ES2();
            gl.glViewport(gle0X, gle0Y, gle0W, gle0H);
            gle0.reshape(drawable, 0, 0, gle0W, gle0H); // don't 'skip' about gle0X/gle0Y

            gl.glViewport(gle1X, gle1Y, gle1W, gle1H);
            gle1.reshape(drawable, 0, 0, gle1W, gle1H); // don't 'skip' about gle0X/gle0Y

            if (keepTextureBound) {
              setupTex(gl);
            }
          }
        });

    final QuitAdapter quitAdapter = new QuitAdapter();
    new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter, glc).addTo(glc);
    new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter, glc).addTo(glc);
    try {
      javax.swing.SwingUtilities.invokeAndWait(
          new Runnable() {
            public void run() {
              frame.pack();
              frame.setVisible(true);
            }
          });
    } catch (Throwable throwable) {
      throwable.printStackTrace();
      Assume.assumeNoException(throwable);
    }
    Assert.assertTrue("Component didn't become visible", AWTRobotUtil.waitForVisible(glc, true));
    Assert.assertTrue("Component didn't become realized", AWTRobotUtil.waitForRealized(glc, true));
    Thread.sleep(100);
    setFrameSize(frame, true, glc_sz2);
    System.err.println(
        "window resize pos/siz: "
            + glc.getX()
            + "/"
            + glc.getY()
            + " "
            + glc.getSurfaceWidth()
            + "x"
            + glc.getSurfaceHeight());
    Thread.sleep(100);

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

    try {
      javax.swing.SwingUtilities.invokeAndWait(
          new Runnable() {
            public void run() {
              frame.setVisible(false);
              frame.remove(glc);
              frame.dispose();
            }
          });
    } catch (Throwable throwable) {
      throwable.printStackTrace();
      Assume.assumeNoException(throwable);
    }
    Assume.assumeFalse("Error occured in GLEL .. see log file above", glelError[0]);
  }