Example usage for org.lwjgl.opengl GL11 glVertex2d

List of usage examples for org.lwjgl.opengl GL11 glVertex2d

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glVertex2d.

Prototype

public static native void glVertex2d(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y);

Source Link

Document

Double version of #glVertex2f Vertex2f .

Usage

From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java

License:Open Source License

/**
 * Draws the collection of points based on the current geometric primitive and fill it.
 * //from   w  w  w.j av a2 s .c o  m
 * @param points
 *            Points in the model coordinate system
 * @throws NullArgumentException
 *             Thrown if points is null
 */
public void drawFromModel(List<Point> points) throws NullArgumentException {

    if (points == null) {
        throw new NullArgumentException();
    }
    GL11.glBegin(primitiveType);
    for (Point point : points) {
        try {
            Point convertedPoint = br.org.archimedes.Utils.getWorkspace().modelToScreen(point);
            GL11.glVertex2d(convertedPoint.getX(), convertedPoint.getY());
        } catch (NullArgumentException e) {
            // Should never reach this block.
            e.printStackTrace();
        }
    }
    GL11.glEnd();
}

From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java

License:Open Source License

/**
 * Draws the collection of points based on the current geometric primitive.
 * /*from w  ww.  j  a  v a  2  s . com*/
 * @param points
 *            Points in the model coordinate system
 */
public void drawFromModel(Point... points) {

    GL11.glBegin(primitiveType);
    for (Point point : points) {
        try {
            Point convertedPoint = br.org.archimedes.Utils.getWorkspace().modelToScreen(point);
            GL11.glVertex2d(convertedPoint.getX(), convertedPoint.getY());
        } catch (NullArgumentException e) {
            // Ignores if the list contains a null point
            e.printStackTrace();
        }
    }
    GL11.glEnd();
}

From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java

License:Open Source License

/**
 * Draws the collection of points based on the current geometric primitive.
 * //from  w  w w  . j  ava  2s .  c o  m
 * @param points
 *            Points in the screen coordinate system
 * @throws NullArgumentException
 *             Thrown if points is null
 */
public void draw(List<Point> points) throws NullArgumentException {

    if (points == null) {
        throw new NullArgumentException();
    }

    GL11.glBegin(primitiveType);
    for (Point point : points) {
        GL11.glVertex2d(point.getX(), point.getY());
    }
    GL11.glEnd();
}

From source file:br.org.archimedes.gui.opengl.OpenGLWrapper.java

License:Open Source License

/**
 * @param points/*from  w  w w. j  av  a 2  s.  c om*/
 *            The list of points to be drawed.
 */
public void draw(Point... points) {

    GL11.glBegin(primitiveType);
    for (Point point : points) {
        GL11.glVertex2d(point.getX(), point.getY());
    }
    GL11.glEnd();
}

From source file:com.breckinloggins.DrawUtils.java

License:Open Source License

public static void drawCircle(int x, int y, int radius) {
    GL11.glBegin(GL11.GL_LINE_LOOP);//from  w  ww.  j a  v  a  2s .co m

    for (int angle = 0; angle <= 360; angle += 5) {
        double rad = Math.toRadians(angle);
        GL11.glVertex2d(x + Math.sin(rad) * radius, y + Math.cos(rad) * radius);
    }

    GL11.glEnd();

}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawBorderedRect(double x, double y, double x2, double y2, float l1, int col1, int col2) {
    drawRect((float) x, (float) y, (float) x2, (float) y2, col2);

    float f = (float) (col1 >> 24 & 0xFF) / 255F;
    float f1 = (float) (col1 >> 16 & 0xFF) / 255F;
    float f2 = (float) (col1 >> 8 & 0xFF) / 255F;
    float f3 = (float) (col1 & 0xFF) / 255F;
    GL11.glPushMatrix();//from   w w  w  .  j  a v  a  2  s . c o  m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    GL11.glColor4f(f1, f2, f3, f);
    GL11.glLineWidth(l1);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glPopMatrix();
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawRect(float paramXStart, float paramYStart, float paramXEnd, float paramYEnd,
        int paramColor) {
    float alpha = (float) (paramColor >> 24 & 0xFF) / 255F;
    float red = (float) (paramColor >> 16 & 0xFF) / 255F;
    float green = (float) (paramColor >> 8 & 0xFF) / 255F;
    float blue = (float) (paramColor & 0xFF) / 255F;
    GL11.glPushMatrix();// w ww .j a  v a2 s  .c o  m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    GL11.glColor4f(red, green, blue, alpha);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2d(paramXEnd, paramYStart);
    GL11.glVertex2d(paramXStart, paramYStart);
    GL11.glVertex2d(paramXStart, paramYEnd);
    GL11.glVertex2d(paramXEnd, paramYEnd);
    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glPopMatrix();
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawGradientRect(double x, double y, double x2, double y2, int col1, int col2) {
    float f = (float) (col1 >> 24 & 0xFF) / 255F;
    float f1 = (float) (col1 >> 16 & 0xFF) / 255F;
    float f2 = (float) (col1 >> 8 & 0xFF) / 255F;
    float f3 = (float) (col1 & 0xFF) / 255F;

    float f4 = (float) (col2 >> 24 & 0xFF) / 255F;
    float f5 = (float) (col2 >> 16 & 0xFF) / 255F;
    float f6 = (float) (col2 >> 8 & 0xFF) / 255F;
    float f7 = (float) (col2 & 0xFF) / 255F;

    GL11.glEnable(GL11.GL_BLEND);/*from  w ww.j a va 2  s  .c  o m*/
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glShadeModel(GL11.GL_SMOOTH);

    GL11.glPushMatrix();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y);

    GL11.glColor4f(f5, f6, f7, f4);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glShadeModel(GL11.GL_FLAT);
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawGradientBorderedRect(double x, double y, double x2, double y2, float l1, int col1,
        int col2, int col3) {
    float f = (float) (col1 >> 24 & 0xFF) / 255F;
    float f1 = (float) (col1 >> 16 & 0xFF) / 255F;
    float f2 = (float) (col1 >> 8 & 0xFF) / 255F;
    float f3 = (float) (col1 & 0xFF) / 255F;

    GL11.glDisable(GL11.GL_TEXTURE_2D);// w  ww .j a  v  a  2 s.c  o  m
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glDisable(GL11.GL_BLEND);

    GL11.glPushMatrix();
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glLineWidth(1F);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();
    GL11.glPopMatrix();

    drawGradientRect(x, y, x2, y2, col2, col3);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawFullCircle(int cx, int cy, double r, int c) {
    GL11.glScalef(0.5F, 0.5F, 0.5F);//  ww  w  .j  a  va  2s . c  o m
    r *= 2;
    cx *= 2;
    cy *= 2;
    float f = (float) (c >> 24 & 0xff) / 255F;
    float f1 = (float) (c >> 16 & 0xff) / 255F;
    float f2 = (float) (c >> 8 & 0xff) / 255F;
    float f3 = (float) (c & 0xff) / 255F;
    GL11.glEnable(3042);
    GL11.glDisable(3553);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glBlendFunc(770, 771);
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    for (int i = 0; i <= 360; i++) {
        double x = Math.sin((i * Math.PI / 180)) * r;
        double y = Math.cos((i * Math.PI / 180)) * r;
        GL11.glVertex2d(cx + x, cy + y);
    }
    GL11.glEnd();
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glEnable(3553);
    GL11.glDisable(3042);
    GL11.glScalef(2F, 2F, 2F);
}