Example usage for org.lwjgl.opengl GL11 glColor3f

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

Introduction

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

Prototype

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

Source Link

Document

Float version of #glColor3b Color3b

Usage

From source file:vazkii.s_hg.client.model.ModelHourglass.java

License:Open Source License

public void render(float fract1, float fract2, boolean flip, int color) {
    if (flip) {//from ww w . ja v  a 2  s . c  o m
        float fract3 = fract1;
        fract1 = fract2;
        fract2 = fract3;
    }

    float f = 1F / 16F;
    ring.render(f);
    base1.render(f);
    base2.render(f);
    Color c = new Color(color);
    GL11.glColor3ub((byte) c.getRed(), (byte) c.getGreen(), (byte) c.getBlue());
    boolean normalize = GL11.glGetBoolean(GL11.GL_NORMALIZE);
    GL11.glEnable(GL11.GL_NORMALIZE);

    if (fract1 > 0) {
        GL11.glPushMatrix();
        if (flip)
            GL11.glTranslatef(-2.5F * f, 1.0F * f, -2.5F * f);
        else {
            GL11.glRotatef(180F, 0F, 0F, 1F);
            GL11.glTranslatef(-2.5F * f, -6.0F * f, -2.5F * f);
        }

        GL11.glScalef(1F, fract1, 1F);
        sand1.render(f);
        GL11.glPopMatrix();
    }

    if (fract2 > 0) {
        GL11.glPushMatrix();
        if (flip)
            GL11.glTranslatef(-2.5F * f, -6.0F * f, -2.5F * f);
        else {
            GL11.glRotatef(180F, 0F, 0F, 1F);
            GL11.glTranslatef(-2.5F * f, 1.0F * f, -2.5F * f);
        }

        GL11.glScalef(1F, fract2, 1F);
        sand2.render(f);
        GL11.glPopMatrix();
    }

    if (!normalize)
        GL11.glDisable(GL11.GL_NORMALIZE);
    GL11.glColor3f(1F, 1F, 1F);
    glass1.render(f);
    glass2.render(f);
}

From source file:vazkii.tinkerer.client.gui.GuiAnimationTablet.java

License:Creative Commons License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(gui);/*from ww  w.ja  va 2  s .com*/
    drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    String left = StatCollector.translateToLocal("ttmisc.leftClick");
    String right = StatCollector.translateToLocal("ttmisc.rightClick");
    String redstone = StatCollector.translateToLocal("ttmisc.redstoneControl");
    fontRenderer.drawString(left, x + 48 - fontRenderer.getStringWidth(left), y + 18, 0x999999);
    fontRenderer.drawString(right, x + 128, y + 18, 0x999999);
    fontRenderer.drawString(redstone, x + xSize / 2 - fontRenderer.getStringWidth(redstone) / 2, y + 50,
            0x999999);
    GL11.glColor3f(1F, 1F, 1F);
}

From source file:vazkii.tinkerer.client.gui.GuiMobMagnet.java

License:Creative Commons License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(gui);/*from  ww  w .j  av  a2 s .co  m*/
    drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    String adult = StatCollector.translateToLocal("ttmisc.adult");
    String child = StatCollector.translateToLocal("ttmisc.child");
    stack = mobMagnet.getStackInSlot(0);

    String filter;

    if (stack != null) {
        String name = ItemSoulMould.getPatternName(stack);
        if (name.isEmpty())
            filter = StatCollector.translateToLocal("ttmisc.none");
        else
            filter = StatCollector.translateToLocal("entity." + name + ".name");
    } else
        filter = StatCollector.translateToLocal("ttmisc.all");

    fontRenderer.drawString(filter, x + xSize / 2 - fontRenderer.getStringWidth(filter) / 2 - 26, y + 16,
            0x999999);
    fontRenderer.drawString(adult, x + 120, y + 30, 0x999999);
    fontRenderer.drawString(child, x + 120, y + 50, 0x999999);
    GL11.glColor3f(1F, 1F, 1F);
}

