Example usage for org.lwjgl.opengl GL11 glVertex3f

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

Introduction

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

Prototype

public static native void glVertex3f(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y,
        @NativeType("GLfloat") float z);

Source Link

Document

Specifies a single vertex between #glBegin Begin and #glEnd End by giving its coordinates in three dimensions.

Usage

From source file:DrawShapes.java

public static void fillRectangle(float x, float y, float width, float height) {
    GL11.glBegin(GL11.GL_QUADS);//from  w w  w.  j  a va2  s .c  o  m
    GL11.glVertex3f(x, y, 0);
    GL11.glVertex3f(x + width, y, 0);
    GL11.glVertex3f(x + width, y + height, 0);
    GL11.glVertex3f(x, y + height, 0);
    GL11.glEnd();
}

From source file:DrawShapes.java

public static void strokeRectangle(float x, float y, float width, float height) {
    GL11.glBegin(GL11.GL_LINE_LOOP);// ww w .  j a  va2 s .  c  om
    GL11.glVertex3f(x, y, 0);
    GL11.glVertex3f(x + width, y, 0);
    GL11.glVertex3f(x + width, y + height, 0);
    GL11.glVertex3f(x, y + height, 0);
    GL11.glEnd();
}

From source file:DrawShapes.java

public static void strokeCircle(float radius, int sides) {
    float dtheta = (float) Math.PI * 2 / sides;
    GL11.glBegin(GL11.GL_LINES);//  w w  w .  ja  v a2  s .  c  om
    for (int i = 0; i < sides; i++) {
        float x0, y0;
        float x1, y1;
        x0 = radius * (float) Math.cos(i * dtheta);
        y0 = radius * (float) Math.sin(i * dtheta);
        x1 = radius * (float) Math.cos((i + 1) * dtheta);
        y1 = radius * (float) Math.sin((i + 1) * dtheta);

        GL11.glVertex3f(x0, y0, 0);
        GL11.glVertex3f(x1, y1, 0);
    }
    GL11.glEnd();
}

From source file:DrawShapes.java

public static void fillCircle(float radius, int sides) {
    float dtheta = (float) Math.PI * 2 / sides;
    GL11.glBegin(GL11.GL_TRIANGLES);/*  w  w w .j a  va2 s.c  o  m*/
    for (int i = 0; i < sides; i++) {
        float x0, y0;
        float x1, y1;
        x0 = radius * (float) Math.cos(i * dtheta);
        y0 = radius * (float) Math.sin(i * dtheta);
        x1 = radius * (float) Math.cos((i + 1) * dtheta);
        y1 = radius * (float) Math.sin((i + 1) * dtheta);

        GL11.glVertex3f(0, 0, 0);
        GL11.glVertex3f(x0, y0, 0);
        GL11.glVertex3f(x1, y1, 0);
    }
    GL11.glEnd();
}

From source file:adrianton.gloptat.plotter.Pointer.java

License:Open Source License

static void assemble() {
    final float tmpm = 1;
    final float tmpm2 = 1 / 3;
    final float tmpm3 = 7;

    handle = GL11.glGenLists(1);/*from w  w w. j a va  2 s  .  c om*/
    GL11.glNewList(handle, GL11.GL_COMPILE);

    GL11.glBegin(GL11.GL_TRIANGLES);
    GL11.glColor3f(1, 1, 1);

    GL11.glVertex3f(0, 0, tmpm2);
    GL11.glVertex3f(-tmpm, -tmpm, tmpm3);
    GL11.glVertex3f(-tmpm, tmpm, tmpm3);

    GL11.glVertex3f(0, 0, tmpm2);
    GL11.glVertex3f(-tmpm, tmpm, tmpm3);
    GL11.glVertex3f(tmpm, tmpm, tmpm3);

    GL11.glVertex3f(0, 0, tmpm2);
    GL11.glVertex3f(tmpm, tmpm, tmpm3);
    GL11.glVertex3f(tmpm, -tmpm, tmpm3);

    GL11.glVertex3f(0, 0, tmpm2);
    GL11.glVertex3f(tmpm, -tmpm, tmpm3);
    GL11.glVertex3f(-tmpm, -tmpm, tmpm3);
    GL11.glEnd();

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(tmpm, tmpm, tmpm3);
    GL11.glVertex3f(tmpm, -tmpm, tmpm3);
    GL11.glVertex3f(-tmpm, -tmpm, tmpm3);
    GL11.glVertex3f(-tmpm, tmpm, tmpm3);
    GL11.glEnd();

    GL11.glEndList();
}

