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.badlogic.gdx.tools.hiero.unicodefont.UnicodeFont.java

License:Apache License

/** Identical to {@link #drawString(float, float, String, Color, int, int)} but returns a DisplayList which provides access to
 * the width and height of the text drawn. */
public void drawDisplayList(float x, float y, String text, Color color, int startIndex, int endIndex) {
    if (text == null)
        throw new IllegalArgumentException("text cannot be null.");
    if (text.length() == 0)
        return;//ww w .  j  a v  a 2  s.c  o  m
    if (color == null)
        throw new IllegalArgumentException("color cannot be null.");

    x -= paddingLeft;
    y -= paddingTop;

    String displayListKey = text.substring(startIndex, endIndex);

    GL11.glColor4f(color.r, color.g, color.b, color.a);

    GL11.glTranslatef(x, y, 0);

    char[] chars = text.substring(0, endIndex).toCharArray();
    GlyphVector vector = font.layoutGlyphVector(GlyphPage.renderContext, chars, 0, chars.length,
            Font.LAYOUT_LEFT_TO_RIGHT);

    int maxWidth = 0, totalHeight = 0, lines = 0;
    int extraX = 0, extraY = ascent;
    boolean startNewLine = false;
    Texture lastBind = null;
    int offsetX = 0;
    for (int glyphIndex = 0, n = vector.getNumGlyphs(); glyphIndex < n; glyphIndex++) {
        int charIndex = vector.getGlyphCharIndex(glyphIndex);
        if (charIndex < startIndex)
            continue;
        if (charIndex > endIndex)
            break;

        int codePoint = text.codePointAt(charIndex);

        Rectangle bounds = getGlyphBounds(vector, glyphIndex, codePoint);
        bounds.x += offsetX;
        Glyph glyph = getGlyph(vector.getGlyphCode(glyphIndex), codePoint, bounds, vector, glyphIndex);

        if (startNewLine && codePoint != '\n') {
            extraX = -bounds.x;
            startNewLine = false;
        }

        if (glyph.getTexture() == null && missingGlyph != null && glyph.isMissing())
            glyph = missingGlyph;
        if (glyph.getTexture() != null) {
            // Draw glyph, only binding a new glyph page texture when necessary.
            Texture texture = glyph.getTexture();
            if (lastBind != null && lastBind != texture) {
                GL11.glEnd();
                lastBind = null;
            }
            if (lastBind == null) {
                texture.bind();
                GL11.glBegin(GL11.GL_QUADS);
                lastBind = texture;
            }
            int glyphX = bounds.x + extraX;
            int glyphY = bounds.y + extraY;
            GL11.glTexCoord2f(glyph.getU(), glyph.getV());
            GL11.glVertex3f(glyphX, glyphY, 0);
            GL11.glTexCoord2f(glyph.getU(), glyph.getV2());
            GL11.glVertex3f(glyphX, glyphY + glyph.getHeight(), 0);
            GL11.glTexCoord2f(glyph.getU2(), glyph.getV2());
            GL11.glVertex3f(glyphX + glyph.getWidth(), glyphY + glyph.getHeight(), 0);
            GL11.glTexCoord2f(glyph.getU2(), glyph.getV());
            GL11.glVertex3f(glyphX + glyph.getWidth(), glyphY, 0);
        }

        if (glyphIndex > 0)
            extraX += paddingRight + paddingLeft + paddingAdvanceX;
        maxWidth = Math.max(maxWidth, bounds.x + extraX + bounds.width);
        totalHeight = Math.max(totalHeight, ascent + bounds.y + bounds.height);

        if (codePoint == '\n') {
            startNewLine = true; // Mac gives -1 for bounds.x of '\n', so use the bounds.x of the next glyph.
            extraY += getLineHeight();
            lines++;
            totalHeight = 0;
        } else if (nativeRendering)
            offsetX += bounds.width;
    }
    if (lastBind != null)
        GL11.glEnd();

    GL11.glTranslatef(-x, -y, 0);
}

From source file:com.gameminers.ethereal.architect.ModelCanvas.java

