Example usage for org.lwjgl.opengl GL11 glBlendFunc

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

Introduction

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

Prototype

public static void glBlendFunc(@NativeType("GLenum") int sfactor, @NativeType("GLenum") int dfactor) 

Source Link

Document

Specifies the weighting factors used by the blend equation, for both RGB and alpha functions and for all draw buffers.

Usage

From source file:buildcraft.robots.render.RenderRobot.java

License:Minecraft Mod Public

private void doRenderRobot(float factor, TextureManager texManager) {
    box.render(factor);//from  ww w . j  ava 2 s . c  o m

    GL11.glPushMatrix();
    texManager.bindTexture(overlay);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
    GL11.glDepthMask(true);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 61680, 0);
    box.render(factor);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:buildcraft.silicon.render.RenderLaserBlock.java

License:Minecraft Mod Public

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
    TileLaser laser = (TileLaser) tileentity;

    if (laser != null) {
        GL11.glPushMatrix();//  w w  w .jav  a2 s  .  c  o  m
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        GL11.glTranslated(x, y, z);
        GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord);

        GL11.glPushMatrix();
        RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, laser.laser,
                laser.getTexture());
        GL11.glPopMatrix();

        //GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopAttrib();
        GL11.glPopMatrix();
    }
}

From source file:buildcraft.transport.render.PipeItemRenderer.java

License:Minecraft Mod Public

private void renderPipeItem(RenderBlocks render, ItemStack item, float translateX, float translateY,
        float translateZ) {
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT); //don't break other mods' guis when holding a pipe
    //force transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);/*from w w  w.  j a v a 2  s .c om*/

    // GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
    Tessellator tessellator = Tessellator.instance;

    Block block = BuildCraftTransport.genericPipeBlock;
    IIcon icon = item.getItem().getIconFromDamage(0);

    if (icon == null) {
        icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager()
                .getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
    }

    block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS,
            CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
    block.setBlockBoundsForItemRender();
    render.setRenderBoundsFromBlock(block);

    GL11.glTranslatef(translateX, translateY, translateZ);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1F, 0.0F);
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

    GL11.glPopAttrib(); // nicely leave the rendering how it was
}

From source file:buildcraft.transport.render.PipeRendererTESR.java

License:Minecraft Mod Public

private void renderFluids(Pipe<PipeTransportFluids> pipe, double x, double y, double z) {
    PipeTransportFluids trans = pipe.transport;

    boolean needsRender = false;
    for (int i = 0; i < 7; ++i) {
        FluidStack fluidStack = trans.renderCache[i];
        if (fluidStack != null && fluidStack.amount > 0) {
            needsRender = true;//www . j a v a  2s  .  co m
            break;
        }
    }

    if (!needsRender) {
        return;
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glTranslatef((float) x, (float) y, (float) z);

    // sides

    boolean sides = false, above = false;

    for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
        int i = side.ordinal();

        FluidStack fluidStack = trans.renderCache[i];

        if (fluidStack == null || fluidStack.amount <= 0) {
            continue;
        }

        if (!pipe.container.isPipeConnected(side)) {
            continue;
        }

        DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.getWorldObj());

        if (d == null) {
            continue;
        }

        int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));

        GL11.glPushMatrix();
        int list = 0;

        switch (ForgeDirection.VALID_DIRECTIONS[i]) {
        case UP:
            above = true;
            list = d.sideVertical[stage];
            break;
        case DOWN:
            GL11.glTranslatef(0, -0.75F, 0);
            list = d.sideVertical[stage];
            break;
        case EAST:
        case WEST:
        case SOUTH:
        case NORTH:
            sides = true;
            // Yes, this is kind of ugly, but was easier than transform the coordinates above.
            GL11.glTranslatef(0.5F, 0.0F, 0.5F);
            GL11.glRotatef(angleY[i], 0, 1, 0);
            GL11.glRotatef(angleZ[i], 0, 0, 1);
            GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
            list = d.sideHorizontal[stage];
            break;
        default:
        }
        bindTexture(TextureMap.locationBlocksTexture);
        RenderUtils.setGLColorFromInt(trans.colorRenderCache[i]);
        GL11.glCallList(list);
        GL11.glPopMatrix();
    }
    // CENTER
    FluidStack fluidStack = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()];

    if (fluidStack != null && fluidStack.amount > 0) {
        DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.getWorldObj());

        if (d != null) {
            int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));

            bindTexture(TextureMap.locationBlocksTexture);
            RenderUtils.setGLColorFromInt(trans.colorRenderCache[ForgeDirection.UNKNOWN.ordinal()]);

            if (above) {
                GL11.glCallList(d.centerVertical[stage]);
            }

            if (!above || sides) {
                GL11.glCallList(d.centerHorizontal[stage]);
            }
        }

    }

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}

