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:appeng.client.render.items.PaintBallRender.java

License:Open Source License

@Override
public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) {
    IIcon par2Icon = item.getIconIndex();
    if (item.getItemDamage() >= 20) {
        par2Icon = ExtraItemTextures.ItemPaintBallShimmer.getIcon();
    }//from  w w w  . j av  a  2s.c  o  m

    final float f4 = par2Icon.getMinU();
    final float f5 = par2Icon.getMaxU();
    final float f6 = par2Icon.getMinV();
    final float f7 = par2Icon.getMaxV();

    final ItemPaintBall ipb = (ItemPaintBall) item.getItem();

    final Tessellator tessellator = Tessellator.instance;
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

    final AEColor col = ipb.getColor(item);

    final int colorValue = item.getItemDamage() >= 20 ? col.mediumVariant : col.mediumVariant;
    final int r = (colorValue >> 16) & 0xff;
    final int g = (colorValue >> 8) & 0xff;
    final int b = (colorValue) & 0xff;

    if (item.getItemDamage() >= 20) {
        final float fail = 0.7f;
        final int full = (int) (255 * 0.3);
        GL11.glColor4ub((byte) (full + r * fail), (byte) (full + g * fail), (byte) (full + b * fail),
                (byte) 255);
    } else {
        GL11.glColor4ub((byte) r, (byte) g, (byte) b, (byte) 255);
    }

    if (type == ItemRenderType.INVENTORY) {
        GL11.glScalef(16F, 16F, 10F);
        GL11.glTranslatef(0.0F, 1.0F, 0.0F);
        GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
        GL11.glEnable(GL11.GL_ALPHA_TEST);

        tessellator.startDrawingQuads();
        tessellator.setNormal(0.0F, 1.0F, 0.0F);
        tessellator.addVertexWithUV(0, 0, 0, f4, f7);
        tessellator.addVertexWithUV(1, 0, 0, f5, f7);
        tessellator.addVertexWithUV(1, 1, 0, f5, f6);
        tessellator.addVertexWithUV(0, 1, 0, f4, f6);
        tessellator.draw();
    } else {
        if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
            GL11.glTranslatef(0.0F, 0.0F, 0.0F);
        } else {
            GL11.glTranslatef(-0.5F, -0.3F, 0.01F);
        }
        final float f12 = 0.0625F;
        ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(),
                par2Icon.getIconHeight(), f12);

        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glColor4f(1, 1, 1, 1.0F);
        GL11.glScalef(1F, 1.1F, 1F);
        GL11.glTranslatef(0.0F, 1.07F, f12 / -2.0f);
        GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
    }

    GL11.glColor4f(1, 1, 1, 1.0F);

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

From source file:appeng.client.render.items.ToolBiometricCardRender.java

License:Open Source License