License:Open Source License

@Override
protected void paintGL() {
    try {//from w  w w  . j  av  a  2  s  .c o  m
        if (getWidth() != current_width || getHeight() != current_height) {
            current_width = getWidth();
            current_height = getHeight();
            GL11.glViewport(0, 0, current_width, current_height);
        }
        GL11.glClearColor(0.0f, 0.6f, 0.5f, 1.0f);
        GL11.glClearDepth(1.0);
        GL11.glColor3f(1, 1, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glLoadIdentity();
        GLU.gluPerspective(45.0f, (float) getWidth() / (float) getHeight(), 0.1f, 1000.0f);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, zoom);
        GL11.glRotatef(angle, 0f, 1f, 0f);
        GL11.glRotatef(tilt, 1f, 0f, 0f);
        GL11.glTranslatef(-16, -16, -16);
        if (lit) {
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_LIGHT0);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, lightAmbient);
        } else {
            GL11.glDisable(GL11.GL_LIGHTING);
        }
        if (textured) {
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
        if (model != null) {
            if (model.isAmbientOcclusionEnabled()) {
                GL11.glShadeModel(GL11.GL_SMOOTH);
            } else {
                GL11.glShadeModel(GL11.GL_FLAT);
            }
            for (ModelElement ele : model.getElements()) {
                GL11.glPushMatrix();
                if (ele.isShade()) {
                    GL11.glEnable(GL11.GL_LIGHTING);
                } else {
                    GL11.glDisable(GL11.GL_LIGHTING);
                }
                float fromX = ele.getFrom()[0];
                float fromY = ele.getFrom()[1];
                float fromZ = ele.getFrom()[2];
                float toX = ele.getTo()[0];
                float toY = ele.getTo()[1];
                float toZ = ele.getTo()[2];

                float fX = (fromX > toX ? fromX : toX);
                float fY = (fromY > toY ? fromY : toY);
                float fZ = (fromZ > toZ ? fromZ : toZ);
                float tX = (fromX > toX ? toX : fromX);
                float tY = (fromY > toY ? toY : fromY);
                float tZ = (fromZ > toZ ? toZ : fromZ);

                GL11.glTranslatef(fX, fY, fZ);
                float scaleX = tX - fX;
                float scaleY = tY - fY;
                float scaleZ = tZ - fZ;
                GL11.glBegin(GL11.GL_QUADS);
                GL11.glNormal3f(0, 0, -1f);
                for (int i = 0; i < vertices.length / 3; i++) {
                    int faceIdx = i / 4;
                    ModelFace face;
                    switch (faceIdx) {
                    case 0:
                        face = ele.getFaces().getNorth();
                        break;
                    case 1:
                        face = ele.getFaces().getSouth();
                        break;
                    case 2:
                        face = ele.getFaces().getUp();
                        break;
                    case 3:
                        face = ele.getFaces().getDown();
                        break;
                    case 4:
                        face = ele.getFaces().getWest();
                        break;
                    case 5:
                        face = ele.getFaces().getEast();
                        break;
                    default:
                        face = null;
                        break;
                    }
                    int idx = i * 3;
                    float vX = vertices[idx] * scaleX;
                    float vY = vertices[idx + 1] * scaleY;
                    float vZ = vertices[idx + 2] * scaleZ;
                    /*float u;
                    float v;
                    GL11.glTexCoord2f(u, v);*/
                    GL11.glVertex3f(vX, vY, vZ);
                }
                GL11.glEnd();
                GL11.glPopMatrix();
            }
        }
        GL11.glPopMatrix();
        swapBuffers();
        repaint();
    } catch (LWJGLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.github.begla.blockmania.blocks.Block.java

License:Apache License

/**
 * Generates the display list used for rendering the block.
 *
 * @return The id of the display list/*from www  .j  a va2 s  .c  om*/
 */
private int generateDisplayList() {
    int id = glGenLists(1);

    glNewList(id, GL11.GL_COMPILE);
    glBegin(GL_QUADS);
    GL11.glColor3f(1.0f, 1.0f, 1.0f);

    // TOP
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.TOP).x, calcTextureOffsetFor(SIDE.TOP).y);
    GL11.glVertex3f(-0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.TOP).x + 0.0624f, calcTextureOffsetFor(SIDE.TOP).y);
    GL11.glVertex3f(0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.TOP).x + 0.0624f, calcTextureOffsetFor(SIDE.TOP).y + 0.0624f);
    GL11.glVertex3f(0.5f, 0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.TOP).x, calcTextureOffsetFor(SIDE.TOP).y + 0.0624f);
    GL11.glVertex3f(-0.5f, 0.5f, -0.5f);

    // LEFT
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.LEFT).x, calcTextureOffsetFor(SIDE.LEFT).y + 0.0624f);
    GL11.glVertex3f(-0.5f, -0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.LEFT).x + 0.0624f, calcTextureOffsetFor(SIDE.LEFT).y + 0.0624f);
    GL11.glVertex3f(-0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.LEFT).x + 0.0624f, calcTextureOffsetFor(SIDE.LEFT).y);
    GL11.glVertex3f(-0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.LEFT).x, calcTextureOffsetFor(SIDE.LEFT).y);
    GL11.glVertex3f(-0.5f, 0.5f, -0.5f);

    // BACK
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BACK).x, calcTextureOffsetFor(SIDE.BACK).y + 0.0624f);
    GL11.glVertex3f(-0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BACK).x + 0.0624f, calcTextureOffsetFor(SIDE.BACK).y + 0.0624f);
    GL11.glVertex3f(0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BACK).x + 0.0624f, calcTextureOffsetFor(SIDE.BACK).y);
    GL11.glVertex3f(0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BACK).x, calcTextureOffsetFor(SIDE.BACK).y);
    GL11.glVertex3f(-0.5f, 0.5f, 0.5f);

    // RIGHT
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.RIGHT).x, calcTextureOffsetFor(SIDE.RIGHT).y);
    GL11.glVertex3f(0.5f, 0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.RIGHT).x + 0.0624f, calcTextureOffsetFor(SIDE.RIGHT).y);
    GL11.glVertex3f(0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.RIGHT).x + 0.0624f,
            calcTextureOffsetFor(SIDE.RIGHT).y + 0.0624f);
    GL11.glVertex3f(0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.RIGHT).x, calcTextureOffsetFor(SIDE.RIGHT).y + 0.0624f);
    GL11.glVertex3f(0.5f, -0.5f, -0.5f);

    GL11.glColor3f(0.5f, 0.5f, 0.5f);

    // FRONT
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.FRONT).x, calcTextureOffsetFor(SIDE.FRONT).y);
    GL11.glVertex3f(-0.5f, 0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.FRONT).x + 0.0624f, calcTextureOffsetFor(SIDE.FRONT).y);
    GL11.glVertex3f(0.5f, 0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.FRONT).x + 0.0624f,
            calcTextureOffsetFor(SIDE.FRONT).y + 0.0624f);
    GL11.glVertex3f(0.5f, -0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.FRONT).x, calcTextureOffsetFor(SIDE.FRONT).y + 0.0624f);
    GL11.glVertex3f(-0.5f, -0.5f, -0.5f);
    // BOTTOM
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BOTTOM).x, calcTextureOffsetFor(SIDE.BOTTOM).y);
    GL11.glVertex3f(-0.5f, -0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BOTTOM).x + 0.0624f, calcTextureOffsetFor(SIDE.BOTTOM).y);
    GL11.glVertex3f(0.5f, -0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BOTTOM).x + 0.0624f,
            calcTextureOffsetFor(SIDE.BOTTOM).y + 0.0624f);
    GL11.glVertex3f(0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BOTTOM).x, calcTextureOffsetFor(SIDE.BOTTOM).y + 0.0624f);
    GL11.glVertex3f(-0.5f, -0.5f, 0.5f);

    GL11.glEnd();
    glEndList();

    return id;
}

