コード例 #1
0
ファイル: Portal.java プロジェクト: ChaplinWang/Graphics
  /** paint the portal using gl. */
  public void paint(GL gl, GLDrawable glc) {

    if (fill != null) {
      setColor(gl, fill);
      gl.glDisable(GL.GL_TEXTURE_2D);
    }
    gl.glLineWidth(lineWidth());
    gl.glBegin(GL.GL_LINES); // draw each wall
    for (int i = 0; i < pts2d.size(); i++) {
      Point2D p = (Point2D) (pts2d.get(i));
      gl.glVertex2d(p.x, p.y);
    }
    gl.glEnd();

    if (pts2d.size() == 4) {
      /* Connect mid point of the two line segments with dotted line*/
      gl.glLineStipple(1, (short) 0x0F0F);
      gl.glEnable(GL.GL_LINE_STIPPLE);
      gl.glLineWidth(1);
      gl.glBegin(GL.GL_LINES);
      Point2D mid = pts2d.get(0).interp(pts2d.get(1), 0.5);
      gl.glVertex2d(mid.x, mid.y);
      mid = pts2d.get(2).interp(pts2d.get(3), 0.5);
      gl.glVertex2d(mid.x, mid.y);
      gl.glEnd();
      gl.glDisable(GL.GL_LINE_STIPPLE);
    }
  }
コード例 #2
0
 public void init(GLAutoDrawable drawable) {
   GL gl = drawable.getGL();
   gl.glMatrixMode(GL.GL_PROJECTION);
   gl.glLoadMatrixd(this._nyar.getGlProjectionMatrix(), 0);
   gl.glEnable(GL.GL_DEPTH_TEST);
   gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   Animator animator = new Animator(drawable);
   animator.start();
   return;
 }