Example usage for org.lwjgl.opengl GL11 glTexCoord2f

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

Introduction

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

Prototype

public static native void glTexCoord2f(@NativeType("GLfloat") float s, @NativeType("GLfloat") float t);

Source Link

Document

Sets the current two-dimensional texture coordinate.

Usage

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);/*from   w ww .  ja v a  2  s  .  com*/
    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.particles.BlockParticle.java

License:Apache License

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

    glBegin(GL_QUADS);/*from w  w  w .java  2s .  c om*/
    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.rendering.Primitives.java

License:Apache License

/**
 * @param scaleX    Scale along the x-axis
 * @param scaleY    Scale along the y-axis
 * @param scaleZ    Scale along the z-axis
 * @param x         Position on the x-axis
 * @param y         Position on the y-axis
 * @param z         Position on the z-axis
 * @param drawLeft/*from ww  w .  j  ava  2  s  .co  m*/
 * @param drawRight
 * @param drawFront
 * @param drawBack
 */
public static void drawCloud(double scaleX, double scaleY, double scaleZ, double x, double y, double z,
        boolean drawLeft, boolean drawRight, boolean drawFront, boolean drawBack) {

    // Top Face
    GL11.glColor4f(CLOUD_COLOR_2.x, CLOUD_COLOR_2.y, CLOUD_COLOR_2.z, CLOUD_COLOR_2.w);
    GL11.glTexCoord2f(0.0f, 0.5f);
    GL11.glVertex3d(-0.5 * scaleX + x, 0.5 * scaleY + y, -0.5 * scaleZ + z);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3d(-0.5 * scaleX + x, 0.5 * scaleY + y, 0.5 * scaleZ + z);
    GL11.glTexCoord2f(0.5f, 0.0f);
    GL11.glVertex3d(0.5 * scaleX + x, 0.5 * scaleY + y, 0.5 * scaleZ + z);
    GL11.glTexCoord2f(0.5f, 0.5f);
    GL11.glVertex3d(0.5 * scaleX + x, 0.5 * scaleY + y, -0.5 * scaleZ + z);

    // Back Face
    if (drawBack) {
        GL11.glColor4f(CLOUD_COLOR_2.x, CLOUD_COLOR_2.y, CLOUD_COLOR_2.z, CLOUD_COLOR_2.w);
        GL11.glTexCoord2f(0.5f, 0.0f);
        GL11.glVertex3d(-0.5 * scaleX + x, -0.5 * scaleY + y, -0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.5f, 0.5f);
        GL11.glVertex3d(-0.5 * scaleX + x, 0.5 * scaleY + y, -0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.0f, 0.5f);
        GL11.glVertex3d(0.5 * scaleX + x, 0.5 * scaleY + y, -0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.0f, 0.0f);
        GL11.glVertex3d(0.5 * scaleX + x, -0.5 * scaleY + y, -0.5 * scaleZ + z);
    }

    // Left Face
    if (drawLeft) {
        GL11.glColor4f(CLOUD_COLOR_2.x, CLOUD_COLOR_2.y, CLOUD_COLOR_2.z, CLOUD_COLOR_2.w);
        GL11.glTexCoord2f(0.0f, 0.0f);
        GL11.glVertex3d(-0.5 * scaleX + x, -0.5 * scaleY + y, -0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.5f, 0.0f);
        GL11.glVertex3d(-0.5 * scaleX + x, -0.5 * scaleY + y, 0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.5f, 0.5f);
        GL11.glVertex3d(-0.5 * scaleX + x, 0.5 * scaleY + y, 0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.0f, 0.5f);
        GL11.glVertex3d(-0.5 * scaleX + x, 0.5 * scaleY + y, -0.5 * scaleZ + z);
    }
    // Right face
    if (drawRight) {
        GL11.glColor4f(CLOUD_COLOR_2.x, CLOUD_COLOR_2.y, CLOUD_COLOR_2.z, CLOUD_COLOR_2.w);
        GL11.glTexCoord2f(0.5f, 0.0f);
        GL11.glVertex3d(0.5 * scaleX + x, -0.5 * scaleY + y, -0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.5f, 0.5f);
        GL11.glVertex3d(0.5 * scaleX + x, 0.5 * scaleY + y, -0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.0f, 0.5f);
        GL11.glVertex3d(0.5 * scaleX + x, 0.5 * scaleY + y, 0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.0f, 0.0f);
        GL11.glVertex3d(0.5 * scaleX + x, -0.5 * scaleY + y, 0.5 * scaleZ + z);
    }

    // Front face
    if (drawFront) {
        GL11.glColor4f(CLOUD_COLOR_2.x, CLOUD_COLOR_2.y, CLOUD_COLOR_2.z, CLOUD_COLOR_2.w);
        GL11.glTexCoord2f(0.5f, 0.0f);
        GL11.glVertex3d(-0.5 * scaleX + x, -0.5 * scaleY + y, 0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.5f, 0.0f);
        GL11.glVertex3d(0.5 * scaleX + x, -0.5 * scaleY + y, 0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.5f, 0.5f);
        GL11.glVertex3d(0.5 * scaleX + x, 0.5 * scaleY + y, 0.5 * scaleZ + z);
        GL11.glTexCoord2f(0.0f, 0.5f);
        GL11.glVertex3d(-0.5 * scaleX + x, 0.5 * scaleY + y, 0.5 * scaleZ + z);
    }

    // Bottom Face
    GL11.glColor4f(CLOUD_COLOR_1.x, CLOUD_COLOR_1.y, CLOUD_COLOR_1.z, CLOUD_COLOR_1.w);
    GL11.glTexCoord2f(0.5f, 0.5f);
    GL11.glVertex3d(-0.5 * scaleX + x, -0.5 * scaleY + y, -0.5 * scaleZ + z);
    GL11.glTexCoord2f(0.0f, 0.5f);
    GL11.glVertex3d(0.5 * scaleX + x, -0.5 * scaleY + y, -0.5 * scaleZ + z);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3d(0.5 * scaleX + x, -0.5 * scaleY + y, 0.5 * scaleZ + z);
    GL11.glTexCoord2f(0.5f, 0.0f);
    GL11.glVertex3d(-0.5 * scaleX + x, -0.5 * scaleY + y, 0.5 * scaleZ + z);
}

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