From source file:com.github.begla.blockmania.game.mobs.GelatinousCube.java

License:Apache License

private void generateDisplayList() {
    _displayListOuterBody = glGenLists(1);
    _displayListInnerBody = glGenLists(1);

    glNewList(_displayListOuterBody, GL_COMPILE);

    glBegin(GL_QUADS);/*w  w w . j  av a 2 s. c o m*/
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.8f);

    // TOP
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, HEIGHT_HALF, WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF, HEIGHT_HALF, WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF, HEIGHT_HALF, -WIDTH_HALF);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, HEIGHT_HALF, -WIDTH_HALF);

    // LEFT
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, -HEIGHT_HALF, -WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, -HEIGHT_HALF, WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, HEIGHT_HALF, WIDTH_HALF);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, HEIGHT_HALF, -WIDTH_HALF);

    // BACK
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, -HEIGHT_HALF, WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF, -HEIGHT_HALF, WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF, HEIGHT_HALF, WIDTH_HALF);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, HEIGHT_HALF, WIDTH_HALF);

    // RIGHT
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF, HEIGHT_HALF, -WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF, HEIGHT_HALF, WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF, -HEIGHT_HALF, WIDTH_HALF);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF, -HEIGHT_HALF, -WIDTH_HALF);

    GL11.glColor4f(0.8f, 0.8f, 0.8f, 0.8f);

    // FRONT
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, HEIGHT_HALF, -WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF, HEIGHT_HALF, -WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF, -HEIGHT_HALF, -WIDTH_HALF);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, -HEIGHT_HALF, -WIDTH_HALF);

    // BOTTOM
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, -HEIGHT_HALF, -WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF, -HEIGHT_HALF, -WIDTH_HALF);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF, -HEIGHT_HALF, WIDTH_HALF);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF, -HEIGHT_HALF, WIDTH_HALF);

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

    glNewList(_displayListInnerBody, GL_COMPILE);

    glBegin(GL_QUADS);
    GL11.glColor4f(0.8f, 0.8f, 0.8f, 1.0f);

    // TOP
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, HEIGHT_HALF / 2, WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, HEIGHT_HALF / 2, WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, HEIGHT_HALF / 2, -WIDTH_HALF / 2);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, HEIGHT_HALF / 2, -WIDTH_HALF / 2);

    // LEFT
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, -HEIGHT_HALF / 2, -WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, -HEIGHT_HALF / 2, WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, HEIGHT_HALF / 2, WIDTH_HALF / 2);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, HEIGHT_HALF / 2, -WIDTH_HALF / 2);

    // BACK
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, -HEIGHT_HALF / 2, WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, -HEIGHT_HALF / 2, WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, HEIGHT_HALF / 2, WIDTH_HALF / 2);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, HEIGHT_HALF / 2, WIDTH_HALF / 2);

    // RIGHT
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, HEIGHT_HALF / 2, -WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, HEIGHT_HALF / 2, WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, -HEIGHT_HALF / 2, WIDTH_HALF / 2);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, -HEIGHT_HALF / 2, -WIDTH_HALF / 2);

    GL11.glColor4f(0.6f, 0.6f, 0.6f, 1.0f);

    // FRONT
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, HEIGHT_HALF / 2, -WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, HEIGHT_HALF / 2, -WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, -HEIGHT_HALF / 2, -WIDTH_HALF / 2);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, -HEIGHT_HALF / 2, -WIDTH_HALF / 2);

    // BOTTOM
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, -HEIGHT_HALF / 2, -WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, -HEIGHT_HALF / 2, -WIDTH_HALF / 2);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(WIDTH_HALF / 2, -HEIGHT_HALF / 2, WIDTH_HALF / 2);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-WIDTH_HALF / 2, -HEIGHT_HALF / 2, WIDTH_HALF / 2);

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

