draw Quad Fan opengl - Java javax.media.opengl

Java examples for javax.media.opengl:GL

Description

draw Quad Fan opengl

Demo Code


import javax.media.opengl.GL2;

public class Main{
    public static void drawQuadFan(GL2 gl2, double x, double y, double z,
            double w, double h, float c1[], float c2[]) {
        gl2.glBegin(GL2.GL_TRIANGLE_FAN);
        if (c1 != null)
            gl2.glColor4fv(c1, 0);//from   ww w. jav a  2s  .  c  om
        gl2.glVertex3d(x, y, z); // center

        if (c2 != null)
            gl2.glColor4fv(c2, 0);
        gl2.glVertex3d(x - w, y - h, z); // lower left
        gl2.glVertex3d(x + w, y - h, z); // lower right
        gl2.glVertex3d(x + w, y + h, z); // upper right
        gl2.glVertex3d(x - w, y + h, z); // upper left

        gl2.glVertex3d(x - w, y - h, z); // bring it back
        gl2.glEnd();
    }
    public static void drawQuadFan(GL2 gl2, double x, double y, double z,
            double w, double h) {
        drawQuadFan(gl2, x, y, z, w, h, null, null);
    }
}

Related Tutorials