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:shadowmage.ancient_structures.client.render.RenderTools.java

License:Open Source License

public static void renderTexturedQuad(float x1, float y1, float x2, float y2, float u1, float v1, float u2,
        float v2) {
    GL11.glBegin(GL11.GL_QUADS);//from  w  w  w . j a  v a 2 s.  c o  m
    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex2f(x1, y1);
    GL11.glTexCoord2f(u1, v2);
    GL11.glVertex2f(x1, y2);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex2f(x2, y2);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex2f(x2, y1);
    GL11.glEnd();
}

From source file:shadowmage.meim.client.gui.GuiTextureElement.java

License:Open Source License

@Override
public void drawElement(int mouseX, int mouseY) {
    int x = renderPosX + guiLeft;
    int y = renderPosY + guiTop;
    int x1 = x;/*from  w  w w.j  av a2  s.  c o m*/
    int y1 = y;
    int x2 = x;
    int y2 = y + height;
    int x3 = x + width;
    int y3 = y + height;
    int x4 = x + width;
    int y4 = y;

    float pixX = 1.f / (float) image.getWidth();
    float pixY = 1.f / (float) image.getHeight();
    float u1, v1, u2, v2, u3, v3, u4, v4;
    float uw, uh;

    uw = scale;//image.getWidth() * pixX * scale;
    uh = scale;

    float u = pixX * (float) viewX;
    float v = pixY * (float) viewY;
    v = v > 1 ? 1 : v;

    u1 = u;
    v1 = v;
    u2 = u;
    v2 = v + uh;
    u3 = u + uw;
    v3 = v + uh;
    u4 = u + uw;
    v4 = v;

    bindTexture();
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex3f(x1, y1, 0);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex3f(x2, y2, 0);
    GL11.glTexCoord2f(u3, v3);
    GL11.glVertex3f(x3, y3, 0);
    GL11.glTexCoord2f(u4, v4);
    GL11.glVertex3f(x4, y4, 0);

    GL11.glEnd();
    resetBoundTexture();

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1.f, 0.f, 0.f, 1.f);
    GL11.glPointSize(5);
    GL11.glBegin(GL11.GL_POINTS);
    GL11.glVertex3f(x, y, 0.f);
    GL11.glEnd();
    GL11.glColor4f(1.f, 1.f, 1.f, 1.f);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:src.graphics.cutout.ImageSprite.java

License:Open Source License

public void renderTo(Rendering rendering) {
    ///*from w w w  .  j av a  2 s.c  o m*/
    //  Since we've disabled normal lighting, we have to 'fake it' using colour
    //  parameters:
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    final Colour c = colour == null ? Colour.WHITE : colour;
    if (c.a < 0) {
        GL11.glColor4f(c.r, c.g, c.b, 0 - c.a);
    } else {
        final Lighting l = rendering.lighting;
        GL11.glColor4f(c.r * fog * l.r(), c.g * fog * l.g(), c.b * fog * l.b(), c.a);
    }
    //
    //  Obtain the correct set of UV coordinates for the current frame-
    model.texture.bindTex();
    final float framesUV[][] = model.framesUV();
    final float texUV[] = framesUV[(int) animProgress];
    //
    //  TODO:  Consider replacing this with an aggregate method within the
    //  MeshBuffer class?  Re-implement RenderPass, in other words.
    GL11.glBegin(GL11.GL_TRIANGLES);
    int tI = 0;
    for (Vec3D vert : model.coords) {
        GL11.glTexCoord2f(texUV[tI++], texUV[tI++]);
        GL11.glVertex3f(position.x + (vert.x * scale), position.y + (vert.y * scale),
                position.z + (vert.z * scale));
    }
    GL11.glEnd();
}

From source file:src.graphics.sfx.SFX.java

License:Open Source License

protected void renderTex(Vec3D[] verts, Texture tex) {
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();//from   ww  w. j a va2s .co  m
    tex.bindTex();
    Vec3D v;
    GL11.glDepthMask(false);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    v = verts[0];
    GL11.glVertex3f(v.x, v.y, v.z);
    GL11.glTexCoord2f(0, 1);
    v = verts[1];
    GL11.glVertex3f(v.x, v.y, v.z);
    GL11.glTexCoord2f(1, 1);
    v = verts[2];
    GL11.glVertex3f(v.x, v.y, v.z);
    GL11.glTexCoord2f(1, 0);
    v = verts[3];
    GL11.glVertex3f(v.x, v.y, v.z);
    GL11.glEnd();
    GL11.glDepthMask(true);
}

From source file:src.graphics.space.Starfield.java

License:Open Source License

private void axisWithTransform(Mat3D transform, Texture tex, float radius) {
    final Vec3D tV = new Vec3D();
    tex.bindTex();//from w  w  w.  j  a  v  a 2  s.c  o m

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glNormal3f(0, 0, 0);

    transform.trans(tV.set(-1, -1, 0)).scale(1.1f * radius);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(tV.x, tV.y, tV.z);

    transform.trans(tV.set(1, -1, 0)).scale(1.1f * radius);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(tV.x, tV.y, tV.z);

    transform.trans(tV.set(1, 1, 0)).scale(1.1f * radius);
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(tV.x, tV.y, tV.z);

    transform.trans(tV.set(-1, 1, 0)).scale(1.1f * radius);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(tV.x, tV.y, tV.z);

    GL11.glEnd();
}