From source file:buildcraftAdditions.client.models.ModelKineticDuster.java

License:GNU General Public License

@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
    this.cube.render(f5);
    this.shape11_2.render(f5);
    GL11.glPushMatrix();//  w  w w  .ja  v a 2 s . c om
    GL11.glTranslatef(this.shape24_3.offsetX, this.shape24_3.offsetY, this.shape24_3.offsetZ);
    GL11.glTranslatef(this.shape24_3.rotationPointX * f5, this.shape24_3.rotationPointY * f5,
            this.shape24_3.rotationPointZ * f5);
    GL11.glScaled(1.0D, 6.0D, 14.0D);
    GL11.glTranslatef(-this.shape24_3.offsetX, -this.shape24_3.offsetY, -this.shape24_3.offsetZ);
    GL11.glTranslatef(-this.shape24_3.rotationPointX * f5, -this.shape24_3.rotationPointY * f5,
            -this.shape24_3.rotationPointZ * f5);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.2F);
    this.shape24_3.render(f5);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
    this.shape11_7.render(f5);
    this.shape11_5.render(f5);
    this.shape11_1.render(f5);
    GL11.glPushMatrix();
    GL11.glTranslatef(this.shape24_1.offsetX, this.shape24_1.offsetY, this.shape24_1.offsetZ);
    GL11.glTranslatef(this.shape24_1.rotationPointX * f5, this.shape24_1.rotationPointY * f5,
            this.shape24_1.rotationPointZ * f5);
    GL11.glScaled(1.0D, 6.0D, 14.0D);
    GL11.glTranslatef(-this.shape24_1.offsetX, -this.shape24_1.offsetY, -this.shape24_1.offsetZ);
    GL11.glTranslatef(-this.shape24_1.rotationPointX * f5, -this.shape24_1.rotationPointY * f5,
            -this.shape24_1.rotationPointZ * f5);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.2F);
    this.shape24_1.render(f5);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
    GL11.glPushMatrix();
    GL11.glTranslatef(this.shape24_2.offsetX, this.shape24_2.offsetY, this.shape24_2.offsetZ);
    GL11.glTranslatef(this.shape24_2.rotationPointX * f5, this.shape24_2.rotationPointY * f5,
            this.shape24_2.rotationPointZ * f5);
    GL11.glScaled(1.0D, 6.0D, 14.0D);
    GL11.glTranslatef(-this.shape24_2.offsetX, -this.shape24_2.offsetY, -this.shape24_2.offsetZ);
    GL11.glTranslatef(-this.shape24_2.rotationPointX * f5, -this.shape24_2.rotationPointY * f5,
            -this.shape24_2.rotationPointZ * f5);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.2F);
    this.shape24_2.render(f5);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
    GL11.glPushMatrix();
    GL11.glTranslatef(this.shape24_5.offsetX, this.shape24_5.offsetY, this.shape24_5.offsetZ);
    GL11.glTranslatef(this.shape24_5.rotationPointX * f5, this.shape24_5.rotationPointY * f5,
            this.shape24_5.rotationPointZ * f5);
    GL11.glScaled(14.0D, 1.0D, 14.0D);
    GL11.glTranslatef(-this.shape24_5.offsetX, -this.shape24_5.offsetY, -this.shape24_5.offsetZ);
    GL11.glTranslatef(-this.shape24_5.rotationPointX * f5, -this.shape24_5.rotationPointY * f5,
            -this.shape24_5.rotationPointZ * f5);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.2F);
    this.shape24_5.render(f5);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
    this.shape11_4.render(f5);
    this.shape11_3.render(f5);
    this.shape11_6.render(f5);
    this.shape11.render(f5);
    GL11.glPushMatrix();
    GL11.glTranslatef(this.shape24.offsetX, this.shape24.offsetY, this.shape24.offsetZ);
    GL11.glTranslatef(this.shape24.rotationPointX * f5, this.shape24.rotationPointY * f5,
            this.shape24.rotationPointZ * f5);
    GL11.glScaled(14.0D, 6.0D, 1.0D);
    GL11.glTranslatef(-this.shape24.offsetX, -this.shape24.offsetY, -this.shape24.offsetZ);
    GL11.glTranslatef(-this.shape24.rotationPointX * f5, -this.shape24.rotationPointY * f5,
            -this.shape24.rotationPointZ * f5);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.2F);
    this.shape24.render(f5);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
    GL11.glPushMatrix();
    GL11.glTranslatef(this.shape24_4.offsetX, this.shape24_4.offsetY, this.shape24_4.offsetZ);
    GL11.glTranslatef(this.shape24_4.rotationPointX * f5, this.shape24_4.rotationPointY * f5,
            this.shape24_4.rotationPointZ * f5);
    GL11.glScaled(14.0D, 6.0D, 1.0D);
    GL11.glTranslatef(-this.shape24_4.offsetX, -this.shape24_4.offsetY, -this.shape24_4.offsetZ);
    GL11.glTranslatef(-this.shape24_4.rotationPointX * f5, -this.shape24_4.rotationPointY * f5,
            -this.shape24_4.rotationPointZ * f5);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.2F);
    this.shape24_4.render(f5);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}