From source file:vazkii.tinkerer.client.helper.RenderHelper.java

License:Creative Commons License

public static void renderCooldown(double x, double y, double z, int cooldown) {
    if (cooldown > 0) {
        GL11.glPushMatrix();/* ww w  .  j a va 2 s .c o m*/
        GL11.glScalef(0.5F, 0.5F, 0.5F);
        String time = FormattingCode.RED + "" + FormattingCode.BOLD + StringUtils.ticksToElapsedTime(cooldown);
        FontRenderer fr = MiscHelper.getMc().fontRenderer;
        int timeStrWidth = fr.getStringWidth(time);
        fr.drawStringWithShadow(time, (int) ((x + 6) * 2 - timeStrWidth), (int) ((y + 4) * 2), 0xFFFFFF);
        GL11.glPopMatrix();
        GL11.glColor3f(1F, 1F, 1F);
    }
}

From source file:vazkii.tinkerer.client.render.block.kami.RenderWarpGate.java

License:Creative Commons License

@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    Icon topIcon = BlockWarpGate.icons[0];
    Icon sideIcon = BlockWarpGate.icons[1];
    drawFaces(renderer, block, sideIcon, topIcon, sideIcon, sideIcon, sideIcon, sideIcon, false);
    GL11.glColor3f(1F, 1F, 1F);

    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    Tessellator t = Tessellator.instance;
    t.startDrawingQuads();//from   www  .  j  a  va2s  . c o  m
    t.setBrightness(255);
    t.setNormal(0, 1, 0);
    renderer.renderFaceYPos(block, 0, 0, 0, BlockWarpGate.icons[2]);
    t.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}

From source file:vazkii.tinkerer.client.render.tile.RenderTileEnchanter.java

License:Creative Commons License

@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float partTicks) {
    TileEnchanter enchanter = (TileEnchanter) tileentity;

    GL11.glPushMatrix();//  w  w  w .  jav a  2  s.  c  om
    GL11.glTranslated(d0, d1 + 0.75, d2);

    ItemStack item = enchanter.getStackInSlot(0);
    if (item != null) {
        GL11.glPushMatrix();
        GL11.glRotatef(90F, 1F, 0F, 0F);
        final float scale = 0.7F;
        GL11.glScalef(scale, scale, scale);
        GL11.glTranslatef(0.6F, -0.2F, 0F);
        GL11.glRotatef(30F, 0F, 0F, 1F);

        ClientHelper.minecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);

        int renderPass = 0;
        do {
            Icon icon = item.getItem().getIcon(item, renderPass);
            if (icon != null) {
                Color color = new Color(item.getItem().getColorFromItemStack(item, renderPass));
                GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
                float f = icon.getMinU();
                float f1 = icon.getMaxU();
                float f2 = icon.getMinV();
                float f3 = icon.getMaxV();
                ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(),
                        icon.getIconHeight(), 1F / 16F);
                GL11.glColor3f(1F, 1F, 1F);
            }
            renderPass++;
        } while (renderPass < item.getItem().getRenderPasses(item.getItemDamage()));
        GL11.glPopMatrix();
    }

    item = enchanter.getStackInSlot(1);
    if (item != null) {
        GL11.glPushMatrix();
        GL11.glRotatef(90F, 1F, 0F, 0F);
        final float scale = 0.5F;
        GL11.glScalef(scale, scale, scale);
        GL11.glTranslatef(0.6F, 1.5F, -0.1F);
        GL11.glRotatef(-70F, 0F, 0F, 1F);
        long millis = System.currentTimeMillis();

        GL11.glTranslatef(0F, 0F, (float) (Math.cos((double) millis / 1000F) - 1.2F) / 10F);
        GL11.glTranslatef(0F, 0.325F, 0F);
        GL11.glRotatef((float) Math.cos((double) millis / 500F) * 5F, 1F, 0F, 0F);
        GL11.glTranslatef(0F, -0.325F, 0F);

        wandRenderer.renderItem(ItemRenderType.ENTITY, item, (Object[]) null);
        GL11.glPopMatrix();
    }

    GL11.glPopMatrix();
}