License:Apache License

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

    glPushMatrix();//  ww w  .j a v  a 2s .c  o  m

    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.golden.gamedev.engine.lwjgl.LWJGLGraphics.java

License:Open Source License

/** ************************************************************************* */

public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
    this.startPainting();

    // store the current model matrix
    GL11.glPushMatrix();// ww w .j a va 2s  .c o  m

    // bind to the appropriate texture for this sprite
    Texture texture = this.textureLoader.getTexture((BufferedImage) img);
    texture.bind();

    // translate to the right location and prepare to draw
    GL11.glTranslatef(x, y, 0);

    // draw a quad textured to match the sprite
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(0, 0);

    GL11.glTexCoord2f(0, texture.getHeight());
    GL11.glVertex2f(0, texture.getImageHeight());

    GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
    GL11.glVertex2f(texture.getImageWidth(), texture.getImageHeight());

    GL11.glTexCoord2f(texture.getWidth(), 0);
    GL11.glVertex2f(texture.getImageWidth(), 0);
    GL11.glEnd();

    // restore the model view matrix to prevent contamination
    GL11.glPopMatrix();

    this.endPainting();

    return true;
}

From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java

License:Open Source License

public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {
    this.startPainting();

    GL11.glPushMatrix();// w w  w .  j  a v a  2  s.  co  m

    Texture texture = this.textureLoader.getTexture((BufferedImage) img);
    texture.bind();

    GL11.glTranslatef(x, y, 0);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(0, 0);

    GL11.glTexCoord2f(0, texture.getHeight());
    GL11.glVertex2f(0, height);

    GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
    GL11.glVertex2f(width, height);

    GL11.glTexCoord2f(texture.getWidth(), 0);
    GL11.glVertex2f(width, 0);
    GL11.glEnd();

    GL11.glPopMatrix();

    this.endPainting();

    return true;
}

From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java

License:Open Source License

public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
        ImageObserver observer) {
    this.startPainting();

    Texture texture = this.textureLoader.getTexture((BufferedImage) img);
    texture.bind();/*  ww w. jav a  2  s .  c  o  m*/

    float tx0 = ((float) sx1 / texture.getTextureWidth());
    float tx1 = ((float) sx2 / texture.getTextureWidth());
    float ty0 = ((float) sy1 / texture.getTextureHeight());
    float ty1 = ((float) sy2 / texture.getTextureHeight());

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(tx0, ty0);
    GL11.glVertex2f(dx1, dy1);

    GL11.glTexCoord2f(tx1, ty0);
    GL11.glVertex2f(dx2, dy1);

    GL11.glTexCoord2f(tx1, ty1);
    GL11.glVertex2f(dx2, dy2);

    GL11.glTexCoord2f(tx0, ty1);
    GL11.glVertex2f(dx1, dy2);
    GL11.glEnd();

    this.endPainting();

    return true;
}

From source file:com.lion328.thaifixes.nmod.ThaiFixesFontRenderer.java

License:Open Source License

