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:com.timvisee.voxeltex.architecture.component.drawable.line.AxisDrawComponent.java

License:Open Source License

@Override
public synchronized void onDraw() {
    // Set the thickness of the axis drawn
    GL11.glLineWidth(this.lineWidth);

    // Enable line drawing mode
    GL11.glBegin(GL11.GL_LINES);/*from w ww . ja  va2 s  . c o  m*/

    // Green for X
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(1.0f, 0.0f, 0.0f);

    // Green for Y
    GL11.glColor3f(0.0f, 1.0f, 0.0f);
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(0.0f, 1.0f, 0.0f);

    // Green for Z
    GL11.glColor3f(0.0f, 0.0f, 1.0f);
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(0.0f, 0.0f, 1.0f);

    // Finish drawing
    GL11.glEnd();
}

From source file:com.timvisee.voxeltex.architecture.component.drawable.line.GridDrawComponent.java

License:Open Source License

@Override
public synchronized void onDraw() {
    // Set the thickness of the axis drawn
    GL11.glLineWidth(this.lineWidth);

    // Enable line drawing mode
    GL11.glBegin(GL11.GL_LINES);/*  w  w  w  . ja v a2  s .co m*/

    // Set the grid color
    GL11.glColor3f(0.2f, 0.2f, 0.2f);

    // Draw the grid
    for (int i = -20; i <= 20; i++) {
        GL11.glVertex3f(-20.0f, 0.0f, i);
        GL11.glVertex3f(20.0f, 0.0f, i);
        GL11.glVertex3f(i, 0.0f, -20.0f);
        GL11.glVertex3f(i, 0.0f, 20.0f);
    }

    // Finish drawing
    GL11.glEnd();
}

From source file:com.timvisee.voxeltex.module.render.RenderOverlayHelper.java

License:Open Source License

/**
 * Render a rectangle at the given position.
 *
 * @param x Rectangle X position./*from w  w w.j a  v a 2 s.co m*/
 * @param y Rectangle Y position.
 * @param w Rectangle width.
 * @param h Rectangle height.
 */
public static void renderRectangle(float x, float y, float w, float h) {
    // Enable line drawing mode
    GL11.glBegin(GL11.GL_QUADS);

    // Draw the grid
    GL11.glVertex3f(x, y, 0f);
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(x + w, y, 0f);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(x + w, y + h, 0f);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(x, y + h, 0f);
    GL11.glTexCoord2f(0, 1);

    // Finish drawing
    GL11.glEnd();
}

From source file:com.timvisee.voxeltex.module.render.RenderOverlayHelper.java

License:Open Source License

/**
 * Render a line at the given position./*  w w w. ja v a 2s . c o  m*/
 *
 * @param x Line X position.
 * @param y Line Y position.
 * @param w Line width.
 * @param h Line height.
 */
public static void renderLine(float x, float y, float w, float h) {
    // Enable line drawing mode
    GL11.glBegin(GL11.GL_LINES);

    // Draw the grid
    GL11.glVertex3f(x, y, 0f);
    GL11.glVertex3f(x + w, y + h, 0f);

    // Finish drawing
    GL11.glEnd();
}

From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java

License:Open Source License

/**
 * Renders a nonstandard vertical rectangle (nonstandard referring primarily to
 * the texture size (ie: when we're not pulling a single element out of a 16x16
 * grid).  This differs from renderVertical also in that we specify two full
 * (x, y, z) coordinates for the bounds, instead of passing in y and a height.
 * Texture coordinates are passed in as the usual float from 0 to 1.
 *
 * @param tx  X index within the texture
 * @param ty  Y index within the texture
 * @param tdx Width of texture//from   w w w  . j a  va  2s  . c  om
 * @param tdy Height of texture
 * @param x1
 * @param y1
 * @param z1
 * @param x2
 * @param y2
 * @param z2
 */