@Override
public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) {
    final IIcon par2Icon = item.getIconIndex();

    final float f4 = par2Icon.getMinU();
    final float f5 = par2Icon.getMaxU();
    final float f6 = par2Icon.getMinV();
    final float f7 = par2Icon.getMaxV();

    final Tessellator tessellator = Tessellator.instance;
    GL11.glPushMatrix();//from w  w  w.  ja  v a 2 s.  c om
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

    if (type == ItemRenderType.INVENTORY) {
        GL11.glColor4f(1, 1, 1, 1.0F);
        GL11.glScalef(16F, 16F, 10F);
        GL11.glTranslatef(0.0F, 1.0F, 0.0F);
        GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
        GL11.glEnable(GL11.GL_ALPHA_TEST);

        tessellator.startDrawingQuads();
        tessellator.setNormal(0.0F, 1.0F, 0.0F);
        tessellator.addVertexWithUV(0, 0, 0, f4, f7);
        tessellator.addVertexWithUV(1, 0, 0, f5, f7);
        tessellator.addVertexWithUV(1, 1, 0, f5, f6);
        tessellator.addVertexWithUV(0, 1, 0, f4, f6);
        tessellator.draw();
    } else {
        GL11.glTranslatef(-0.5F, -0.3F, 0.01F);
        final float f12 = 0.0625F;
        ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(),
                par2Icon.getIconHeight(), f12);

        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glColor4f(1, 1, 1, 1.0F);
        GL11.glScalef(1F, 1.1F, 1F);
        GL11.glTranslatef(0.0F, 1.07F, f12 / -2.0f);
        GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
    }

    final float u = ExtraItemTextures.White.getIcon().getInterpolatedU(8.1);
    final float v = ExtraItemTextures.White.getIcon().getInterpolatedV(8.1);

    String username = "";
    if (item.getItem() instanceof IBiometricCard) {
        final GameProfile gp = ((IBiometricCard) item.getItem()).getProfile(item);
        if (gp != null) {
            username = gp.getName();
        }
    }
    final int hash = username.length() > 0 ? username.hashCode() : 0;

    GL11.glScalef(1F / 16F, 1F / 16F, 1F);
    GL11.glTranslatef(4, 6, 0);
    GL11.glDisable(GL11.GL_LIGHTING);

    tessellator.startDrawingQuads();

    AEColor col = AEColor.values()[Math.abs(3 + hash) % AEColor.values().length];
    if (hash == 0) {
        col = AEColor.Black;
    }

    final float z = 0;
    for (int x = 0; x < 8; x++)// 8
    {
        for (int y = 0; y < 6; y++)// 6
        {
            boolean isLit = false;

            if (x == 0 || y == 0 || x == 7 || y == 5) {
                isLit = false;
            } else {
                isLit = (hash & (1 << x)) != 0 || (hash & (1 << y)) != 0;
            }

            if (isLit) {
                tessellator.setColorOpaque_I(col.mediumVariant);
            } else {
                final float scale = 0.3f / 255.0f;
                tessellator.setColorOpaque_F(((col.blackVariant >> 16) & 0xff) * scale,
                        ((col.blackVariant >> 8) & 0xff) * scale, (col.blackVariant & 0xff) * scale);
            }

            tessellator.addVertexWithUV(x, y, z, u, v);
            tessellator.addVertexWithUV(x + 1, y, z, u, v);
            tessellator.addVertexWithUV(x + 1, y + 1, z, u, v);
            tessellator.addVertexWithUV(x, y + 1, z, u, v);
        }
    }
    tessellator.draw();

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

From source file:appeng.client.render.items.ToolColorApplicatorRender.java

License:Open Source License