From source file:src.graphics.widgets.UINode.java

License:Open Source License

/**  Utility methods for drawing/graphic display:
  *//*w w  w  .  ja v a2  s  .co  m*/
final public static void drawQuad(float xmin, float ymin, float xmax, float ymax, float umin, float vmin,
        float umax, float vmax, float absDepth) {
    GL11.glTexCoord2f(umin, vmax);
    GL11.glVertex3f(xmin, ymin, absDepth);
    GL11.glTexCoord2f(umin, vmin);
    GL11.glVertex3f(xmin, ymax, absDepth);
    GL11.glTexCoord2f(umax, vmin);
    GL11.glVertex3f(xmax, ymax, absDepth);
    GL11.glTexCoord2f(umax, vmax);
    GL11.glVertex3f(xmax, ymin, absDepth);
}

From source file:src.user.Minimap.java

License:Open Source License

private void renderTex(float fadeVal) {
    ////from ww w.  ja va 2s .c  o m
    //You draw a diamond-shaped area around the four points-
    final float w = xdim(), h = ydim(), x = xpos(), y = ypos();
    GL11.glBegin(GL11.GL_QUADS);

    if (fadeVal == -1)
        GL11.glTexCoord2f(0, 0);
    else
        GL11.glTexCoord3f(0, 0, fadeVal);
    GL11.glVertex2f(x, y + (h / 2));

    if (fadeVal == -1)
        GL11.glTexCoord2f(0, 1);
    else
        GL11.glTexCoord3f(0, 1, fadeVal);
    GL11.glVertex2f(x + (w / 2), y + h);

    if (fadeVal == -1)
        GL11.glTexCoord2f(1, 1);
    else
        GL11.glTexCoord3f(1, 1, fadeVal);
    GL11.glVertex2f(x + w, y + (h / 2));

    if (fadeVal == -1)
        GL11.glTexCoord2f(1, 0);
    else
        GL11.glTexCoord3f(1, 0, fadeVal);
    GL11.glVertex2f(x + (w / 2), y);

    GL11.glEnd();
}

From source file:tectonicus.rasteriser.lwjgl.LwjglRasteriser.java

License:BSD License

@Override
public void texCoord(final float u, final float v) {
    GL11.glTexCoord2f(u, v);
}

From source file:terminal.gld.TrueTypeFont.java

License:Open Source License

private void drawQuad(float drawX, float drawY, float drawX2, float drawY2, float srcX, float srcY, float srcX2,
        float srcY2) {
    float DrawWidth = drawX2 - drawX;
    float DrawHeight = drawY2 - drawY;
    float TextureSrcX = -.01f + srcX / textureWidth;
    float TextureSrcY = srcY / textureHeight;
    float SrcWidth = srcX2 - srcX;
    float SrcHeight = srcY2 - srcY;
    float RenderWidth = (SrcWidth / textureWidth);
    float RenderHeight = (SrcHeight / textureHeight);

    GL11.glTexCoord2f(TextureSrcX, TextureSrcY);
    GL11.glVertex3f(drawX, drawY, .1f);//from ww  w.j  a va 2s  .  com
    GL11.glTexCoord2f(TextureSrcX, TextureSrcY + RenderHeight);
    GL11.glVertex3f(drawX, drawY + DrawHeight, .1f);
    GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY + RenderHeight);
    GL11.glVertex3f(drawX + DrawWidth, drawY + DrawHeight, .1f);
    GL11.glTexCoord2f(TextureSrcX + RenderWidth, TextureSrcY);
    GL11.glVertex3f(drawX + DrawWidth, drawY, .1f);
}

From source file:tileengine.MenuItem.java

public void drawBox() {
    for (int x = 0; x < 3; x++) {
        int selectedTexture = 197, selectedColumn = 0, selectedRow = 0;
        //Selvitetn milloin piirretn textboxin reunoja  
        if (x == 0) {
            selectedTexture = 196;//from   w w w .  j a va 2s  .  com
        }
        if (x == 2) {
            selectedTexture = 198;
        }

        if (selected) {
            selectedTexture += 3;
        }

        //pieni hksi for loopin avulla valitun texturen selvittmiseksi
        for (selectedColumn = selectedTexture; selectedColumn >= GameHandler.spriteSheetX
                / GameHandler.spriteSheetScale; selectedColumn -= 32) {
            selectedRow++;
        }

        float textureXOffSet = ((float) 1 / GameHandler.spriteSheetScale) * selectedColumn;
        float textureYOffSet = ((float) 1 / GameHandler.spriteSheetScale) * selectedRow;

        GL11.glTexCoord2f(textureXOffSet + (float) 1 / GameHandler.spriteSheetScale,
                textureYOffSet + (float) 1 / GameHandler.spriteSheetScale);
        GL11.glVertex2f(posX + 64 + x * 64, posY);

        GL11.glTexCoord2f(textureXOffSet, textureYOffSet + (float) 1 / GameHandler.spriteSheetScale);
        GL11.glVertex2f(posX + x * 64, posY);

        GL11.glTexCoord2f(textureXOffSet, textureYOffSet);
        GL11.glVertex2f(posX + x * 64, posY + 64);

        GL11.glTexCoord2f(textureXOffSet + (float) 1 / GameHandler.spriteSheetScale, textureYOffSet);
        GL11.glVertex2f(posX + 64 + x * 64, posY + 64);

    }

}