From source file:buildcraftAdditions.client.render.BucketItemRenderer.java

License:GNU General Public License

private void renderMask(IIcon mask, IIcon subIcon, ItemRenderType type, boolean flip) {
    if (mask == null || subIcon == null)
        return;// ww w  .  j a v  a2 s  . c o  m

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_CULL_FACE);
    Tessellator tessellator = Tessellator.instance;

    tessellator.startDrawingQuads();
    tessellator.setNormal(0, 0, 1);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(mask, 0.001, flip);
    else
        preRenderWorldIcon(mask, 0.001, flip);
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0, 0, -1);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(mask, -0.0635, flip);
    else
        preRenderWorldIcon(mask, -0.0635, flip);
    tessellator.draw();

    Minecraft.getMinecraft().renderEngine.bindTexture(RenderUtils.MC_BLOCK_SHEET);
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDepthMask(false);

    tessellator.startDrawingQuads();
    tessellator.setNormal(0, 0, 1);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(subIcon, 0.001, flip);
    else
        preRenderWorldIcon(subIcon, 0.001, flip);
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0, 0, -1);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(subIcon, -0.0635, flip);
    else
        preRenderWorldIcon(subIcon, -0.0635, flip);
    tessellator.draw();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glColor4f(1, 1, 1, 1);
}

From source file:buildcraftAdditions.client.render.CanisterItemRender.java

License:GNU General Public License

private void renderMask(IIcon mask, IIcon subIcon, ItemRenderType type) {
    if (mask == null || subIcon == null)
        return;/*from   w  ww .j a  v a 2s. c  o  m*/

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    Tessellator tessellator = Tessellator.instance;

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(mask, 0.001D);
    else
        preRenderWorldIcon(mask, 0.001D);
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(mask, -0.0635D);
    else
        preRenderWorldIcon(mask, -0.0635D);
    tessellator.draw();

    Minecraft.getMinecraft().renderEngine.bindTexture(BLOCK_TEXTURE);
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDepthMask(false);

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(subIcon, 0.001D);
    else
        preRenderWorldIcon(subIcon, 0.001D);
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(subIcon, -0.0635D);
    else
        preRenderWorldIcon(subIcon, -0.0635D);
    tessellator.draw();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}

From source file:buildcraftAdditions.client.render.items.CanisterItemRender.java

License:GNU General Public License

private void renderMask(IIcon mask, IIcon subIcon, ItemRenderType type) {
    if (mask == null || subIcon == null)
        return;//from www  . j  av a2s  .  c o m

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_CULL_FACE);
    Tessellator tessellator = Tessellator.instance;

    tessellator.startDrawingQuads();
    tessellator.setNormal(0, 0, 1);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(mask, 0.001);
    else
        preRenderWorldIcon(mask, 0.001);
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0, 0, -1);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(mask, -0.0635);
    else
        preRenderWorldIcon(mask, -0.0635);
    tessellator.draw();

    Minecraft.getMinecraft().renderEngine.bindTexture(RenderUtils.MC_BLOCK_SHEET);
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDepthMask(false);

    tessellator.startDrawingQuads();
    tessellator.setNormal(0, 0, 1);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(subIcon, 0.001);
    else
        preRenderWorldIcon(subIcon, 0.001);
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0, 0, -1);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(subIcon, -0.0635);
    else
        preRenderWorldIcon(subIcon, -0.0635);
    tessellator.draw();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glColor4f(1, 1, 1, 1);
}

From source file:buildcraftAdditions.client.render.KineticToolItemRender.java

License:GNU General Public License

private void renderMask(IIcon mask, IIcon subIcon, ItemRenderType type) {
    if (mask == null || subIcon == null)
        return;//  w w  w  .j  a  va 2 s. co m

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    Tessellator tessellator = Tessellator.instance;

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(mask, 0.001D);
    else
        preRenderWorldIcon(mask, 0.001D);
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(mask, -0.0635D);
    else
        preRenderWorldIcon(mask, -0.0635D);
    tessellator.draw();

    Minecraft.getMinecraft().renderEngine.bindTexture(BLOCK_TEXTURE);
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDepthMask(false);

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(subIcon, 0.001D);
    else
        preRenderWorldIcon(subIcon, 0.001D);
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    if (type.equals(ItemRenderType.INVENTORY))
        preRenderInvIcon(subIcon, -0.0635D);
    else
        preRenderWorldIcon(subIcon, -0.0635D);
    tessellator.draw();

    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDepthMask(true);

}