From source file:adrianton.gloptat.plotter.Surface.java

License:Open Source License

public static void assemble(Displayer outer) {
    int i, j;//w ww.  j a va2  s  .  com
    float px, py;
    float z1, z2, z3, z4;
    float tmp;

    Color col;

    float spx = -outer.rezx / 2;
    float spy = -outer.rezy / 2;

    handle = GL11.glGenLists(1);
    GL11.glNewList(handle, GL11.GL_COMPILE);

    GL11.glBegin(GL11.GL_QUADS);

    px = spx;
    for (i = 0; i < outer.rezx - 1; i++) {
        py = spy;
        for (j = 0; j < outer.rezy - 1; j++) {
            z1 = (float) outer.val[i][j];
            z2 = (float) outer.val[i + 1][j];
            z3 = (float) outer.val[i][j + 1];
            z4 = (float) outer.val[i + 1][j + 1];

            tmp = (float) (1 - ((outer.val[i][j] - outer.minc) / (outer.maxc - outer.minc)));
            tmp = tmp * 66 / 100 + 34 / 100;
            col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f));
            GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f),
                    (float) (col.getBlue() / 255f));

            GL11.glVertex3f(px, py, z1);

            tmp = (float) (1 - ((outer.val[i][j + 1] - outer.minc) / (outer.maxc - outer.minc)));
            tmp = tmp * 66 / 100 + 34 / 100;
            col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f));
            GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f),
                    (float) (col.getBlue() / 255f));

            GL11.glVertex3f(px, py + 1, z3);

            tmp = (float) (1 - ((outer.val[i + 1][j + 1] - outer.minc) / (outer.maxc - outer.minc)));
            tmp = tmp * 66 / 100 + 34 / 100;
            col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f));
            GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f),
                    (float) (col.getBlue() / 255f));

            GL11.glVertex3f(px + 1, py + 1, z4);

            tmp = (float) (1 - ((outer.val[i + 1][j] - outer.minc) / (outer.maxc - outer.minc)));
            tmp = tmp * 66 / 100 + 34 / 100;
            col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f));
            GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f),
                    (float) (col.getBlue() / 255f));

            GL11.glVertex3f(px + 1, py, z2);

            py += 1;
        }
        px += 1;
    }

    GL11.glEnd();
    GL11.glEndList();
}

From source file:analog.clock.AnalogClock.java

private void drawCircle(double r, int n) {
    GL11.glColor3f(1.0f, 1.0f, 0.0f);// w  w w. j ava2  s  .  c  om
    double theta = 2 * Math.PI / n;
    GL11.glPushMatrix();
    GL11.glBegin(GL11.GL_LINES);
    for (int i = 0; i < n;) {
        //GL11.glVertex3f(0, 0, 0);
        float x = (float) (r * Math.cos(theta * i));
        float y = (float) (r * Math.sin(theta * i));
        GL11.glVertex3f(x, y, 0);
        i++;
        x = (float) (r * Math.cos(theta * i));
        y = (float) (r * Math.sin(theta * i));
        GL11.glVertex3f(x, y, 0);
    }
    GL11.glEnd();
    GL11.glPopMatrix();
}

From source file:buildcraft.core.lib.client.render.RenderUtils.java