From source file:vazkii.tinkerer.client.render.tile.RenderTileRepairer.java

License:Creative Commons License

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float t) {
    int meta = tileentity.worldObj == null ? 3 : tileentity.getBlockMetadata();
    int rotation = meta == 2 ? 0 : meta == 3 ? 180 : meta == 4 ? 270 : 90;

    TileRepairer repairer = (TileRepairer) tileentity;

    GL11.glPushMatrix();//from w w  w.  j a  va2  s  . com
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    bindTexture(modelTex);
    GL11.glTranslatef(0F, 2F, 1F);
    GL11.glScalef(1F, -1F, -1F);
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    GL11.glRotatef(rotation, 0F, 1F, 0F);
    model.render();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glScalef(1F, -1F, -1F);

    ItemStack item = ((TileRepairer) tileentity).getStackInSlot(0);
    if (item != null) {
        GL11.glPushMatrix();
        final float scale = 0.5F;
        GL11.glScalef(scale, scale, scale);
        GL11.glTranslatef(-0.5F, (float) (-2.5F + Math.sin(repairer.ticksExisted / 10F) * 0.1F), 0F);

        float deg = repairer.ticksExisted * 0.75F % 360F;
        GL11.glTranslatef(1F / 2F, 1F / 2F, 1F / 32F);
        GL11.glRotatef(deg, 0F, 1F, 0F);
        GL11.glTranslatef(-1F / 2F, -1F / 2F, -1F / 32F);

        bindTexture(TextureMap.locationItemsTexture);

        int renderPass = 0;
        do {
            Icon icon = item.getItem().getIcon(item, renderPass);
            if (icon != null) {
                Color color = new Color(item.getItem().getColorFromItemStack(item, renderPass));
                GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
                float f = icon.getMinU();
                float f1 = icon.getMaxU();
                float f2 = icon.getMinV();
                float f3 = icon.getMaxV();
                ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(),
                        icon.getIconHeight(), 1F / 16F);
                GL11.glColor3f(1F, 1F, 1F);
            }
            renderPass++;
        } while (renderPass < item.getItem().getRenderPasses(item.getItemDamage()));
        GL11.glPopMatrix();
    }

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    bindTexture(modelTex);
    GL11.glScalef(1F, -1F, -1F);
    GL11.glRotatef(rotation, 0F, 1F, 0F);
    model.renderGlass();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glScalef(1F, -1F, -1F);

    renderOverlay((TileRepairer) tileentity, ((TileRepairer) tileentity).tookLastTick ? repair : repairOff,
            1.25F);
    GL11.glPopMatrix();
    GL11.glColor4f(1F, 1F, 1F, 1F);
}

From source file:vazkii.tinkerer.client.render.tile.RenderTileTransmutator.java

License:Creative Commons License

private void renderItem(TileEntityTransmutator transmutator) {
    ItemStack stack = transmutator.getStackInSlot(0);
    Minecraft mc = MiscHelper.getMc();//from  w w  w  . j  a  va2  s  . co m
    if (stack != null) {
        mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? "/terrain.png" : "/gui/items.png");

        if (stack.getItem() instanceof ItemBlock
                && RenderBlocks.renderItemIn3d(Block.blocksList[stack.itemID].getRenderType())) {
            GL11.glTranslatef(0.5F, 0.4F, 0F);
            new RenderBlocks().renderBlockAsItem(Block.blocksList[stack.itemID], stack.getItemDamage(), 1F);
            GL11.glTranslatef(-0.5F, -0.4F, 0F);
        } else {
            int renderPass = 0;
            do {
                Icon icon = stack.getItem().getIcon(stack, renderPass);
                if (icon != null) {
                    Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));
                    GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
                    float f = icon.getMinU();
                    float f1 = icon.getMaxU();
                    float f2 = icon.getMinV();
                    float f3 = icon.getMaxV();
                    ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getSheetWidth(),
                            icon.getSheetHeight(), LibMisc.MODEL_DEFAULT_RENDER_SCALE);
                    GL11.glColor3f(1F, 1F, 1F);
                }
                renderPass++;
            } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
        }
    }
}

