Example usage for org.lwjgl.opengl GL11 glColor4f

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

Introduction

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

Prototype

public static native void glColor4f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green,
        @NativeType("GLfloat") float blue, @NativeType("GLfloat") float alpha);

Source Link

Document

Float version of #glColor4b Color4b

Usage

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

License:GNU General Public License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    IIcon overlay = canister.overlay;/*from w  w w . ja  v a  2  s.c  om*/
    IIcon cannister = canister.getIconFromDamage(0);

    GL11.glPushMatrix();
    if (type.equals(ItemRenderType.EQUIPPED)) {
        GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D);
        GL11.glTranslated(-1.0D, -1.0D, 0.0D);
    } else if (type.equals(ItemRenderType.ENTITY)) {
        GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D);
        GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D);
        GL11.glTranslated(-0.5D, -0.9D, 0.0D);
        if (item.isOnItemFrame()) {
            GL11.glTranslated(0.1D, 0.4D, 0.0D);
            GL11.glScaled(0.85D, 0.85D, 0.85D);
        }
    } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) {
        GL11.glTranslated(1.0D, 1.0D, 0.0D);
        GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D);
    }

    if (item.stackTagCompound != null && item.getTagCompound().hasKey("Fluid")) {
        Fluid fluid = FluidRegistry
                .getFluid(item.stackTagCompound.getCompoundTag("Fluid").getString("FluidName"));
        if (fluid != null) {
            Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);
            renderMask(overlay, fluid.getIcon(), type);
        }
    }
    Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);

    if (!type.equals(ItemRenderType.INVENTORY))
        ItemRenderer.renderItemIn2D(Tessellator.instance, cannister.getMinU(), cannister.getMaxV(),
                cannister.getMaxU(), cannister.getMinV(), cannister.getIconWidth(), cannister.getIconHeight(),
                0.0625F);
    else
        renderIcon(cannister, 0.0D);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

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  w w.java  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

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    if (item == null || item.getItem() == null || !(item.getItem() instanceof ItemCanister))
        return;/*from   ww w .  j a  v a2  s  . c om*/

    ItemCanister canister = (ItemCanister) item.getItem();

    IIcon overlay = canister.getOverlay();
    IIcon canisterIcon = canister.getIconFromDamage(0);

    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    if (type.equals(ItemRenderType.EQUIPPED)) {
        GL11.glRotated(180, 0, 0, 1);
        GL11.glTranslated(-1, -1, 0);
    } else if (type.equals(ItemRenderType.ENTITY)) {
        GL11.glRotated(180, 0, 0, 1);
        GL11.glRotated(90, 0, 1, 0);
        GL11.glTranslated(-0.5, -0.9, 0);
        if (item.isOnItemFrame()) {
            GL11.glTranslated(0.075, 0.475, 0);
            GL11.glScaled(0.85, 0.85, 0.85);
        }
    } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) {
        GL11.glTranslated(1, 1, 0);
        GL11.glRotated(180, 0, 0, 1);
    }

    FluidStack fluid = Utils.getFluidStackFromItemStack(item);
    if (fluid != null) {
        Fluid f = fluid.getFluid();
        if (f != null) {
            Minecraft.getMinecraft().renderEngine.bindTexture(RenderUtils.MC_ITEM_SHEET);
            renderMask(overlay, f.getIcon(), type);
        }
    }
    Minecraft.getMinecraft().renderEngine.bindTexture(RenderUtils.MC_ITEM_SHEET);

    if (type.equals(ItemRenderType.INVENTORY))
        renderIcon(canisterIcon, 0);
    else
        ItemRenderer.renderItemIn2D(Tessellator.instance, canisterIcon.getMinU(), canisterIcon.getMaxV(),
                canisterIcon.getMaxU(), canisterIcon.getMinV(), canisterIcon.getIconWidth(),
                canisterIcon.getIconHeight(), 0.0625F);

    GL11.glColor4f(1, 1, 1, 1);
    GL11.glPopMatrix();
}

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  w ww.  j  av  a2 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);
    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

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    IIcon overlayChainsaw = tool.overlayChainsaw;
    IIcon overlayDigger = tool.overlayDigger;
    IIcon overlayDrill = tool.overlayDrill;
    IIcon overlayHoe = tool.overlayHoe;/*from   w  w  w  . j av  a2s.  c  om*/
    IIcon toolIcon = tool.getIconFromDamage(0);

    GL11.glPushMatrix();
    if (type.equals(ItemRenderType.EQUIPPED)) {
        GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D);
        GL11.glTranslated(-1.0D, -1.0D, 0.0D);
    } else if (type.equals(ItemRenderType.ENTITY)) {
        GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D);
        GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D);
        GL11.glTranslated(-0.5D, -0.9D, 0.0D);
        if (item.isOnItemFrame()) {
            GL11.glTranslated(0.1D, 0.4D, 0.0D);
            GL11.glScaled(0.85D, 0.85D, 0.85D);
        }
    } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) {
        GL11.glTranslated(1.0D, 1.0D, 0.0D);
        GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D);
    }

    String lastUsedMode = "";
    if (item.stackTagCompound != null && item.stackTagCompound.hasKey("lastUsedMode"))
        lastUsedMode = item.stackTagCompound.getString("lastUsedMode");
    if (lastUsedMode.equals("axe")) {
        Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);
        renderMask(overlayChainsaw, overlayChainsaw, type);
    }

    if (lastUsedMode.equals("shovel")) {
        Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);
        renderMask(overlayDigger, overlayDigger, type);
    }

    if (lastUsedMode.equals("pickaxe")) {
        Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);
        renderMask(overlayDrill, overlayDrill, type);
    }

    if (lastUsedMode.equals("hoe")) {
        Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);
        renderMask(overlayHoe, overlayHoe, type);
    }

    Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);

    if (!type.equals(ItemRenderType.INVENTORY))
        ItemRenderer.renderItemIn2D(Tessellator.instance, toolIcon.getMinU(), toolIcon.getMaxV(),
                toolIcon.getMaxU(), toolIcon.getMinV(), toolIcon.getIconWidth(), toolIcon.getIconHeight(),
                0.0625F);
    else
        renderIcon(toolIcon, 0.0D);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

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;//from ww w  .j  a v a 2 s .  c om

    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:buildcraftAdditions.compat.nei.DustingRecipeHandler.java