From source file:com.github.begla.blockmania.rendering.helper.Primitives.java

License:Apache License

public static int generateColoredBlock(Vector4f color, float size) {
    int id = glGenLists(1);

    GL11.glNewList(id, GL11.GL_COMPILE);
    GL11.glBegin(GL11.GL_QUADS);//from w ww  . j av  a  2s  . c o m

    GL11.glColor4f(color.x, color.y, color.z, color.w);

    float sHalf = size / 2;

    // TOP
    GL11.glVertex3f(-sHalf, sHalf, sHalf);
    GL11.glVertex3f(sHalf, sHalf, sHalf);
    GL11.glVertex3f(sHalf, sHalf, -sHalf);
    GL11.glVertex3f(-sHalf, sHalf, -sHalf);

    // LEFT
    GL11.glVertex3f(-sHalf, -sHalf, -sHalf);
    GL11.glVertex3f(-sHalf, -sHalf, sHalf);
    GL11.glVertex3f(-sHalf, sHalf, sHalf);
    GL11.glVertex3f(-sHalf, sHalf, -sHalf);

    // RIGHT
    GL11.glVertex3f(sHalf, sHalf, -sHalf);
    GL11.glVertex3f(sHalf, sHalf, sHalf);
    GL11.glVertex3f(sHalf, -sHalf, sHalf);
    GL11.glVertex3f(sHalf, -sHalf, -sHalf);

    GL11.glColor4f(0.85f * color.x, 0.85f * color.y, 0.85f * color.z, color.w);

    // FRONT
    GL11.glVertex3f(-sHalf, sHalf, -sHalf);
    GL11.glVertex3f(sHalf, sHalf, -sHalf);
    GL11.glVertex3f(sHalf, -sHalf, -sHalf);
    GL11.glVertex3f(-sHalf, -sHalf, -sHalf);

    // BACK
    GL11.glVertex3f(-sHalf, -sHalf, sHalf);
    GL11.glVertex3f(sHalf, -sHalf, sHalf);
    GL11.glVertex3f(sHalf, sHalf, sHalf);
    GL11.glVertex3f(-sHalf, sHalf, sHalf);

    // BOTTOM
    GL11.glVertex3f(-sHalf, -sHalf, -sHalf);
    GL11.glVertex3f(sHalf, -sHalf, -sHalf);
    GL11.glVertex3f(sHalf, -sHalf, sHalf);
    GL11.glVertex3f(-sHalf, -sHalf, sHalf);

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

    return id;
}

