Example usage for org.lwjgl.opengl GL11 glBindTexture

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

Introduction

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

Prototype

public static void glBindTexture(@NativeType("GLenum") int target, @NativeType("GLuint") int texture) 

Source Link

Document

Binds the a texture to a texture target.

Usage

From source file:org.getspout.spout.gui.about.GuiAbout.java

License:LGPL

private void overlayBackground(int var1, int var2, int var3, int var4) {
    Tessellator var5 = Tessellator.instance;
    GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, this.mc.renderEngine.getTexture("/gui/background.png"));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    float var6 = 32.0F;
    var5.startDrawingQuads();
    var5.setColorRGBA_I(4210752, var4);
    var5.addVertexWithUV(0.0D, (double) var2, 0.0D, 0.0D, (double) ((float) var2 / var6));
    var5.addVertexWithUV((double) this.width, (double) var2, 0.0D, (double) ((float) this.width / var6),
            (double) ((float) var2 / var6));
    var5.setColorRGBA_I(4210752, var3);
    var5.addVertexWithUV((double) this.width, (double) var1, 0.0D, (double) ((float) this.width / var6),
            (double) ((float) var1 / var6));
    var5.addVertexWithUV(0.0D, (double) var1, 0.0D, 0.0D, (double) ((float) var1 / var6));
    var5.draw();/*from ww  w. ja v a2s  . com*/
}

From source file:org.getspout.spout.gui.CustomGuiButton.java

License:Open Source License

@Override
public void drawButton(Minecraft game, int mouseX, int mouseY) {
    if (button.isVisible()) {
        FontRenderer font = game.fontRenderer;
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, game.renderEngine.getTexture("/gui/gui.png"));
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) button.getScreenX(), (float) button.getScreenY(), 0);
        float width = (float) (button.getWidth() < 200 ? button.getWidth() : 200);
        GL11.glScalef((float) button.getWidth() / width, (float) button.getHeight() / 20f, 1);

        boolean hovering = mouseX >= button.getScreenX() && mouseY >= button.getScreenY()
                && mouseX < button.getScreenX() + button.getWidth()
                && mouseY < button.getScreenY() + button.getHeight();
        int hoverState = this.getHoverState(hovering);
        this.drawTexturedModalRect(0, 0, 0, 46 + hoverState * 20, (int) Math.ceil(width / 2), 20);
        this.drawTexturedModalRect((int) Math.floor(width / 2), 0, 200 - (int) Math.ceil(width / 2),
                46 + hoverState * 20, (int) Math.ceil(width / 2), 20);
        this.mouseDragged(game, mouseX, mouseY);
        Color color = button.getColor();
        if (!button.isEnabled()) {
            color = button.getDisabledColor();
        } else if (hovering) {
            color = button.getHoverColor();
        }/*  w  w w .j  a  v a 2 s . c  o m*/
        int left = (int) 5;
        switch (button.getAlign()) {
        case TOP_CENTER:
        case CENTER_CENTER:
        case BOTTOM_CENTER:
            left = (int) ((width / 2) - (font.getStringWidth(button.getText()) / 2));
            break;
        case TOP_RIGHT:
        case CENTER_RIGHT:
        case BOTTOM_RIGHT:
            left = (int) (width - font.getStringWidth(button.getText())) - 5;
            break;
        }
        this.drawString(font, button.getText(), left, 6, color.toInt());
    }
}

From source file:org.getspout.spout.gui.CustomGuiSlider.java

License:Open Source License

@Override
public void drawButton(Minecraft game, int mouseX, int mouseY) {
    if (slider.isVisible()) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, game.renderEngine.getTexture("/gui/gui.png"));
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        float width = (float) (slider.getWidth() < 200 ? slider.getWidth() : 200);
        GL11.glTranslatef((float) slider.getScreenX(), (float) slider.getScreenY(), 0);
        GL11.glScalef((float) slider.getWidth() / width, (float) slider.getHeight() / 20f, 1);

        boolean hovering = mouseX >= slider.getScreenX() && mouseY >= slider.getScreenY()
                && mouseX < slider.getScreenX() + slider.getWidth()
                && mouseY < slider.getScreenY() + slider.getHeight();

        int hoverState = this.getHoverState(hovering);
        this.drawTexturedModalRect(0, 0, 0, 46 + hoverState * 20, (int) Math.ceil(width / 2), 20);
        this.drawTexturedModalRect((int) Math.floor(width / 2), 0, 200 - (int) Math.ceil(width / 2),
                46 + hoverState * 20, (int) Math.ceil(width / 2), 20);
        this.mouseDragged(game, mouseX, mouseY);
    }/*from  www.ja va  2 s . c  o  m*/
}

