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