@Override
public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) {
    final IIcon par2Icon = item.getIconIndex();

    float f4 = par2Icon.getMinU();
    float f5 = par2Icon.getMaxU();
    float f6 = par2Icon.getMinV();
    float f7 = par2Icon.getMaxV();

    final Tessellator tessellator = Tessellator.instance;
    GL11.glPushMatrix();// w  w  w  .  j  a  v  a  2  s.c o m
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

    if (type == ItemRenderType.INVENTORY) {
        GL11.glColor4f(1, 1, 1, 1.0F);
        GL11.glScalef(16F, 16F, 10F);
        GL11.glTranslatef(0.0F, 1.0F, 0.0F);
        GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
        GL11.glEnable(GL11.GL_ALPHA_TEST);

        tessellator.startDrawingQuads();
        tessellator.setNormal(0.0F, 1.0F, 0.0F);
        tessellator.addVertexWithUV(0, 0, 0, f4, f7);
        tessellator.addVertexWithUV(1, 0, 0, f5, f7);
        tessellator.addVertexWithUV(1, 1, 0, f5, f6);
        tessellator.addVertexWithUV(0, 1, 0, f4, f6);
        tessellator.draw();
    } else {
        if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
            GL11.glTranslatef(0.0F, 0.0F, 0.0F);
        } else if (type == ItemRenderType.EQUIPPED) {
            GL11.glTranslatef(0.0F, 0.0F, 0.0F);
        } else {
            GL11.glTranslatef(-0.5F, -0.3F, 0.01F);
        }
        final float f12 = 0.0625F;
        ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(),
                par2Icon.getIconHeight(), f12);

        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glColor4f(1, 1, 1, 1.0F);
        GL11.glScalef(-1F, -1F, 1F);
        GL11.glTranslatef(-1.125F, 0.0f, f12 / -2.0f);
        GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
    }

    final IIcon dark = ExtraItemTextures.ToolColorApplicatorTip_Dark.getIcon();
    final IIcon med = ExtraItemTextures.ToolColorApplicatorTip_Medium.getIcon();
    final IIcon light = ExtraItemTextures.ToolColorApplicatorTip_Light.getIcon();

    GL11.glScalef(1F / 16F, 1F / 16F, 1F);
    if (type != ItemRenderType.INVENTORY) {
        GL11.glTranslatef(2, 0, 0);
    }
    GL11.glDisable(GL11.GL_LIGHTING);

    final AEColor col = ((ToolColorApplicator) item.getItem()).getActiveColor(item);

    if (col != null) {
        tessellator.startDrawingQuads();

        f4 = dark.getMinU();
        f5 = dark.getMaxU();
        f6 = dark.getMinV();
        f7 = dark.getMaxV();

        tessellator.setColorOpaque_I(col.blackVariant);
        tessellator.addVertexWithUV(0, 0, 0, f4, f7);
        tessellator.addVertexWithUV(16, 0, 0, f5, f7);
        tessellator.addVertexWithUV(16, 16, 0, f5, f6);
        tessellator.addVertexWithUV(0, 16, 0, f4, f6);

        f4 = light.getMinU();
        f5 = light.getMaxU();
        f6 = light.getMinV();
        f7 = light.getMaxV();

        tessellator.setColorOpaque_I(col.whiteVariant);
        tessellator.addVertexWithUV(0, 0, 0, f4, f7);
        tessellator.addVertexWithUV(16, 0, 0, f5, f7);
        tessellator.addVertexWithUV(16, 16, 0, f5, f6);
        tessellator.addVertexWithUV(0, 16, 0, f4, f6);

        f4 = med.getMinU();
        f5 = med.getMaxU();
        f6 = med.getMinV();
        f7 = med.getMaxV();

        tessellator.setColorOpaque_I(col.mediumVariant);
        tessellator.addVertexWithUV(0, 0, 0, f4, f7);
        tessellator.addVertexWithUV(16, 0, 0, f5, f7);
        tessellator.addVertexWithUV(16, 16, 0, f5, f6);
        tessellator.addVertexWithUV(0, 16, 0, f4, f6);

        tessellator.draw();
    }

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

From source file:appeng.client.render.items.ToolWirelessTerminalRender.java

License:Open Source License