License:GNU General Public License

@Override
public void drawBackground(int recipe) {
    GL11.glColor4f(1, 1, 1, 1);
    changeTexture(getGuiTexture());
    drawTexturedModalRect(0, 0, 0, 0, 166, 65);
}

From source file:buildcraftAdditions.compat.nei.RecipeHandlerBase.java

License:GNU General Public License

public void changeToGuiTexture() {
    GuiDraw.changeTexture(this.getGuiTexture());
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}

From source file:buildcraftAdditions.utils.RenderUtils.java

License:GNU General Public License

public static void drawImage(ResourceLocation image, int x, int y, int width, int height) {
    bindTexture(image);// ww  w.  j ava  2  s. c om
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    Tessellator tess = Tessellator.instance;
    tess.startDrawingQuads();
    tess.addVertexWithUV(x, y + height, 0, 0, 1);
    tess.addVertexWithUV(x + width, y + height, 0, 1, 1);
    tess.addVertexWithUV(x + width, y, 0, 1, 0);
    tess.addVertexWithUV(x, y, 0, 0, 0);
    tess.draw();
}

From source file:bunyan.blocks.RenderManager.java

License:Minecraft Mod Public

public static void renderBlockAsItem(Block block, int metadata, float color, RenderBlocks renderer) {
    if (renderer.useInventoryTint) {
        final int renderColor = block.getRenderColor(metadata);

        final float red = (renderColor >> 16 & 255) / 255.0F;
        final float green = (renderColor >> 8 & 255) / 255.0F;
        final float blue = (renderColor & 255) / 255.0F;
        GL11.glColor4f(red * color, green * color, blue * color, 1.0F);
    }/*from   ww  w  . ja  v a  2  s  . co  m*/

    final Tessellator tessellator = Tessellator.instance;

    block.setBlockBoundsForItemRender();
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1.0F, 0.0F);
    renderer.renderBottomFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(0, metadata));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    renderer.renderTopFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(1, metadata));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1.0F);
    renderer.renderEastFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(2, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    renderer.renderWestFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(3, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1.0F, 0.0F, 0.0F);
    renderer.renderNorthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(4, metadata));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    renderer.renderSouthFace(block, 0.0D, 0.0D, 0.0D, block.getBlockTextureFromSideAndMetadata(5, metadata));
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}