License:Minecraft Mod Public

public static void vertex3f(Vector3f vec) {
    GL11.glVertex3f(vec.x, vec.y, vec.z);
}

From source file:cellSim2.GradientWall.java

License:Open Source License

public boolean specialRender(IGL gl, Transform t) {
    if (grad == null) {
        return false;
    }/*from   w ww  . j  a  v a2s . c om*/

    //get the time 
    long ti = sim.getCurrentTimeMicroseconds();
    int axis = grad.getAxis();

    float[] wallSize = new float[3];
    getSize().get(wallSize);
    float blockSize = wallSize[axis] / (float) drawnSegments;

    float[] diagonal = new float[3];
    switch (axis) {
    case 0:
        diagonal[0] = -blockSize;
        diagonal[1] = -wallSize[1];//height
        diagonal[2] = 0;
        break;
    case 1:
        diagonal[0] = wallSize[0];//width
        diagonal[1] = blockSize;
        diagonal[2] = 0;
        break;
    case 2:
        diagonal[0] = 0;
        diagonal[1] = wallSize[1];
        diagonal[2] = blockSize;
        break;
    }
    Vector3f diagonalVector = new Vector3f(diagonal);
    //System.out.println(diagonalVector);

    float[] nextPos = new float[] { 0f, 0f, 0f };
    nextPos[axis] = blockSize;
    Vector3f nextPositionVector = new Vector3f(nextPos);
    //System.out.println(nextPositionVector);

    float[] dist = new float[] { 0f, 0f, 0f };
    dist[axis] = distanceFromSource;
    Vector3f distVector = new Vector3f(dist);

    gl.glPushMatrix();

    t.getOpenGLMatrix(glMat);
    gl.glMultMatrix(glMat);
    GL11.glNormal3f(0f, 0f, -1f);
    Vector3f vecOne = new Vector3f(startPoint);
    Vector3f vecTwo = new Vector3f(vecOne);
    vecTwo.add(diagonalVector);
    for (int i = 0; i < drawnSegments; i++) {
        //Find the concentration at this time and position
        //System.out.println("VecOne: " + vecOne + " VecTwo: " + vecTwo);
        Vector3f gradPos = new Vector3f();
        gradPos.add(vecOne, distVector);
        float[] color = grad.getColor(grad.getConcentration(ti, gradPos));
        GL11.glColor3f(color[0], color[1], color[2]);
        GL11.glBegin(GL11.GL_QUADS);
        //System.out.println(i + "ri: " + ri + " le: " + le + " con: " + con + " mi: " + mi);
        GL11.glVertex3f(vecOne.x, vecOne.y, vecOne.z);
        GL11.glVertex3f(vecTwo.x, vecOne.y, vecTwo.z);
        GL11.glVertex3f(vecTwo.x, vecTwo.y, vecTwo.z);
        GL11.glVertex3f(vecOne.x, vecTwo.y, vecOne.z);
        GL11.glEnd();
        vecOne.add(nextPositionVector);
        vecTwo.add(vecOne, diagonalVector);
        //System.out.println(startPoint + ", " + vecOne + ", " +addOnVector +", "+ vecTwo);
    }
    gl.glPopMatrix();

    return true;
    //return false;
}

From source file:com.a2client.corex.Skeleton.java

License:Open Source License

public void draw_bones() {
    for (int i = 0; i < joint.length; i++) {
        updateJoint(i);/*  www  .  j ava  2  s  . c o  m*/
        if (data.base[i].parent != -1 && joint[i] != null) {
            Vec3f p1 = joint[i].pos();
            Vec3f p2 = joint[data.base[i].parent].pos();

            GL11.glBegin(GL11.GL_LINES);
            GL11.glVertex3f(p1.x, p1.y, p1.z);
            GL11.glVertex3f(p2.x, p2.y, p2.z);
            GL11.glEnd();
        }
    }
}