@Override
public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) {
    Entity itemLocation = item.getItemFrame();
    if (itemLocation == null) {
        itemLocation = Minecraft.getMinecraft().thePlayer;
    }/*from  w w  w .j a v  a 2  s .  co m*/

    final boolean displayAntenna = ((ToolWirelessTerminal) item.getItem()).getIsUsable(item, itemLocation);
    final boolean hasPower = ((ToolWirelessTerminal) item.getItem()).hasPower(null, 0.5, item);

    IIcon border;
    if (displayAntenna) {
        border = ExtraItemTextures.WirelessTerminal_Border.getIcon();
    } else {
        border = ExtraItemTextures.WirelessTerminal_Border_Inactive.getIcon();
    }
    final IIcon scrollBar = ExtraItemTextures.WirelessTerminal_ScrollBar.getIcon();
    final IIcon icons = ExtraItemTextures.WirelessTerminal_Icons.getIcon();
    IIcon screen = ExtraItemTextures.WirelessTerminal_Screen.getIcon();

    final AEColor color = ToolWirelessTerminal.getColor(item);
    if (color == null) {
        screen = item.getIconIndex();
    }

    final Tessellator tessellator = Tessellator.instance;
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

    //translate stuff for different item render types
    if (type != ItemRenderType.INVENTORY) {
        if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
            GL11.glTranslatef(0.0F, 0.0F, 0.0F);
        } else if (type == ItemRenderType.EQUIPPED) {
            GL11.glTranslatef(0.0F, 0.0F, 0.0F);
        } else {
            GL11.glTranslatef(-0.5F, -0.3F, 0.01F);
        }
    } else {
        GL11.glColor4f(1, 1, 1, 1.0F);
        GL11.glScalef(16F, 16F, 10F);
        GL11.glTranslatef(0.0F, 1.0F, 0.0F);
        GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }

    final float f12 = 0.0625F;

    //Border, which is uncolored
    subRenderItem(type, tessellator, border, f12);

    if (hasPower) {
        RenderHelper.disableStandardItemLighting();
    }

    //If a terminal isn't colored, use the default icon which doesn't require icons or scrollbar
    if (color != null) {
        //Icons, which are dark colored
        {
            final int blackColor = color.blackVariant;
            final float r = (blackColor >> 16) & 0xFF;
            final float g = (blackColor >> 8) & 0xFF;
            final float b = blackColor & 0xFF;
            GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f);

            subRenderItem(type, tessellator, icons, f12);
        }

        //Scrollbar, which is medium colored
        {
            final int medColor = color.mediumVariant;
            final float r = (medColor >> 16) & 0xFF;
            final float g = (medColor >> 8) & 0xFF;
            final float b = medColor & 0xFF;
            GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f);

            subRenderItem(type, tessellator, scrollBar, f12);
        }
    }

    //Screen, which is light colored
    {
        if (color != null) {
            final int whiteColor = color.whiteVariant;
            final float r = (whiteColor >> 16) & 0xFF;
            final float g = (whiteColor >> 8) & 0xFF;
            final float b = whiteColor & 0xFF;
            GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f);
        }

        subRenderItem(type, tessellator, screen, f12);
    }

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

From source file:appeng.entity.RenderTinyTNTPrimed.java

License:Open Source License

private void renderPrimedTNT(final EntityTinyTNTPrimed tnt, final double x, final double y, final double z,
        final float life) {
    GL11.glPushMatrix();//from w w  w.  j  a v  a 2  s .c  o  m
    GL11.glTranslatef((float) x, (float) y - 0.25f, (float) z);
    float f2;

    if (tnt.fuse - life + 1.0F < 10.0F) {
        f2 = 1.0F - (tnt.fuse - life + 1.0F) / 10.0F;

        if (f2 < 0.0F) {
            f2 = 0.0F;
        }

        if (f2 > 1.0F) {
            f2 = 1.0F;
        }

        f2 *= f2;
        f2 *= f2;
        final float f3 = 1.0F + f2 * 0.3F;
        GL11.glScalef(f3, f3, f3);
    }

    GL11.glScalef(0.5f, 0.5f, 0.5f);
    f2 = (1.0F - (tnt.fuse - life + 1.0F) / 100.0F) * 0.8F;
    this.bindEntityTexture(tnt);
    this.blockRenderer.renderBlockAsItem(Blocks.tnt, 0, tnt.getBrightness(life));

    if (tnt.fuse / 5 % 2 == 0) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, f2);
        this.blockRenderer.renderBlockAsItem(Blocks.tnt, 0, 1.0F);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }

    GL11.glPopMatrix();
}

