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:wrath.client.graphics.graphics2D.Background.java

License:Open Source License

@Override
public void render(boolean consolidated) {
    if (consolidated)
        renderSetup();//from w  w w.  j  a  v  a 2  s  . c o  m
    //Top Left
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(-1.0f, 1.0f, 0.0f);

    //Top Right
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(1.0f, 1.0f, 0.0f);

    //Bottom Right
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(1.0f, -1.0f, 0.0f);

    //Bottom Left
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(-1.0f, -1.0f, 0.0f);
    if (consolidated)
        renderStop();
}

From source file:wrath.client.graphics.gui.GuiElement.java

License:Open Source License

@Override
public void render(boolean consolidated) {
    if (consolidated)
        renderSetup();//ww  w . jav  a  2s  .  c  o  m
    color.bindColor();

    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(x, y - h, 0);

    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(x + w, y - h, 0);

    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(x + w, y, 0);

    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(x, y, 0);
    if (consolidated)
        renderStop();
}

From source file:wrath.client.graphics.TextRenderer.java

License:Open Source License

/**
 * Draws the specified string onto the screen at the specified points independent of variables set in this object.
 * The only variable taken from the object in this method is the font itself.
 * @param string The {@link java.lang.String} to write to the screen.
 * @param x The X-coordinate of the top left of the message.
 * @param y The Y-coordinate of the top left of the message.
 * @param fontSize The size of the font. This is a NON standardized unit!
 * @param color The {@link wrath.client.graphics.Color} to make the rendered text.
 *//*from ww w  . j ava 2s  .  c  o  m*/
public void renderString(String string, float x, float y, float fontSize, Color color) {
    if (string.length() == 0)
        return;
    final int gridSize = 16;
    final float characterWidth = fontSize * 0.1f;
    final float characterHeight = characterWidth * 0.75f;

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    fontTex.bindTexture();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR);
    float curPos = x;
    float charWidth;
    GL11.glBegin(GL11.GL_QUADS);
    for (int i = 0; i < string.length(); i++) {
        int ascii = (int) string.charAt(i);
        final float cellSize = 1.0f / gridSize;
        float cellX = ((int) ascii % gridSize) * cellSize;
        float cellY = ((int) ascii / gridSize) * cellSize;
        color.bindColor();
        //(0, 1) bottom left
        GL11.glTexCoord2f(cellX, cellY + cellSize);
        GL11.glVertex3f(curPos, y - characterHeight, 0);

        //(1, 1) bottom right
        GL11.glTexCoord2f(cellX + cellSize, cellY + cellSize);
        GL11.glVertex3f(curPos + characterWidth / 2, y - characterHeight, 0);

        //(1, 0) top right 
        GL11.glTexCoord2f(cellX + cellSize, cellY);
        GL11.glVertex3f(curPos + characterWidth / 2, y, 0);

        //(0, 0) top left
        GL11.glTexCoord2f(cellX, cellY);
        GL11.glVertex3f(curPos, y, 0);

        if (spaceMap.containsKey(string.charAt(i)))
            charWidth = spaceMap.get(string.charAt(i));
        else
            charWidth = 1.0f;
        curPos = curPos + (charWidth * (fontSize / 48f));
        if ((i + 1) < string.length()) {
            if (spaceMap.containsKey(string.charAt(i + 1)))
                curPos = curPos + ((spaceMap.get(string.charAt(i + 1)) * (fontSize / 48f)) / 1.6f);
            else
                curPos = curPos + (fontSize / 48f) / 3.5f;
        }
    }
    GL11.glEnd();

    color.unbindColor();
    Texture.unbindTextures();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}