public static void renderNonstandardVertical(float tx, float ty, float tdx, float tdy, float x1, float y1,
        float z1, float x2, float y2, float z2) {
    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);

    GL11.glTexCoord2f(tx, ty + tdy);
    GL11.glVertex3f(x1, y1, z1);

    GL11.glTexCoord2f(tx + tdx, ty + tdy);
    GL11.glVertex3f(x2, y1, z2);

    GL11.glTexCoord2f(tx, ty);
    GL11.glVertex3f(x1, y2, z1);

    GL11.glTexCoord2f(tx + tdx, ty);
    GL11.glVertex3f(x2, y2, z2);

    // unflipped textures
    /*
    GL11.glTexCoord2f(tx, ty);
    GL11.glVertex3f(x1, y1, z1);
            
    GL11.glTexCoord2f(tx + tdx, ty);
    GL11.glVertex3f(x2, y1, z2);
            
    GL11.glTexCoord2f(tx, ty + tdy);
    GL11.glVertex3f(x1, y2, z1);
            
    GL11.glTexCoord2f(tx + tdx, ty + tdy);
    GL11.glVertex3f(x2, y2, z2);
     */
    GL11.glEnd();
}

From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java

License:Open Source License

/**
 * Renders a somewhat-arbitrary vertical rectangle.  Pass in (x, z) pairs for the endpoints,
 * and information about the height.  The texture variables given are in terms of 1/16ths of
 * the texture square, which means that for the default Minecraft 16x16 texture, they're in
 * pixels.//from w  w  w  .  j a  v  a 2 s  .  c  o  m
 *
 * @param x1
 * @param z1
 * @param x2
 * @param z2
 * @param y      The lower part of the rectangle
 * @param height Height of the rectangle.
 */
public static void renderVertical(float tx, float ty, float tdx, float tdy, float x1, float z1, float x2,
        float z2, float y, float height) {
    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
    GL11.glTexCoord2f(tx, ty);
    GL11.glVertex3f(x1, y + height, z1);

    GL11.glTexCoord2f(tx + tdx, ty);
    GL11.glVertex3f(x2, y + height, z2);

    GL11.glTexCoord2f(tx, ty + tdy);
    GL11.glVertex3f(x1, y, z1);

    GL11.glTexCoord2f(tx + tdx, ty + tdy);
    GL11.glVertex3f(x2, y, z2);
    GL11.glEnd();
}

From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java

License:Open Source License

/**
 * Renders an arbitrary horizontal rectangle (will be orthogonal).  The texture parameters
 * are specified in terms of 1/16ths of the texture (which equates to one pixel, when using
 * the default 16x16 Minecraft texture./* w  w  w . jav  a2  s.com*/
 *
 * @param x1
 * @param z1
 * @param x2
 * @param z2
 * @param y
 */
public static void renderHorizontal(float x1, float z1, float x2, float z2, float y, float tex_start_x,
        float tex_start_y, float tex_width, float tex_height, boolean flip_tex) {
    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);

    if (flip_tex) {
        GL11.glTexCoord2f(tex_start_x, tex_start_y);
        GL11.glVertex3f(x1, y, z2);

        GL11.glTexCoord2f(tex_start_x + tex_width, tex_start_y);
        GL11.glVertex3f(x2, y, z2);

        GL11.glTexCoord2f(tex_start_x, tex_start_y + tex_height);
        GL11.glVertex3f(x1, y, z1);

        GL11.glTexCoord2f(tex_start_x + tex_width, tex_start_y + tex_height);
        GL11.glVertex3f(x2, y, z1);
    } else {
        GL11.glTexCoord2f(tex_start_x, tex_start_y);
        GL11.glVertex3f(x1, y, z1);

        GL11.glTexCoord2f(tex_start_x + tex_width, tex_start_y);
        GL11.glVertex3f(x1, y, z2);

        GL11.glTexCoord2f(tex_start_x, tex_start_y + tex_height);
        GL11.glVertex3f(x2, y, z1);

        GL11.glTexCoord2f(tex_start_x + tex_width, tex_start_y + tex_height);
        GL11.glVertex3f(x2, y, z2);
    }
    GL11.glEnd();
}

From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java

License:Open Source License

/**
 * Renders a nonstandard horizontal rectangle (nonstandard referring primarily to
 * the texture size (ie: when we're not pulling a single element out of a 16x16
 * grid).//from w  w w .  j  av a2 s .co m
 *
 * @param tx  X index within the texture
 * @param ty  Y index within the texture
 * @param tdx Width of texture
 * @param tdy Height of texture
 * @param x1
 * @param z1
 * @param x2
 * @param z2
 * @param y
 */