From source file:com.github.begla.blockmania.rendering.particles.BlockParticle.java

License:Apache License

private void drawParticle() {
    Block b = BlockManager.getInstance().getBlock(_blockType);

    glBegin(GL_QUADS);//from w w w  .  j  a v  a2 s  .c o  m
    GL11.glTexCoord2f(b.calcTextureOffsetFor(Block.SIDE.FRONT).x, b.calcTextureOffsetFor(Block.SIDE.FRONT).y);
    GL11.glVertex3f(-0.5f, -0.5f, 0.0f);

    GL11.glTexCoord2f(b.calcTextureOffsetFor(Block.SIDE.FRONT).x + 0.02f,
            b.calcTextureOffsetFor(Block.SIDE.FRONT).y);
    GL11.glVertex3f(0.5f, -0.5f, 0.0f);

    GL11.glTexCoord2f(b.calcTextureOffsetFor(Block.SIDE.FRONT).x + 0.02f,
            b.calcTextureOffsetFor(Block.SIDE.FRONT).y + 0.02f);
    GL11.glVertex3f(0.5f, 0.5f, 0.0f);

    GL11.glTexCoord2f(b.calcTextureOffsetFor(Block.SIDE.FRONT).x,
            b.calcTextureOffsetFor(Block.SIDE.FRONT).y + 0.02f);
    GL11.glVertex3f(-0.5f, 0.5f, 0.0f);
    glEnd();

}

From source file:com.github.begla.blockmania.world.characters.Slime.java

License:Apache License