From source file:org.getspout.spout.gui.GenericTexture.java

License:Open Source License

@Override
public void render() {
    String path = CustomTextureManager.getTextureFromUrl(getUrl());
    if (path == null) {
        return;// ww  w. j  a  va 2 s  .c om
    }
    if (texture == null) {
        texture = CustomTextureManager.getTextureFromPath(path);
        if (texture == null) {
            return;
        }
    }
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glTranslatef((float) getScreenX(), (float) getScreenY(), 0); //moves texture into place
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID());
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(0.0D, getHeight(), -90, 0.0D, 0.0D); //draw corners
    tessellator.addVertexWithUV(getWidth(), getHeight(), -90, texture.getWidth(), 0.0D);
    tessellator.addVertexWithUV(getWidth(), 0.0D, -90, texture.getWidth(), texture.getHeight());
    tessellator.addVertexWithUV(0.0D, 0.0D, -90, 0.0D, texture.getHeight());
    tessellator.draw();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}

From source file:org.getspout.spout.gui.server.GuiServerInfo.java

License:Open Source License

@Override
public void drawScreen(int var1, int var2, float var3) {
    this.drawDefaultBackground();

    if (flag != null) {
        GL11.glPushMatrix();//ww w  . j  av a 2s  .  c o  m
        GL11.glTranslatef(this.width / 2 + 150, this.height / 2 - 84, 0);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDepthMask(false);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, flag.getTextureID());
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(0.0D, 6, -90, 0.0D, 0.0D); // draw corners
        tessellator.addVertexWithUV(9, 6, -90, flag.getWidth(), 0.0D);
        tessellator.addVertexWithUV(9, 0.0D, -90, flag.getWidth(), flag.getHeight());
        tessellator.addVertexWithUV(0.0D, 0.0D, -90, 0.0D, flag.getHeight());
        tessellator.draw();
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glPopMatrix();
    } else {
        flag = CustomTextureManager.getTextureFromUrl(
                "http://servers.getspout.org/images/flags/" + info.country.toLowerCase() + ".png");
    }

    if (image != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(this.width / 2 - 110 - (image.getImageWidth() / 4),
                this.height / 2 - 20 - (image.getImageHeight() / 4), 0);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDepthMask(false);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, image.getTextureID());
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(0.0D, image.getImageHeight() / 2, -90, 0.0D, 0.0D); // draw corners
        tessellator.addVertexWithUV(image.getImageWidth() / 2, image.getImageHeight() / 2, -90,
                image.getWidth(), 0.0D);
        tessellator.addVertexWithUV(image.getImageWidth() / 2, 0.0D, -90, image.getWidth(), image.getHeight());
        tessellator.addVertexWithUV(0.0D, 0.0D, -90, 0.0D, image.getHeight());
        tessellator.draw();
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glPopMatrix();
    } else {
        image = CustomTextureManager.getTextureFromUrl(url);
    }

    this.drawString(SpoutClient.getHandle().fontRenderer, "Server IP:Port", this.width / 2 - 20,
            this.height / 2 - 95, 0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.getFullIp(), this.width / 2 - 10,
            this.height / 2 - 85, 0xA0A0A0);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Name", this.width / 2 - 20, this.height / 2 - 70,
            0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.name, this.width / 2 - 10, this.height / 2 - 60,
            0xA0A0A0);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Country", this.width / 2 + 120, this.height / 2 - 95,
            0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.country, this.width / 2 + 130,
            this.height / 2 - 85, 0xA0A0A0);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Players", this.width / 2 + 120, this.height / 2 - 70,
            0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.players + "/" + info.maxPlayers,
            this.width / 2 + 130, this.height / 2 - 60, 0xA0A0A0);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Response", this.width / 2 - 20, this.height / 2 - 45,
            0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.msg + ChatColor.GRAY + " (" + info.ping + "ms)",
            this.width / 2 - 10, this.height / 2 - 35, 0xA0A0A0);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Website", this.width / 2 - 20, this.height / 2 - 20,
            0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, site, this.width / 2 - 10, this.height / 2 - 10,
            hoveringSite ? 0x0099FF : 0x40FFFF);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Forum Post", this.width / 2 - 20,
            this.height / 2 + 5, 0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, forum, this.width / 2 - 10, this.height / 2 + 15,
            hoveringForum ? 0x0099FF : 0x40FFFF);

    this.drawString(SpoutClient.getHandle().fontRenderer, "Description", this.width / 2 - 20,
            this.height / 2 + 30, 0xFFFFFF);
    this.drawString(SpoutClient.getHandle().fontRenderer, info.description, this.width / 2 - 10,
            this.height / 2 + 40, 0xA0A0A0);

    super.drawScreen(var1, var2, var3);
}

