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:fi.conf.ae.gl.GLGraphicRoutines.java

License:LGPL

public static void drawCube(float r) {
    r /= 2f;//w  w  w.  j a v  a  2  s.c o  m
    GL11.glBegin(GL11.GL_QUADS);
    // Front Face
    GL11.glNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(-r, -r, r); // Point 1 (Front)
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(r, -r, r); // Point 2 (Front)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(r, r, r); // Point 3 (Front)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-r, r, r); // Point 4 (Front)
    // Back Face
    GL11.glNormal3f(0.0f, 0.0f, -1.0f); // Normal Pointing Away From Viewer
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(-r, -r, -r); // Point 1 (Back)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(-r, r, -r); // Point 2 (Back)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(r, r, -r); // Point 3 (Back)
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(r, -r, -r); // Point 4 (Back)
    // Top Face
    GL11.glNormal3f(0.0f, 1.0f, 0.0f); // Normal Pointing Up
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-r, r, -r); // Point 1 (Top)
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(-r, r, r); // Point 2 (Top)
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(r, r, r); // Point 3 (Top)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(r, r, -r); // Point 4 (Top)
    // Bottom Face
    GL11.glNormal3f(0.0f, -1.0f, 0.0f); // Normal Pointing Down
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(-r, -r, -r); // Point 1 (Bottom)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(r, -r, -r); // Point 2 (Bottom)
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(r, -r, r); // Point 3 (Bottom)
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(-r, -r, r); // Point 4 (Bottom)
    // Right face
    GL11.glNormal3f(1.0f, 0.0f, 0.0f); // Normal Pointing Right
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(r, -r, -r); // Point 1 (Right)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(r, r, -r); // Point 2 (Right)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(r, r, r); // Point 3 (Right)
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(r, -r, r); // Point 4 (Right)
    // Left Face
    GL11.glNormal3f(-1.0f, 0.0f, 0.0f); // Normal Pointing Left
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(-r, -r, -r); // Point 1 (Left)
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(-r, -r, r); // Point 2 (Left)
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(-r, r, r); // Point 3 (Left)
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-r, r, -r); // Point 4 (Left)
    // Done Drawing Quads
    GL11.glEnd();

}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DSprite.java

License:Open Source License

@Override
protected void doDisplay(V3DCamera camera) {

    if (!enableColor) {
        GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
        GL11.glColor4f(1, 1, 1, opacity);
    }/*from   w w w.  j  av  a  2 s  . c  om*/

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

    GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f);
    GL11.glEnable(GL11.GL_ALPHA_TEST);

    if (disableRotation) {
        camera.disableRotation();
    }

    float w = 0.5f * size.x * image.getWidth();
    float h = 0.5f * size.y * image.getHeight();

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getID());
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex3f(-w, -h, 0.0f);
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(w, -h, 0.0f);
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(w, h, 0.0f);
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-w, h, 0.0f);
    GL11.glEnd();

    if (disableRotation) {
        camera.enableRotation();
    }

    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    if (!enableColor) {
        GL11.glPopAttrib();
    }
}

From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java

License:Open Source License

private void draw3dQuadList() {
    int quadCount = buffer.getInt();
    GL11.glBegin(GL11.GL_QUADS);/*from w w w.  j a  v  a 2s  .c om*/

    for (int quadIndex = 0; quadIndex < quadCount; quadIndex++) {
        for (int i = 0; i < 4; i++) {
            GL11.glTexCoord2f(buffer.getFloat(), buffer.getFloat());
            GL11.glNormal3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
            GL11.glVertex3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());

        }
    }
    GL11.glEnd();
}

From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java

License:Open Source License

private void draw3dTriangleList() {
    int triangleCount = buffer.getInt();

    GL11.glBegin(GL11.GL_TRIANGLES);/*from   ww  w  .  ja va2 s .  c o  m*/
    for (int triangleIndex = 0; triangleIndex < triangleCount; triangleIndex++) {

        for (int i = 0; i < 3; i++) {
            GL11.glTexCoord2f(buffer.getFloat(), buffer.getFloat());
            GL11.glNormal3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
            GL11.glVertex3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
        }
    }
    GL11.glEnd();
}

From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java

License:Open Source License

private void draw3dPolygonList() {
    int polygonCount = buffer.getInt();

    for (int polygonIndex = 0; polygonIndex < polygonCount; polygonIndex++) {
        GL11.glBegin(GL11.GL_POLYGON);/*from  w w  w.j  a va 2  s  . c o m*/
        int vertexCount = buffer.getInt();
        for (int i = 0; i < vertexCount; i++) {
            GL11.glTexCoord2f(buffer.getFloat(), buffer.getFloat());
            GL11.glNormal3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
            GL11.glVertex3f(buffer.getFloat(), buffer.getFloat(), buffer.getFloat());
        }
        GL11.glEnd();
    }
}

From source file:fr.def.iss.vd2.lib_v3d.v3draw.V3DrawReader.java

License:Open Source License