From source file:vazkii.tinkerer.client.tilerender.TileEntityRenderVoidGateway.java

License:Creative Commons License

@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float ticks) {
    VoidEntry entry = VoidMap.theMap.getEntryAtCoord(tile.xCoord, tile.zCoord);

    if (entry != null && entry.stack != null) {
        ItemStack stack = entry.stack.copy();
        stack.stackSize = 1;/*w  ww.j  a v  a 2 s  .  c om*/

        GL11.glPushMatrix();
        GL11.glTranslatef((float) x + 0.5F, (float) y + 0.1F,
                (float) z + 0.4F + MiscReference.MODEL_DEFAULT_RENDER_SCALE);
        GL11.glRotatef((float) ClientTickHandler.elapsedClientTicks % 360L / 20.0F * (180F / (float) Math.PI),
                0.0F, 1.0F, 0.0F);
        Minecraft mc = MiscHelper.getMc();
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine
                .getTexture(stack.getItem() instanceof ItemBlock ? "/terrain.png" : "/gui/items.png"));
        Tessellator var5 = Tessellator.instance;
        RenderBlocks var6 = new RenderBlocks();
        if (stack.getItem() instanceof ItemBlock
                && RenderBlocks.renderItemIn3d(Block.blocksList[stack.itemID].getRenderType())) {
            GL11.glScalef(0.5F, 0.5F, 0.5F);
            GL11.glTranslatef(0F, 0.9F, 0F);
            var6.renderBlockAsItem(Block.blocksList[stack.itemID], stack.getItemDamage(), 1F);

        } else {
            int renderPass = 0;
            GL11.glScalef(0.75F, 0.75F, 0.75F);
            GL11.glRotatef(
                    (float) ClientTickHandler.elapsedClientTicks % 360L / 20.0F * (180F / (float) Math.PI),
                    0.0F, 1.0F, 0.0F);
            GL11.glTranslatef(-0.5F, 0F, -MiscReference.MODEL_DEFAULT_RENDER_SCALE);
            do {
                Icon icon = stack.getItem().getIcon(stack, renderPass);
                if (icon != null) {
                    Color color = new Color(stack.getItem().getColorFromItemStack(stack, renderPass));

                    GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
                    float f = icon.getMinU();
                    float f1 = icon.getMaxU();
                    float f2 = icon.getMinV();
                    float f3 = icon.getMaxV();
                    // TODO Is this correct?
                    ItemRenderer.renderItemIn2D(var5, f1, f2, f, f3, icon.getOriginX(), icon.getOriginY(),
                            MiscReference.MODEL_DEFAULT_RENDER_SCALE);
                    GL11.glColor3f(1F, 1F, 1F);
                }
                renderPass++;
            } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
        }

        GL11.glColor4f(1F, 1F, 1F, 1F);
        GL11.glPopMatrix();
    } else {
        GL11.glPushMatrix();
        GL11.glColor4f(1F, 1F, 1F, 1F);
        GL11.glTranslatef((float) x + 2.5F, (float) y - 0.5F, (float) z + 0.5F);
        GL11.glRotatef(180F, 0.5F, 0F, 0.5F);
        RenderHelper.renderStar(0x140025, 0.03F, 0.03F, 0.03F);
        GL11.glPopMatrix();
    }
}

From source file:vazkii.tinkerer.gui.GuiElementalistLexiconIndex.java

License:Creative Commons License

