Example #1
0
  private void doDrawPolygon(Polygon polygon, int glMode) {
    if (glMode == GL.GL_LINES) {
      doDrawLines(polygon.getVertices());
    } else {
      Iterator<Vector> vertices = polygon.getVertices();

      Iterator<Vector> texCoords = null;
      if (textureCoords != null) texCoords = textureCoords.getVertices();

      gl.glBegin(glMode);

      for (vertices.reset();
          !vertices.isDone() && (currentTexture == null || !texCoords.isDone());
          vertices.advance()) {
        Vector v = vertices.current();

        if (currentTexture != null) {
          Vector texCoord = texCoords.current();
          texCoords.advance();

          double y = texCoord.getY();
          if (currentTexture.getMustFlipVertically()) {
            y =
                currentTexture.getImageTexCoords().top()
                    - y
                    + currentTexture.getImageTexCoords().bottom();
          }
          gl.glTexCoord2d(texCoord.getX(), y);
        }

        double x = scaleX * (brushPos.getX() + v.getX());
        double y = scaleY * (brushPos.getY() + v.getY());

        gl.glVertex3d(x, y, brushPos.getZ());
      }
      gl.glEnd();
    }
  }
Example #2
0
 public void drawPolygon(Polygon polygon) {
   switch (polygon.getVertexCount()) {
     case 2:
       doDrawPolygon(polygon, GL.GL_LINES);
       break;
     case 3:
       doDrawPolygon(polygon, GL.GL_TRIANGLES);
       break;
     case 4:
       doDrawPolygon(polygon, GL.GL_QUADS);
       break;
     default:
       doDrawPolygon(polygon, GL.GL_POLYGON);
       break;
   }
 }