From source file:appeng.facade.FacadePart.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)/*from  w w w  . j a v a  2  s  .  c  om*/
public void renderInventory(final IPartRenderHelper instance, final RenderBlocks renderer) {
    if (this.facade != null) {
        final IFacadeItem fi = (IFacadeItem) this.facade.getItem();

        try {
            if (fi != null) {
                final ItemStack randomItem = fi.getTextureItem(this.facade);

                instance.setTexture(this.facade.getIconIndex());
                instance.setBounds(7, 7, 4, 9, 9, 14);
                instance.renderInventoryBox(renderer);
                instance.setTexture(null);

                if (randomItem != null) {
                    if (randomItem.getItem() instanceof ItemBlock) {
                        final ItemBlock ib = (ItemBlock) randomItem.getItem();
                        final Block blk = Block.getBlockFromItem(ib);

                        try {
                            final int color = ib.getColorFromItemStack(randomItem, 0);
                            GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
                            instance.setInvColor(color);
                        } catch (final Throwable error) {
                            GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
                            instance.setInvColor(0xffffff);
                        }

                        Tessellator.instance.setBrightness(15 << 20 | 15 << 4);
                        Tessellator.instance.setColorOpaque_F(1, 1, 1);
                        instance.setTexture(
                                blk.getIcon(this.side.ordinal(), ib.getMetadata(randomItem.getItemDamage())));

                        instance.setBounds(0, 0, 14, 16, 16, 16);
                        instance.renderInventoryBox(renderer);

                        instance.setTexture(null);
                    }
                }
            }
        } catch (final Exception ignored) {

        }
    }
}

From source file:appeng.integration.modules.NEIHelpers.NEIGrinderRecipeHandler.java

License:Open Source License

@Override
public void drawBackground(final int recipe) {
    GL11.glColor4f(1, 1, 1, 1);
    GuiDraw.changeTexture(this.getGuiTexture());
    GuiDraw.drawTexturedModalRect(40, 10, 75, 16 + 10, 90, 66);
}

From source file:appeng.integration.modules.NEIHelpers.NEIInscriberRecipeHandler.java

License:Open Source License

@Override
public void drawBackground(final int recipe) {
    GL11.glColor4f(1, 1, 1, 1);
    GuiDraw.changeTexture(this.getGuiTexture());
    GuiDraw.drawTexturedModalRect(0, 0, 5, 11, 166, 75);
}

From source file:appeng.integration.modules.NEIHelpers.NEIWorldCraftingHandler.java

License:Open Source License

@Override
public void drawBackground(final int recipe) {
    GL11.glColor4f(1, 1, 1, 1);// nothing.
}

From source file:appeng.parts.reporting.AbstractPartMonitor.java

License:Open Source License

private void tesrRenderScreen(final Tessellator tess, final IAEItemStack ais) {
    // GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );

    final ForgeDirection d = this.getSide();

    GL11.glTranslated(d.offsetX * 0.77, d.offsetY * 0.77, d.offsetZ * 0.77);

    switch (d) {/*from  w  ww  . jav a2 s. co  m*/
    case UP:
        GL11.glScalef(1.0f, -1.0f, 1.0f);
        GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
        GL11.glRotatef(this.getSpin() * 90.0F, 0, 0, 1);
        break;
    case DOWN:
        GL11.glScalef(1.0f, -1.0f, 1.0f);
        GL11.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
        GL11.glRotatef(this.getSpin() * -90.0F, 0, 0, 1);
        break;
    case EAST:
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
        break;
    case WEST:
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
        break;
    case NORTH:
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        break;
    case SOUTH:
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
        break;

    default:
        break;
    }

    try {
        final ItemStack sis = ais.getItemStack();
        sis.stackSize = 1;

        final int br = 16 << 20 | 16 << 4;
        final int var11 = br % 65536;
        final int var12 = br / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * 0.8F, var12 * 0.8F);

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

        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        // RenderHelper.enableGUIStandardItemLighting();
        tess.setColorOpaque_F(1.0f, 1.0f, 1.0f);

        ClientHelper.proxy.doRenderItem(sis, this.getTile().getWorldObj());
    } catch (final Exception e) {
        AELog.error(e);
    } finally {
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    }

    GL11.glTranslatef(0.0f, 0.14f, -0.24f);
    GL11.glScalef(1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f);

    final long stackSize = ais.getStackSize();
    final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm(stackSize);

    final FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
    final int width = fr.getStringWidth(renderedStackSize);
    GL11.glTranslatef(-0.5f * width, 0.0f, -1.0f);
    fr.drawString(renderedStackSize, 0, 0, 0);

    // GL11.glPopAttrib();
}