Search code examples
javaswingawtdrawingpolygon

Draw image as a polygon


I'm trying to draw an image as a polygon in Swing but I don't know how. Now I only have code to draw filled polygon. This is not a cropped image, it is distorted.

What I need (Polygon with texture):

Polygon with texture

What I have - Filled polygon

Filled Polygon

gr.fillPolygon(x_points, y_points, points.length);

Solution

  • The easiest way to render 3D is using JOGL library which uses OpenGL to render in JPanel.