private float renderThaiChar(char c, boolean italic) {
    try {//from w w w  .j a  v  a  2 s .c om
        float cPosX, cPosY;
        switch (ThaiFixesConfiguration.getFontStyle()) {
        default:
        case UNICODE:
            if (ThaiFixesUtils.isSpecialThaiChar(c)) {
                //posX.setFloat(this, posX.getFloat(this) - 4); // move character to before character position
                byte size = ((byte[]) glyphWidth.get(this))[c];
                if (size == 0)
                    return 0.0F;
                else {
                    invokeMethod("loadGlyphTexture", new Class[] { int.class }, (int) (c / 256)); // load texture

                    float charHeightOnTexture = 4.98F,
                            beginTexcoordY = ThaiFixesUtils.isLowerThaiChar(c) ? 15.98F - charHeightOnTexture
                                    : 0F,
                            quadHeight = charHeightOnTexture / 2; // vertex position, not for texture coordinate.

                    // glyphWidth format:
                    // XXXXYYYY, XXXX as start X position on texture coordinate and YYYY as width.
                    float startTexcoordX = (float) (size >>> 4);
                    float charWidth = (float) ((size & 0xF) + 1);

                    float texcoordX = (float) (c % 16 * 16) + startTexcoordX;
                    float texcoordY = (float) ((c & 255) / 16 * 16);
                    float realCharWidth = charWidth - startTexcoordX - 0.02F;
                    float italicSize = italic ? 1.0F : 0.0F;

                    cPosX = posX.getFloat(this) - (realCharWidth + 0.02F) / 2 - 1; // get current position
                    cPosY = posY.getFloat(this);

                    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
                    GL11.glTexCoord2f(texcoordX / 256.0F, (texcoordY + beginTexcoordY) / 256.0F);
                    GL11.glVertex2f(cPosX + italicSize, cPosY + (beginTexcoordY / 2));
                    GL11.glTexCoord2f(texcoordX / 256.0F,
                            (texcoordY + beginTexcoordY + charHeightOnTexture) / 256.0F);
                    GL11.glVertex2f(cPosX - italicSize, cPosY + (beginTexcoordY / 2) + quadHeight);
                    GL11.glTexCoord2f((texcoordX + realCharWidth) / 256.0F,
                            (texcoordY + beginTexcoordY) / 256.0F);
                    GL11.glVertex2f(cPosX + realCharWidth / 2.0F + italicSize, cPosY + (beginTexcoordY / 2));
                    GL11.glTexCoord2f((texcoordX + realCharWidth) / 256.0F,
                            (texcoordY + beginTexcoordY + charHeightOnTexture) / 256.0F);
                    GL11.glVertex2f(cPosX + realCharWidth / 2.0F - italicSize,
                            cPosY + (beginTexcoordY / 2) + quadHeight);
                    GL11.glEnd();
                    return 0;//(realCharWidth + 0.02F) / 2.0F + 1.0F;
                }
            }
        case DISABLE:
            return (Float) invokeMethod("renderUnicodeChar", new Class[] { char.class, boolean.class }, c,
                    italic);
        case MCPX:
            //if(ThaiFixesUtils.isSpecialThaiChar(c)) posX.setFloat(this, posX.getFloat(this) - 5.0F);
            int posOnArray = c - THAI_CHAR_START;

            cPosX = posX.getFloat(this)
                    - (ThaiFixesUtils.isSpecialThaiChar(c) ? thaiCharWidth[posOnArray] : 0F); // get current position
            cPosY = posY.getFloat(this)
                    + (ThaiFixesUtils
                            .isSpecialThaiChar(c)
                                    ? (ThaiFixesUtils.isUpperThaiChar(c) ? -7.0F : 2.0F)
                                            - (!ThaiFixesUtils.isSpecialSpecialThaiChar(beforeChar)
                                                    ? (ThaiFixesUtils
                                                            .isSpecialThaiChar(beforeChar)
                                                                    ? 2.0F
                                                                    : (ThaiFixesUtils.isVeryLongTailThaiChar(
                                                                            beforeChar) ? 1.0F : 0.0F))
                                                    : 0.0F)
                                    : 0.0F);

            float texcoordX = (float) (posOnArray % 16 * 8);
            float texcoordY = (float) (posOnArray / 16 * 8);
            float italicSize = italic ? 1.0F : 0.0F;
            renderEngine.bindTexture(mcpx_font);
            float f3 = (float) thaiCharWidth[posOnArray] - 0.01F;
            GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
            GL11.glTexCoord2f(texcoordX / 128.0F, texcoordY / 128.0F);
            GL11.glVertex2f(cPosX + italicSize, cPosY);
            GL11.glTexCoord2f(texcoordX / 128.0F, (texcoordY + 7.99F) / 128.0F);
            GL11.glVertex2f(cPosX - italicSize, cPosY + 7.99F);
            GL11.glTexCoord2f((texcoordX + f3 - 1.0F) / 128.0F, texcoordY / 128.0F);
            GL11.glVertex2f(cPosX + f3 - 1.0F + italicSize, cPosY);
            GL11.glTexCoord2f((texcoordX + f3 - 1.0F) / 128.0F, (texcoordY + 7.99F) / 128.0F);
            GL11.glVertex2f(cPosX + f3 - 1.0F - italicSize, cPosY + 7.99F);
            GL11.glEnd();
            return ThaiFixesUtils.isSpecialThaiChar(c) ? 0 : (float) thaiCharWidth[posOnArray];
        }
    } catch (Exception e) {
        System.out.println("[ThaiFixes] Error during render an thai character '" + c + "'"
                + (italic ? " with italic style" : "") + ".");
        e.printStackTrace();
    }
    return 0.0F;
}

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);/*w w  w.j  av  a 2s.  co m*/

    // 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 drawQuad2(float displayWidth, float displayHeight, float scale) {
    float aspect = displayHeight / displayWidth;

    GL11.glBegin(GL11.GL_QUADS);//from ww w  . j  av  a  2s.  com

    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();
}