private void drawRegistrated3dConcavePolygon() {
    int polygonIndex = buffer.getInt();
    Tesselation tesselation = concavePolygonList.get(polygonIndex);

    List<Integer> vertexTypeList = tesselation.getVertexTypeList();

    for (int i = 0; i < vertexTypeList.size(); i++) {

        List<V3DrawVertex> vertexList = tesselation.getVertexListList().get(i);

        GL11.glBegin(vertexTypeList.get(i));
        for (V3DrawVertex vertex : vertexList) {
            GL11.glTexCoord2f(vertex.texture.x, vertex.texture.y);
            GL11.glNormal3f(vertex.normal.x, vertex.normal.y, vertex.normal.z);
            GL11.glVertex3f(vertex.position.x, vertex.position.y, vertex.position.z);
        }/*from   w w w.j a v  a2 s.  c o  m*/
        GL11.glEnd();
    }
}

From source file:fr.theshark34.sharkengine.ui.components.Checkbox.java

License:Apache License

/**
 * Draw the checkbox/*from   w  w  w .  j a v a 2s. c o  m*/
 */
public void draw() {
    // Enabling blending
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    // Being sure that texturing is disabled
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    // Picking white color
    GL11.glColor3f(1.0F, 1.0F, 1.0F);

    // Drawing the checkbox
    GL11.glBegin(GL11.GL_QUADS);
    {
        GL11.glVertex2f(x, y);
        GL11.glVertex2f(x + width, y);
        GL11.glVertex2f(x + width, y + height);
        GL11.glVertex2f(x, y + height);
    }
    GL11.glEnd();

    // Drawing the text
    this.font.drawString(x + 25, y + (this.height - this.font.getHeight(text)) / 2, text);

    // Being sure that texturing is enabled
    GL11.glEnable(GL11.GL_TEXTURE_2D);

    // If the mouse is on the checkbox
    if (Mouse.getX() > this.x && Mouse.getX() < this.x + this.width
            && Mouse.getY() < Display.getHeight() - this.y
            && Mouse.getY() > Display.getHeight() - this.y - this.height)
        // If the mouse clicked and clicked is false, setting coched
        // to its oposite and setting clicked to true, so it will do
        // it one time
        if (Mouse.isButtonDown(0)) {
            if (!clicked) {
                clicked = true;
                coched = !coched;
            }
        } else
            // If mouse isn't on it, setting clicked to false
            clicked = false;

    // Checking if the checkbox is coched
    if (coched) {
        // Drawing coched checkbox texture
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, cochedcb.getTextureID());

        // Drawing the image
        GL11.glBegin(GL11.GL_QUADS);
        {
            GL11.glTexCoord2f(0.0f, 0.0f);
            GL11.glVertex2f(x, y);
            GL11.glTexCoord2f(1.0f, 0.0f);
            GL11.glVertex2f(x + width, y);
            GL11.glTexCoord2f(1.0f, 1.0f);
            GL11.glVertex2f(x + width, y + height);
            GL11.glTexCoord2f(0.0f, 1.0f);
            GL11.glVertex2f(x, y + height);
        }
        GL11.glEnd();
    }

    // Disabling texture
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    // Disabling blending
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:fr.theshark34.sharkengine.ui.components.Image.java

License:Apache License

/**
 * Draw it/*from   w  ww .ja v  a  2  s. co  m*/
 */
@Override
public void draw() {
    // Without this, image can render strangely
    GL11.glColor3f(1.0F, 1.0F, 1.0F);

    // Enabling blend and texture
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID());

    // Drawing the image
    GL11.glBegin(GL11.GL_QUADS);
    {
        GL11.glTexCoord2f(0.0f, 0.0f);
        GL11.glVertex2f(x, y);
        GL11.glTexCoord2f(1.0f, 0.0f);
        GL11.glVertex2f(x + width, y);
        GL11.glTexCoord2f(1.0f, 1.0f);
        GL11.glVertex2f(x + width, y + height);
        GL11.glTexCoord2f(0.0f, 1.0f);
        GL11.glVertex2f(x, y + height);
    }
    GL11.glEnd();

    // Disabling blend and texture
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
}

From source file:game.core.blockmap.BlockMapBehavior.java

License:Open Source License

@Override
public void draw(GameObject target) {
    if (textureProvider == null) {
        return;//w  ww .  ja  va2 s  .  co  m
    }
    int w = Math.min(width, 100);
    int h = Math.min(height, 30);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
    for (int x = 0; x < w; x++) {
        for (int y = 0; y < h; y++) {
            Texture texture = textureProvider.getBlockTexture(getBlock(x, y));
            if (texture == null) {
                continue;
            }
            texture.glBindTexture();
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glTexCoord2f(0.0f, 1.0f);
            GL11.glVertex2i(x, y);
            GL11.glTexCoord2f(1.0f, 1.0f);
            GL11.glVertex2i(x + 1, y);
            GL11.glTexCoord2f(1.0f, 0.0f);
            GL11.glVertex2i(x + 1, y + 1);
            GL11.glTexCoord2f(0.0f, 0.0f);
            GL11.glVertex2i(x, y + 1);
            GL11.glEnd();
        }
    }
}

From source file:game.engine.gfx.Sprite.java

License:Open Source License

/**
 * Calls glTexCoord() / glVertex() on the sprite vertices, assuming the hotspot is at (0, 0).
 *//*from   w  w w  .  j  a  v  a 2s .c  o m*/
public void glVertices() {
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex2f(-leftExtent, -topExtent);
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex2f(rightExtent, -topExtent);
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex2f(rightExtent, bottomExtent);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex2f(-leftExtent, bottomExtent);
}