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:map.GameMap.java

License:Open Source License

public void drawWater() {
    GL11.glEnable(GL11.GL_BLEND);/*from www .  j a  va  2 s  .co  m*/
    GL11.glDepthMask(false);
    waterMaterial.bind();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glNormal3f(0, 0, 1.0f);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(0, 0, WATER_HEIGHT);
    GL11.glTexCoord2f(size, 0);
    GL11.glVertex3f(size, 0, WATER_HEIGHT);
    GL11.glTexCoord2f(size, size);
    GL11.glVertex3f(size, size, WATER_HEIGHT);
    GL11.glTexCoord2f(0, size);
    GL11.glVertex3f(0, size, WATER_HEIGHT);
    GL11.glEnd();
    GL11.glDepthMask(true);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:model.Triangle.java

License:Open Source License

public void draw() {
    if (tex[0] != null)
        GL11.glTexCoord2f(tex[0].x, tex[0].y);
    GL11.glNormal3f(norm[0].x, norm[0].y, norm[0].z);
    GL11.glVertex3f(pos[0].x, pos[0].y, pos[0].z);
    if (tex[1] != null)
        GL11.glTexCoord2f(tex[1].x, tex[1].y);
    GL11.glNormal3f(norm[1].x, norm[1].y, norm[1].z);
    GL11.glVertex3f(pos[1].x, pos[1].y, pos[1].z);
    if (tex[2] != null)
        GL11.glTexCoord2f(tex[2].x, tex[2].y);
    GL11.glNormal3f(norm[2].x, norm[2].y, norm[2].z);
    GL11.glVertex3f(pos[2].x, pos[2].y, pos[2].z);
}

From source file:mwisbest.openbase.gui.Button.java

License:Open Source License

@Override
public void render() {
    GL11.glPushMatrix();//from   ww w  .j  a v  a2s  .  c om
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDepthMask(false);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    if (Common.currentTextureID != this.texture.getTextureID()) {
        int texID = this.texture.getTextureID();
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
        Common.currentTextureID = texID;
    }
    GL11.glTranslatef(this.x, this.y, 0);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(0, 0);
    GL11.glTexCoord2f(0, this.texture.getHeight());
    GL11.glVertex2f(0, this.height);
    GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight());
    GL11.glVertex2f(this.width, this.height);
    GL11.glTexCoord2f(this.texture.getWidth(), 0);
    GL11.glVertex2f(this.width, 0);
    GL11.glEnd();
    GL11.glPopMatrix();
}

From source file:mwisbest.openbase.opengl.UtilsGL.java

License:Open Source License

/**
 * Draws the specified texture to positions x and y on the screen and scaled with the specified width and height
 * /*from  w ww.  j av a  2 s  . c  o  m*/
 * @param texture
 * @param x
 * @param y
 * @param width
 * @param height
 */
public static void drawTexture(Texture texture, int x, int y, int width, int height) {
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDepthMask(false);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    if (Common.currentTextureID != texture.getTextureID()) {
        int texID = texture.getTextureID();
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
        Common.currentTextureID = texID;
    }
    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();
}

From source file:myfirstgame.bullet.java

public void drawBullet(int x, int y, Texture tex) {
    tex.bind();/* w ww. j  av  a 2 s.c  om*/
    GL11.glBegin(GL_QUADS);
    GL11.glTexCoord2f(0, 1);
    glVertex2f(x, y);
    GL11.glTexCoord2f(1, 1);
    glVertex2f(x + sizeX, y);
    GL11.glTexCoord2f(1, 0);
    glVertex2f(x + sizeX, y + sizeY);
    GL11.glTexCoord2f(0, 0);
    glVertex2f(x, y + sizeY);
    GL11.glEnd();
}

From source file:myfirstgame.Game.java

public void menu(Texture tex) {
    int x = 200, y = 200;
    tex.bind();/*from www.j a v a  2 s  .c om*/
    GL11.glBegin(GL_QUADS);
    GL11.glTexCoord2f(0, 1);
    glVertex2i(x, y);
    GL11.glTexCoord2f(1, 1);
    glVertex2i(x + 200, y);
    GL11.glTexCoord2f(1, 0);
    glVertex2i(x + 200, y + 200);
    GL11.glTexCoord2f(0, 0);
    glVertex2i(x, y + 200);
    GL11.glEnd();
}

From source file:myfirstgame.grass.java

public void drawGrass(int x, int y, Texture tex) {
    //grass background
    gx = x;//from w w w.ja  va2  s.  com
    gy = y;

    tex.bind();
    GL11.glBegin(GL_QUADS);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex2i(gx, gy);
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex2i(gx + sizeX, gy);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex2i(gx + sizeX, gy + sizeY);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2i(gx, gy + sizeY);
    GL11.glEnd();
    outline();
}

From source file:myfirstgame.toolBar.java

public void draw(Texture tex) {

    tex.bind();//ww  w  .j a v  a2s  . com
    GL11.glBegin(GL_QUADS);
    GL11.glTexCoord2f(0, 1);
    glVertex2i(x, y);
    GL11.glTexCoord2f(1, 1);
    glVertex2i(x + 45, y);
    GL11.glTexCoord2f(1, 0);
    glVertex2i(x + 45, y + 250);
    GL11.glTexCoord2f(0, 0);
    glVertex2i(x, y + 250);
    GL11.glEnd();
}

From source file:name.martingeisse.stackd.client.gui.element.FillTexture.java

License:Open Source License

@Override
protected void draw() {
    GL11.glEnable(GL11.GL_TEXTURE_2D);//from w ww. j a  v a 2  s.c  o m
    GL11.glDisable(GL11.GL_BLEND);
    texture.glBindTexture();
    final int x = getAbsoluteX(), y = getAbsoluteY(), w = getWidth(), h = getHeight();
    final Gui gui = getGui();
    final float effectiveRepetitionLengthX = (repetitionLengthX < 1 ? gui.pixelsToUnitsInt(texture.getWidth())
            : repetitionLengthX);
    final float effectiveRepetitionLengthY = (repetitionLengthY < 1 ? gui.pixelsToUnitsInt(texture.getHeight())
            : repetitionLengthY);
    final float s = (w / effectiveRepetitionLengthX);
    final float t = (h / effectiveRepetitionLengthY);

    GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex2i(x, y);
    GL11.glTexCoord2f(s, 0.0f);
    GL11.glVertex2i(x + w, y);
    GL11.glTexCoord2f(s, t);
    GL11.glVertex2i(x + w, y + h);
    GL11.glTexCoord2f(0.0f, t);
    GL11.glVertex2i(x, y + h);
    GL11.glEnd();
}

From source file:name.martingeisse.swtlib.canvas.OpenGlImageBlockCanvas.java

License:Open Source License

@Override
protected void drawBlock(final int x, final int y) {
    palette.safeBind(getBlock(x, y));/*from  w w w  .ja va 2  s  .c o  m*/
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    // glBegin/glEnd must be called per block because of changing textures
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex2i(x, y);
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex2i(x + 1, y);
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex2i(x + 1, y + 1);
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex2i(x, y + 1);
    GL11.glEnd();

}