public void render() {
    super.render();

    glPushMatrix();// w w w  .  java2 s . com

    glTranslatef(getPosition().x, getPosition().y, getPosition().z);
    glRotatef((float) _yaw, 0f, 1f, 0f);

    glEnable(GL_TEXTURE_2D);
    TextureManager.getInstance().bindTexture("slime");

    float brightness = (float) Math.pow(0.84, 15.0 - _parent.getDaylight() * 15.0);

    glBegin(GL_QUADS);
    GL11.glColor3f(brightness, brightness, brightness);

    // TOP
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-0.25f, 0.2f, 0.25f);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(0.25f, 0.2f, 0.25f);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(0.25f, 0.2f, -0.25f);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-0.25f, 0.2f, -0.25f);

    // LEFT
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-0.25f, -0.2f, -0.25f);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(-0.25f, -0.2f, 0.25f);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(-0.25f, 0.2f, 0.25f);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-0.25f, 0.2f, -0.25f);

    // BACK
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-0.25f, -0.2f, 0.25f);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(0.25f, -0.2f, 0.25f);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(0.25f, 0.2f, 0.25f);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-0.25f, 0.2f, 0.25f);

    // RIGHT
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(0.25f, 0.2f, -0.25f);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(0.25f, 0.2f, 0.25f);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(0.25f, -0.2f, 0.25f);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(0.25f, -0.2f, -0.25f);

    GL11.glColor3f(brightness * 0.25f, brightness * 0.25f, brightness * 0.25f);

    // FRONT
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-0.25f, 0.2f, -0.25f);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(0.25f, 0.2f, -0.25f);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(0.25f, -0.2f, -0.25f);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-0.25f, -0.2f, -0.25f);

    // BOTTOM
    GL11.glTexCoord2f(0f / 64f, 28f / 32f);
    GL11.glVertex3f(-0.25f, -0.2f, -0.25f);
    GL11.glTexCoord2f(6f / 64f, 28f / 32f);
    GL11.glVertex3f(0.25f, -0.2f, -0.25f);
    GL11.glTexCoord2f(6f / 64f, 22f / 32f);
    GL11.glVertex3f(0.25f, -0.2f, 0.25f);
    GL11.glTexCoord2f(0f / 64f, 22f / 32f);
    GL11.glVertex3f(-0.25f, -0.2f, 0.25f);

    GL11.glEnd();

    glDisable(GL11.GL_TEXTURE_2D);

    glPopMatrix();
}

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

public void drawQuad() {
    // this func just draws a perfectly normal box with some texture coordinates
    GL11.glBegin(GL11.GL_QUADS);/*from   www  . j ava2  s  .  com*/

    // Front Face
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left Of The Texture and Quad
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right Of The Texture and Quad
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 0.0f); // Top Right Of The Texture and Quad
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left Of The Texture and Quad

    GL11.glEnd();
}

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

public void drawLatencyTesterColoredQuad(float r, float g, float b, float a) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from   w w  w  .j  av a 2  s .  co m*/
    GL11.glEnable(GL11.GL_BLEND);

    // Setup ortho projection
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    GL11.glTranslatef(0.0f, 0.0f, -0.7f);

    // Cover the appropriate areas of the screen with the colored quad
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glColor4f(r, g, b, a);

    GL11.glVertex3f(-0.6f, -0.6f, 0.0f); // Bottom Left Of The Texture and Quad
    GL11.glVertex3f(0.6f, -0.6f, 0.0f); // Bottom Right Of The Texture and Quad
    GL11.glVertex3f(0.6f, 0.6f, 0.0f); // Top Right Of The Texture and Quad
    GL11.glVertex3f(-0.6f, 0.6f, 0.0f); // Top Left Of The Texture and Quad

    GL11.glEnd();

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

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

public void drawQuad2(float displayWidth, float displayHeight, float scale) {
    float aspect = displayHeight / displayWidth;

    GL11.glBegin(GL11.GL_QUADS);//  w  w w .ja va  2 s. co  m

    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(-1.0f * scale, -1.0f * aspect * scale, 0.0f); // Bottom Left  Of The Texture and Quad
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(1.0f * scale, -1.0f * aspect * scale, 0.0f); // Bottom Right Of The Texture and Quad
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(1.0f * scale, 1.0f * aspect * scale, 0.0f); // Top    Right Of The Texture and Quad
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-1.0f * scale, 1.0f * aspect * scale, 0.0f); // Top    Left  Of The Texture and Quad

    GL11.glEnd();
}