From source file:ccm.placeableTools.client.ToolRenderer.java

License:Open Source License

public static void doRenderPass(int i, int meta, ItemStack stack, double x, double y, double z) {
    Icon icon = stack.getItem().getIcon(stack, i);

    if (icon == null)
        return;//ww w  . ja va2s. c  om

    GL11.glPushMatrix();
    TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
    texturemanager.bindTexture(texturemanager.getResourceLocation(stack.getItemSpriteNumber()));
    Tessellator tessellator = Tessellator.instance;

    GL11.glTranslated(x, y, z); //Center to block
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    GL11.glTranslatef(-0.5f, .5f, 0.5f); // Center on block

    if (stack.getItem() instanceof ItemSpade || stack.getItem() instanceof ItemHoe) {
        float shift = 0.3f;
        switch (ForgeDirection.values()[meta]) {
        case NORTH:
            GL11.glTranslatef(0, 0, -shift);
            GL11.glRotatef(15f, -0.5f, 0, 0);
            break;
        case SOUTH:
            GL11.glTranslatef(0, 0, shift);
            GL11.glRotatef(-15f, -0.5f, 0, 0);
            break;
        case EAST:
            GL11.glRotatef(90f, 0, 1, 0);
            GL11.glTranslatef(-1, 0, 1);
            GL11.glTranslatef(0, 0, shift);
            GL11.glRotatef(-15f, -0.5f, 0, 0);
            break;
        case WEST:
            GL11.glRotatef(90f, 0, 1, 0);
            GL11.glTranslatef(-1, 0, 1);
            GL11.glTranslatef(0, 0, -shift);
            GL11.glRotatef(15f, -0.5f, 0, 0);
            break;
        case DOWN:
            GL11.glRotatef(90f, 0, 1, 0);
            GL11.glTranslatef(-1, 0, 1);
            break;
        }
        GL11.glTranslatef(0, 0, -0.03f); //Icon depth of the shovel
        GL11.glRotatef(180f, 1, 0, 0);
    } else if (stack.getItem() instanceof ItemAxe || stack.getItem() instanceof ItemPickaxe) {
        float shift = 0.15f;
        switch (ForgeDirection.values()[meta]) {
        case NORTH:
            GL11.glRotatef(90f, 0, 1, 0);
            GL11.glTranslatef(-1, 0, 1);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-10f, 0, 0, 1);
            break;
        case SOUTH:
            GL11.glRotatef(-90f, 0, 1, 0);
            GL11.glTranslatef(-1, 0, -1);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-10f, 0, 0, 1);
            break;
        case EAST:
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-10f, 0, 0, 1);
            break;
        case WEST:
            GL11.glRotatef(180f, 0, 1, 0);
            GL11.glTranslatef(-2, 0, 0);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-10f, 0, 0, 1);
            break;
        }
        GL11.glTranslatef(0, 0, 0.03F);
    } else if (stack.getItem() instanceof ItemSword) {
        float shift = 0.15f;
        switch (ForgeDirection.values()[meta]) {
        case NORTH:
            GL11.glRotatef(90f, 0, 1, 0);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-90f, 0, 0, 1);
            GL11.glTranslatef(-1, 0, 1);
            break;
        case SOUTH:
            GL11.glRotatef(-90f, 0, 1, 0);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-90f, 0, 0, 1);
            GL11.glTranslatef(-1, 0, -1);
            break;
        case EAST:
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-90f, 0, 0, 1);
            GL11.glTranslatef(-1, 1, 0);
            break;
        case WEST:
            GL11.glRotatef(180f, 0, 1, 0);
            GL11.glTranslatef(-1, 1, 0);
            GL11.glTranslatef(shift, 0, 0);
            GL11.glRotatef(-90f, 0, 0, 1);
            break;
        case UP:
            GL11.glRotatef(180f, 1, 0, 0);
            GL11.glTranslatef(1, 0, 1);
            GL11.glRotatef(90f, 0, 1, 0);
            break;
        case DOWN:
            GL11.glRotatef(180f, 1, 0, 0);
            break;
        }
        GL11.glTranslatef(-0.05f, 0, 0.03F);
    }
    GL11.glRotatef(-45f, 0, 0, 1);
    GL11.glScalef(1.5f, 1.5f, 1.5f);
    ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
            icon.getIconWidth(), icon.getIconHeight(), 0.06F / 1.5f);

    if (stack.hasEffect(i)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        texturemanager.bindTexture(RES_ITEM_GLINT);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
        float f7 = 0.76F;
        GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        float f8 = 0.125F;
        GL11.glScalef(f8, f8, f8);
        float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
        GL11.glTranslatef(f9, 0.0F, 0.0F);
        GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.06F / 1.5f);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(f8, f8, f8);
        f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
        GL11.glTranslatef(-f9, 0.0F, 0.0F);
        GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.06F / 1.5f);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}