@Override
  public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();

    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();

    // to position the camera.

    gl.glTranslated(0, 0, -1);

    // Forgetting to clear the depth buffer can cause problems
    // such as empty black screens.
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    float matAmbAndDifR[] = {0.9f, 0.0f, 0.0f, 0.75f};
    float matAmbAndDifG[] = {0.0f, 0.5f, 0.0f, 1.0f};

    gl.glBegin(GL2.GL_TRIANGLES);
    {

      // One in drawn first and in front has alpha
      // gl.glColor4f(1f,0f,0f,1f);
      // CCW ordering of vertices
      double p0[] = {1, 0, -1};
      double p1[] = {0, 1, -1};
      double p2[] = {-1, 0, -1};

      gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT_AND_DIFFUSE, matAmbAndDifG, 0);

      // gl.glColor4f(0,1,0,1f);
      gl.glVertex3d(2, 0, -2);
      gl.glVertex3d(1, 1, -2);
      gl.glVertex3d(0, 0, -2);

      gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE, matAmbAndDifR, 0);
      gl.glVertex3dv(p0, 0);
      gl.glVertex3dv(p1, 0);
      gl.glVertex3dv(p2, 0);
    }
    gl.glEnd();

    gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL);
  }
  @Override
  public void display(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();

    gl.glMatrixMode(GL2.GL_MODELVIEW);
    gl.glLoadIdentity();

    // Move camera back a little
    gl.glTranslated(0, 0, -1);

    // Forgetting to clear the depth buffer can cause problems
    // such as empty black screens.
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);

    gl.glBegin(GL2.GL_TRIANGLES);
    {

      // Need to draw transparent one last
      gl.glColor4f(1f, 0f, 0f, 0.75f); // try with 0.25
      // CCW ordering of vertices
      double p0[] = {1, 0, -1};
      double p1[] = {0, 1, -1};
      double p2[] = {-1, 0, -1};

      // Can pass in an array and an offset into the array
      gl.glVertex3dv(p0, 0);
      gl.glVertex3dv(p1, 0);
      gl.glVertex3dv(p2, 0);

      // Opaque one (at back) must be drawn before
      // transparent one in front
      gl.glColor4f(0, 1, 0, 1f);
      gl.glVertex3d(2, 0, -2);
      gl.glVertex3d(1, 1, -2);
      gl.glVertex3d(0, 0, -2);
    }
    gl.glEnd();
  }
 public void vertex(Object vertexData) {
   // p("vertex");
   double[] pointer;
   if (vertexData instanceof double[]) {
     pointer = (double[]) vertexData;
     // p("vd = " + pointer[0] + " " + pointer[1] + " " + pointer[2]);
     if (pointer.length == 6) {
       // p("adding color");
       gl.glColor3dv(pointer, 3);
     }
     gl.glVertex3dv(pointer, 0);
     if (targetPath != null) {
       targetPath.addPoint(pointer);
     }
   }
 }