public static void renderNonstandardHorizontal(float tx, float ty, float tdx, float tdy, float x1, float z1,
        float x2, float z2, float y) {
    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
    GL11.glTexCoord2f(tx, ty);
    GL11.glVertex3f(x1, y, z1);

    GL11.glTexCoord2f(tx + tdx, ty);
    GL11.glVertex3f(x1, y, z2);

    GL11.glTexCoord2f(tx, ty + tdy);
    GL11.glVertex3f(x2, y, z1);

    GL11.glTexCoord2f(tx + tdx, ty + tdy);
    GL11.glVertex3f(x2, y, z2);
    GL11.glEnd();
}

From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java

License:Open Source License

/**
 * Render a surface on a horizontal plane; pass in all four verticies.  This can result,
 * obviously, in non-rectangular and non-orthogonal shapes.
 *
 * @param tx//from   ww  w . j  a v a2 s.com
 * @param ty
 * @param tdx
 * @param tdy
 * @param x1
 * @param z1
 * @param x2
 * @param z2
 * @param x3
 * @param z3
 * @param x4
 * @param z4
 * @param y
 */
public static void renderHorizontalAskew(float tx, float ty, float tdx, float tdy, float x1, float z1, float x2,
        float z2, float x3, float z3, float x4, float z4, float y) {
    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
    GL11.glTexCoord2f(tx, ty);
    GL11.glVertex3f(x1, y, z1);

    GL11.glTexCoord2f(tx + tdx, ty);
    GL11.glVertex3f(x2, y, z2);

    GL11.glTexCoord2f(tx, ty + tdy);
    GL11.glVertex3f(x3, y, z3);

    GL11.glTexCoord2f(tx + tdx, ty + tdy);
    GL11.glVertex3f(x4, y, z4);
    GL11.glEnd();
}

From source file:de.keyle.dungeoncraft.editor.editors.world.render.Renderer.java

License:Open Source License

/**
 * Renders a block sized face with the given facing.
 *
 * @param dimensions Texture dimensions/* w  ww  . ja  v a 2  s . com*/
 * @param x
 * @param y
 * @param z
 * @param facing     The face that should be drawn
 */
public static void renderBlockFace(TextureDimensions dimensions, float x, float y, float z, Facing facing) {
    float curFace[][];
    switch (facing) {
    case UP:
        curFace = new float[][] { { 0f, 1f, 1f }, { 0f, 1f, 0f }, { 1f, 1f, 1f }, { 1f, 1f, 0f } };
        break;
    case DOWN:
        curFace = new float[][] { { 0f, 0f, 1f }, { 0f, 0f, 0f }, { 1f, 0f, 1f }, { 1f, 0f, 0f } };
        break;
    case NORTH:
        curFace = new float[][] { { 0f, 1f, 0f }, { 1f, 1f, 0f }, { 0f, 0f, 0f }, { 1f, 0f, 0f } };
        break;
    case SOUTH:
        curFace = new float[][] { { 0f, 1f, 1f }, { 1f, 1f, 1f }, { 0f, 0f, 1f }, { 1f, 0f, 1f } };
        break;
    case WEST:
        curFace = new float[][] { { 0f, 1f, 1f }, { 0f, 1f, 0f }, { 0f, 0f, 1f }, { 0f, 0f, 0f } };
        break;
    case EAST:
        curFace = new float[][] { { 1f, 1f, 1f }, { 1f, 1f, 0f }, { 1f, 0f, 1f }, { 1f, 0f, 0f } };
        break;
    default:
        return;
    }

    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
    GL11.glTexCoord2f(dimensions.getTexLeft(), dimensions.getTexTop());
    GL11.glVertex3f(x + curFace[0][0], y + curFace[0][1], z + curFace[0][2]);

    GL11.glTexCoord2f(dimensions.getTexLeft() + dimensions.getTexWidth(), dimensions.getTexTop());
    GL11.glVertex3f(x + curFace[1][0], y + curFace[1][1], z + curFace[1][2]);

    GL11.glTexCoord2f(dimensions.getTexLeft(), dimensions.getTexTop() + dimensions.getTexHeight());
    GL11.glVertex3f(x + curFace[2][0], y + curFace[2][1], z + curFace[2][2]);

    GL11.glTexCoord2f(dimensions.getTexLeft() + dimensions.getTexWidth(),
            dimensions.getTexTop() + dimensions.getTexHeight());
    GL11.glVertex3f(x + curFace[3][0], y + curFace[3][1], z + curFace[3][2]);
    GL11.glEnd();
}