@Override
public void drawScreen(int par1, int par2, float par3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glEnable(GL11.GL_BLEND);//from  w w  w . j a v a  2s.c  om
    mc.renderEngine.bindTexture(ResourcesReference.GUI_ELEMENTALIST_LEXICON_INDEX_TEXTURE);
    int shiftX = xStart + 137;
    int shiftY = yStart + 15;
    int bookmarkDifference = 14;

    ResearchCategory category = ResearchLibrary.categories.get(currentSection);
    int nodesSize = category.getNodes().size();
    boolean prev = currentPage != 0;
    boolean next = nodesSize > (currentPage + 1) * 12;

    drawTexturedModalRect(xStart, yStart, 0, 0, 186, 180);

    if (prev)
        fontRenderer.drawString("<", xStart + 20, yStart + 161, 0);
    if (next)
        fontRenderer.drawString(">", xStart + 117, yStart + 161, 0);

    int total = ResearchLibrary.allNodes.size();
    int done = 0;
    int undone = 0;
    for (Short s : ResearchHelper.clientResearch.researchesDone.keySet()) {
        byte value = ResearchHelper.clientResearch.researchesDone.get(s);
        if (value == (byte) 2)
            done += 1;
        else if (value == (byte) 1)
            undone += 1;
    }

    drawCenteredString(
            fontRenderer, FormattingCode.BLUE + "Completed: " + FormattingCode.YELLOW + done
                    + FormattingCode.BLUE + "/" + FormattingCode.YELLOW + total,
            width / 2, yStart + 185, 0xFFFFFF);
    if (undone > 0)
        drawCenteredString(fontRenderer, FormattingCode.RED + "Uncompleted Researches: " + undone, width / 2,
                yStart + 196, 0xFFFFFF);

    fontRenderer.setUnicodeFlag(true); // Start the fancy font rendering
    fontRenderer.drawStringWithShadow(
            (currentSection == 0 ? FormattingCode.UNDERLINE : "") + ResearchReference.CATEGORY_NAME_GENERAL,
            shiftX, shiftY, 0xFFFFFF);
    shiftY += bookmarkDifference;
    fontRenderer.drawStringWithShadow(
            (currentSection == 1 ? FormattingCode.UNDERLINE : "") + ResearchReference.CATEGORY_NAME_PURE,
            shiftX, shiftY, 0xFFFFFF);
    int i = 2;
    for (Element element : Element.class.getEnumConstants()) {
        shiftY += bookmarkDifference;
        fontRenderer.drawStringWithShadow(
                (currentSection == i ? FormattingCode.UNDERLINE : "") + element.getName(), shiftX, shiftY,
                0xFFFFFF);
        ++i;
    }
    int i1 = 0;
    for (ResearchNode node : currentShowingNodes) {
        boolean isHover = ((GuiInvisibleButton) buttonList.get(i1 + 8)).isHovered();
        fontRenderer.drawString(
                (isHover ? "* " : "")
                        + (ResearchHelper.clientResearch.isResearchDone(node.index) ? node.displayName
                                : FormattingCode.ITALICS + "Unknown Chapter"),
                xStart + 24, yStart + 16 + i1 * 12, 0);
        GL11.glPushMatrix();
        GL11.glScalef(0.5F, 0.5F, 0.5F);
        GL11.glColor3f(0F, 0F, 0F);
        RenderHelper.renderResearchIcon(node, true, (xStart + 14) * 2 + 1, (yStart + 16 + i1 * 12) * 2 + 1,
                zLevel);
        zLevel += 1;
        GL11.glColor3f(1F, 1F, 1F);
        RenderHelper.renderResearchIcon(node, true, (xStart + 14) * 2, (yStart + 16 + i1 * 12) * 2, zLevel);
        zLevel -= 1;
        GL11.glPopMatrix();

        ++i1;
    }
    fontRenderer.setUnicodeFlag(false); // End the fancy font rendering

    if (((GuiInvisibleButton) buttonList.get(6)).isHovered() && prev)
        RenderHelper.renderTooltip(par1, par2, "Prev. Page");
    if (((GuiInvisibleButton) buttonList.get(7)).isHovered() && next)
        RenderHelper.renderTooltip(par1, par2, "Next Page");

    GL11.glDisable(GL11.GL_BLEND);
    super.drawScreen(par1, par2, par3);
}