From source file:org.getspout.spout.item.CustomEntityDiggingFX.java

License:Open Source License

public void renderParticle(Tessellator var1, float var2, float var3, float var4, float var5, float var6,
        float var7) {
    GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, textureBinding.getTextureID());
    Tessellator var10 = Tessellator.instance;
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    var10.startDrawingQuads();

    float var12 = 0.1F * this.particleScale;
    float var13 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) var2 - interpPosX);
    float var14 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) var2 - interpPosY);
    float var15 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) var2 - interpPosZ);
    float var16 = 1.0F;
    for (int i = 0; i < design.getX().length; i++) {

        var1.setColorOpaque_F(var16 * this.particleRed, var16 * this.particleGreen, var16 * this.particleBlue);
        var1.addVertexWithUV((double) (var13 - var3 * var12 - var6 * var12), (double) (var14 - var4 * var12),
                (double) (var15 - var5 * var12 - var7 * var12), design.getTextureXPos()[i][0],
                design.getTextureYPos()[i][0]);
        var1.addVertexWithUV((double) (var13 - var3 * var12 + var6 * var12), (double) (var14 + var4 * var12),
                (double) (var15 - var5 * var12 + var7 * var12), design.getTextureXPos()[i][1],
                design.getTextureYPos()[i][1]);
        var1.addVertexWithUV((double) (var13 + var3 * var12 + var6 * var12), (double) (var14 + var4 * var12),
                (double) (var15 + var5 * var12 + var7 * var12), design.getTextureXPos()[i][2],
                design.getTextureYPos()[i][2]);
        var1.addVertexWithUV((double) (var13 + var3 * var12 - var6 * var12), (double) (var14 - var4 * var12),
                (double) (var15 + var5 * var12 - var7 * var12), design.getTextureXPos()[i][3],
                design.getTextureYPos()[i][3]);
    }//from ww  w. j  a  v  a2 s.  c o m

    var10.draw();
}

From source file:org.jmangos.tools.openGL.Texture.java

License:Open Source License

/**
 * Bind the specified GL context to a texture
 * //from  www . j  a v  a2 s .c o  m
 * @param gl
 *        The GL context to bind to
 */
public void bind() {

    GL11.glBindTexture(this.target, this.textureID);
}

From source file:org.jmangos.tools.openGL.TextureLoader.java

License:Open Source License

/**
 * Load a texture into OpenGL from a image reference on disk.
 * /* ww  w  .j a  v a 2 s  .  c om*/
 * @param resourceName
 *        The location of the resource to load
 * @param target
 *        The GL target to load the texture against
 * @param dstPixelFormat
 *        The pixel format of the screen
 * @param minFilter
 *        The minimising filter
 * @param magFilter
 *        The magnification filter
 * @return The loaded texture
 * @throws IOException
 *         Indicates a failure to access the resource
 */
public Texture getTexture(final String resourceName, final boolean injar, final int target,
        final int dstPixelFormat, final int minFilter, final int magFilter) throws IOException {

    int srcPixelFormat = 0;

    // create the texture ID for this texture
    final int textureID = createTextureID();
    final Texture texture = new Texture(target, textureID);

    // bind this texture
    GL11.glBindTexture(target, textureID);

    final BufferedImage bufferedImage = loadImage(resourceName, injar);
    texture.setWidth(bufferedImage.getWidth());
    texture.setHeight(bufferedImage.getHeight());

    if (bufferedImage.getColorModel().hasAlpha()) {
        srcPixelFormat = GL11.GL_RGBA;
    } else {
        srcPixelFormat = GL11.GL_RGB;
    }

    // convert that image into a byte buffer of texture data
    final ByteBuffer textureBuffer = convertImageData(bufferedImage, texture);

    if (target == GL11.GL_TEXTURE_2D) {
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
    }

    // produce a texture from the byte buffer
    /*
     * GL11.glTexImage2D(target, 0, dstPixelFormat,
     * get2Fold(bufferedImage.getWidth()),
     * get2Fold(bufferedImage.getHeight()), 0, srcPixelFormat,
     * GL11.GL_UNSIGNED_BYTE,
     * textureBuffer );
     */

    GLU.gluBuild2DMipmaps(target, dstPixelFormat, get2Fold(bufferedImage.getWidth()),
            get2Fold(bufferedImage.getHeight()), srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer);

    return texture;
}

From source file:org.jmangos.tools.openGL.TextureLoader.java

License:Open Source License

/**
 * Load a texture into OpenGL from a BufferedImage
 * /*from  ww  w . j a v  a 2  s.co m*/
 * @param resourceName
 *        The location of the resource to load
 * @param target
 *        The GL target to load the texture against
 * @param dstPixelFormat
 *        The pixel format of the screen
 * @param minFilter
 *        The minimising filter
 * @param magFilter
 *        The magnification filter
 * @return The loaded texture
 * @throws IOException
 *         Indicates a failure to access the resource
 */
public Texture getTexture(final BufferedImage resourceimage, final int target, final int dstPixelFormat,
        final int minFilter, final int magFilter) throws IOException {

    int srcPixelFormat = 0;

    // create the texture ID for this texture
    final int textureID = createTextureID();
    final Texture texture = new Texture(target, textureID);

    // bind this texture
    GL11.glBindTexture(target, textureID);

    final BufferedImage bufferedImage = resourceimage;
    texture.setWidth(bufferedImage.getWidth());
    texture.setHeight(bufferedImage.getHeight());

    if (bufferedImage.getColorModel().hasAlpha()) {
        srcPixelFormat = GL11.GL_RGBA;
    } else {
        srcPixelFormat = GL11.GL_RGB;
    }

    // convert that image into a byte buffer of texture data
    final ByteBuffer textureBuffer = convertImageData(bufferedImage, texture);

    if (target == GL11.GL_TEXTURE_2D) {
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
    }

    // produce a texture from the byte buffer
    /*
     * GL11.glTexImage2D(target, 0, dstPixelFormat,
     * get2Fold(bufferedImage.getWidth()),
     * get2Fold(bufferedImage.getHeight()), 0, srcPixelFormat,
     * GL11.GL_UNSIGNED_BYTE,
     * textureBuffer );
     */

    GLU.gluBuild2DMipmaps(target, dstPixelFormat, get2Fold(bufferedImage.getWidth()),
            get2Fold(bufferedImage.getHeight()), srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer);

    return texture;
}

From source file:org.jmangos.tools.openGL.TextureLoader.java

License:Open Source License

/**
 * Load a texture into OpenGL from a BufferedImage
 * //from   www  .j  a  va2s  .com
 * @param resourceName
 *        The location of the resource to load
 * @param target
 *        The GL target to load the texture against
 * @param dstPixelFormat
 *        The pixel format of the screen
 * @param minFilter
 *        The minimising filter
 * @param magFilter
 *        The magnification filter
 * @return The loaded texture
 * @throws IOException
 *         Indicates a failure to access the resource
 */
public Texture getNMMTexture(final BufferedImage resourceimage, final int target, final int dstPixelFormat,
        final int minFilter, final int magFilter) throws IOException {

    int srcPixelFormat = 0;

    // create the texture ID for this texture
    final int textureID = createTextureID();
    final Texture texture = new Texture(target, textureID);

    // bind this texture
    GL11.glBindTexture(target, textureID);

    final BufferedImage bufferedImage = resourceimage;
    texture.setWidth(bufferedImage.getWidth());
    texture.setHeight(bufferedImage.getHeight());

    if (bufferedImage.getColorModel().hasAlpha()) {
        srcPixelFormat = GL11.GL_RGBA;
    } else {
        srcPixelFormat = GL11.GL_RGB;
    }

    // convert that image into a byte buffer of texture data
    final ByteBuffer textureBuffer = convertImageData(bufferedImage, texture);

    if (target == GL11.GL_TEXTURE_2D) {
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
    }

    // produce a texture from the byte buffer
    GL11.glTexImage2D(target, 0, dstPixelFormat, get2Fold(bufferedImage.getWidth()),
            get2Fold(bufferedImage.getHeight()), 0, srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer);

    return texture;
}