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:advancedbrewing.gui.GuiMachine.java

License:Minecraft Mod Public

@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
    super.drawGuiContainerBackgroundLayer(par1, par2, par3);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.mc.getTextureManager().bindTexture(GuiMachine.TEXTURE);

    int x = (this.width - this.xSize) / 2;
    int y = (this.height - this.ySize) / 2;

    this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);

    float storedEnergy = this.tileEntity.getPowerHandler().getEnergyStored();
    if (storedEnergy > 0) {
        float gaugeWidth = ((storedEnergy) / this.tileEntity.getPowerHandler().getMaxEnergyStored()) * 160f;
        this.drawTexturedModalRect(x + 8, y + 8, 0, this.ySize, (int) gaugeWidth, 6);
    }//  w ww .ja v a 2 s. c  om
}

From source file:advancedbrewing.gui.GuiMachine.java

License:Minecraft Mod Public

protected void displayFluidGauge(int j, int k, int line, int col, int squaled, FluidStack fluidStack) {
    if (fluidStack == null) {
        return;/*  www .  java2s . c  o  m*/
    }

    Fluid fluid = fluidStack.getFluid();

    Icon liquidIcon = null;
    if (fluid != null && fluid.getStillIcon() != null) {
        liquidIcon = fluid.getStillIcon();
    }

    this.mc.renderEngine.bindTexture(GuiMachine.BLOCK_TEXTURE);

    PotionDefinition potionDefinition = Utils.getPotionDefinitionByFluid(fluid);

    if (potionDefinition != null && !potionDefinition.getName().equals("water")) {
        int color = potionDefinition.getColor();
        float r = (color >> 16 & 255) / 255.0F;
        float g = (color >> 8 & 255) / 255.0F;
        float b = (color & 255) / 255.0F;
        GL11.glColor4f(r, g, b, 1.0F);
    }

    if (liquidIcon != null) {
        int start = 0;
        while (true) {
            int x;

            if (squaled > 16) {
                x = 16;
                squaled -= 16;
            } else {
                x = squaled;
                squaled = 0;
            }

            this.drawTexturedModelRectFromIcon(j + col, k + line + 58 - x - start, liquidIcon, 16,
                    16 - (16 - x));
            start = start + 16;

            if (x == 0 || squaled == 0) {
                break;
            }
        }
    }

    if (potionDefinition != null) {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }

    this.mc.renderEngine.bindTexture(GuiMachine.TEXTURE);
    this.drawTexturedModalRect(j + col, k + line, 176, 0, 16, 60);
}

From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java

License:Minecraft Mod Public

@Override
public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
    if (type == ItemRenderType.ENTITY) {
        if (RenderManager.instance.options.fancyGraphics) {
            if (RenderItem.renderInFrame) {
                GL11.glTranslatef(0.0F, -0.05F, -0.084375F);
                GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
            }/* ww  w .  j  a va  2  s  .co  m*/

            GL11.glTranslatef(-0.5F, -0.25F,
                    -(0.084375F * ItemGlintOverlayRenderer.RENDERITEM.getMiniItemCount(itemStack) / 2.0F));

            this.renderItem3D(type, itemStack, data);
        } else {
            if (!RenderItem.renderInFrame) {
                GL11.glRotatef(180.0F - RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
            }

            TextureManager renderEngine = FMLClientHandler.instance().getClient().renderEngine;
            Tessellator tessellator = Tessellator.instance;

            // render colored overlay
            renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
            this.setColorByItemStack(itemStack);
            Icon icon = this.getIcon(itemStack, 0);

            tessellator.startDrawingQuads();
            tessellator.setNormal(0.0F, 1.0F, 0.0F);
            tessellator.addVertexWithUV((-0.5F), (-0.25F), 0.0D, icon.getMinU(), icon.getMaxV());
            tessellator.addVertexWithUV((0.5F), (-0.25F), 0.0D, icon.getMaxU(), icon.getMaxV());
            tessellator.addVertexWithUV((0.5F), (0.75F), 0.0D, icon.getMaxU(), icon.getMinV());
            tessellator.addVertexWithUV((-0.5F), (0.75F), 0.0D, icon.getMinU(), icon.getMinV());
            tessellator.draw();

            // render uncolored icon
            this.setColorByItemStack(itemStack);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            icon = this.getIcon(itemStack, 1);

            tessellator.startDrawingQuads();
            tessellator.setNormal(0.0F, 1.0F, 0.0F);
            tessellator.addVertexWithUV((-0.5F), (-0.25F), 0.0D, icon.getMinU(), icon.getMaxV());
            tessellator.addVertexWithUV((0.5F), (-0.25F), 0.0D, icon.getMaxU(), icon.getMaxV());
            tessellator.addVertexWithUV((0.5F), (0.75F), 0.0D, icon.getMaxU(), icon.getMinV());
            tessellator.addVertexWithUV((-0.5F), (0.75F), 0.0D, icon.getMinU(), icon.getMinV());
            tessellator.draw();
        }
    } else if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
        this.renderItem3D(type, itemStack, data);
    } else if (type == ItemRenderType.INVENTORY) {
        this.renderItem2D(type, itemStack, data);
    }
}

From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java

License:Minecraft Mod Public

private void renderItem3D(ItemRenderType type, ItemStack itemStack, Object... data) {
    TextureManager renderEngine = FMLClientHandler.instance().getClient().renderEngine;
    Tessellator tessellator = Tessellator.instance;

    if (this.shouldRenderOverlay(itemStack)) {
        // render colored overlay
        renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
        this.setColorByItemStack(itemStack);
        Icon icon = this.getIcon(itemStack, 0);
        ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
                icon.getIconWidth(), icon.getIconHeight(), 0.0625F);

        // render glint
        if (itemStack.hasEffect(0)) {
            renderEngine.bindTexture(ItemGlintOverlayRenderer.RES_ITEM_GLINT);

            GL11.glDepthFunc(GL11.GL_EQUAL);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glMatrixMode(GL11.GL_TEXTURE);

            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);

            // first pass
            GL11.glPushMatrix();/*  w  w w  .  j a  va2  s  . c o m*/
            GL11.glScalef(0.125F, 0.125F, 0.125F);
            float f9 = 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.0625F);
            GL11.glPopMatrix();

            // second pass
            GL11.glPushMatrix();
            GL11.glScalef(0.125F, 0.125F, 0.125F);
            f9 = 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.0625F);
            GL11.glPopMatrix();

            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }

    // render uncolored icon
    renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    Icon icon = this.getIcon(itemStack, 1);
    ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
            icon.getIconWidth(), icon.getIconHeight(), 0.0625F);
}

From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java

License:Minecraft Mod Public

private void renderItem2D(ItemRenderType type, ItemStack itemStack, Object... data) {
    TextureManager renderEngine = FMLClientHandler.instance().getClient().renderEngine;
    Tessellator tessellator = Tessellator.instance;

    if (this.shouldRenderOverlay(itemStack)) {
        // render colored overlay
        renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
        this.setColorByItemStack(itemStack);
        Icon icon = this.getIcon(itemStack, 0);
        ItemGlintOverlayRenderer.RENDERITEM.renderIcon(0, 0, icon, 16, 16);

        // render glint
        if (itemStack.hasEffect(0)) {
            renderEngine.bindTexture(ItemGlintOverlayRenderer.RES_ITEM_GLINT);

            GL11.glDepthFunc(GL11.GL_GREATER);
            GL11.glDepthMask(false);/*from   w  w w.  ja va 2 s .  c  o  m*/
            GL11.glEnable(GL11.GL_BLEND);

            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);

            // first pass
            float f2 = Minecraft.getSystemTime() % 3000L / 3000.0F * 256.0F;
            tessellator.startDrawingQuads();
            tessellator.addVertexWithUV(-2, -2 + 20, -50.0F, (f2 + 20 * 4.0F) * 0.00390625F, 20 * 0.00390625F);
            tessellator.addVertexWithUV(-2 + 20, -2 + 20, -50.0F, (f2 + 20 + 20 * 4.0F) * 0.00390625F,
                    20 * 0.00390625F);
            tessellator.addVertexWithUV(-2 + 20, -2, -50.0F, (f2 + 20) * 0.00390625F, 0);
            tessellator.addVertexWithUV(-2, -2, -50.0F, (f2) * 0.00390625F, 0);
            tessellator.draw();

            // second pass
            f2 = Minecraft.getSystemTime() % 4873L / 4873.0F * 256.0F;
            tessellator.startDrawingQuads();
            tessellator.addVertexWithUV(-2, -2 + 20, -50.0F, (f2 + 20 * -1.0F) * 0.00390625F, 20 * 0.00390625F);
            tessellator.addVertexWithUV(-2 + 20, -2 + 20, -50.0F, (f2 + 20 + 20 * -1.0F) * 0.00390625F,
                    20 * 0.00390625F);
            tessellator.addVertexWithUV(-2 + 20, -2, -50.0F, (f2 + 20) * 0.00390625F, 0);
            tessellator.addVertexWithUV(-2, -2, -50.0F, (f2) * 0.00390625F, 0);
            tessellator.draw();

            GL11.glDisable(GL11.GL_BLEND);
            GL11.glDepthMask(true);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }

    // render uncolored icon
    renderEngine.bindTexture(renderEngine.getResourceLocation(itemStack.getItemSpriteNumber()));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    Icon icon = this.getIcon(itemStack, 1);
    ItemGlintOverlayRenderer.RENDERITEM.renderIcon(0, 0, icon, 16, 16);
}

From source file:advancedbrewing.renderer.ItemGlintOverlayRenderer.java

License:Minecraft Mod Public

private void setColorByItemStack(ItemStack itemStack) {
    int color = Item.itemsList[itemStack.getItem().itemID].getColorFromItemStack(itemStack, 0);
    float r = (color >> 16 & 255) / 255.0F;
    float g = (color >> 8 & 255) / 255.0F;
    float b = (color & 255) / 255.0F;
    GL11.glColor4f(r, g, b, 1.0F);
}

From source file:aic2o.energy.gui.GuiPetrochemicalGenerator.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(DefaultProps.TEXTURE_PATH_GUI + "/combustion_engine_gui.png");
    int j = (width - xSize) / 2;
    int k = (height - ySize) / 2;
    drawTexturedModalRect(j, k, 0, 0, xSize, ySize);

    TileEngine engine = (TileEngine) tile;
    EnginePetrochemical enginePetrochemical = ((EnginePetrochemical) engine.engine);

    if (engine.getScaledBurnTime(58) > 0) {
        displayGauge(j, k, 19, 104, engine.getScaledBurnTime(58), enginePetrochemical.getFuel());
    }/*from   w w  w . j  a  v a  2 s.com*/

    if (enginePetrochemical.getScaledCoolant(58) > 0) {
        displayGauge(j, k, 19, 122, enginePetrochemical.getScaledCoolant(58), enginePetrochemical.getCoolant());
    }
}

From source file:akarnokd.opengl.experiment.Planet.java

License:Apache License

public static Planet create(String file, float radius, int smoothness) {
    Planet p = new Planet();
    p.id = ObjectTracker.add(p);/*from w ww.j  a v a 2 s  . c  o m*/
    p.radius = radius;
    p.smoothness = smoothness;

    // GLU sphere requires a mirrored texture ?!
    p.tex = Texture.fromFile(file, false, true);

    {
        Sphere sphere = new Sphere();
        sphere.setDrawStyle(GLU.GLU_FILL);
        sphere.setTextureFlag(true);
        sphere.setNormals(GLU.GLU_SMOOTH);
        sphere.setOrientation(GLU.GLU_OUTSIDE);

        p.handle = GL11.glGenLists(1);

        GL11.glNewList(p.handle, GL11.GL_COMPILE);
        p.tex.use();
        GL11.glColor4f(1, 1, 1, 1);
        sphere.draw(radius, smoothness, smoothness);
        p.tex.stop();
        GL11.glEndList();
    }
    {
        Sphere sphere2 = new Sphere();
        sphere2.setDrawStyle(GLU.GLU_FILL);
        sphere2.setNormals(GLU.GLU_SMOOTH);
        sphere2.setOrientation(GLU.GLU_OUTSIDE);

        p.handleSelect = GL11.glGenLists(1);
        GL11.glNewList(p.handleSelect, GL11.GL_COMPILE);
        G2D.color(p.id);
        sphere2.draw(radius, smoothness, smoothness);
        GL11.glEndList();
    }
    {
        Sphere sphere2 = new Sphere();
        sphere2.setDrawStyle(GLU.GLU_LINE);
        sphere2.setNormals(GLU.GLU_NONE);

        p.wireframe = GL11.glGenLists(1);
        GL11.glNewList(p.wireframe, GL11.GL_COMPILE);
        sphere2.draw(radius, smoothness, smoothness);
        GL11.glEndList();
    }

    return p;
}

From source file:allout58.mods.techtree.client.elements.GuiButtonEditNode.java

License:Open Source License

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
    if (this.visible) {
        FontRenderer fontRenderer = mc.fontRenderer;
        boolean mouseOver = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width
                && mouseY < yPosition + height;

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

        drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + height,
                Config.INSTANCE.client.colorBtnUnlocked1, Config.INSTANCE.client.colorBtnUnlocked2);

        if (isSelected) {
            drawRect(xPosition - 1, yPosition - 1, xPosition + width + 1, yPosition + height + 1, 0x99101010);
        }/*from   w  w  w  .  j  av  a 2s.  c  o m*/

        if (mouseOver) {
            drawRect(xPosition - 2, yPosition - 2, xPosition + width + 2, yPosition + height + 2, 0x30FFFFFF);
        }

        GL11.glPushMatrix();

        GL11.glScaled(0.75, 0.75, 0.75);
        GL11.glTranslated(xPosition * .33, yPosition * .33, 0);
        fontRenderer.drawString(node.getName(), xPosition + 2, yPosition + 2,
                Config.INSTANCE.client.colorBtnText, true);

        GL11.glPopMatrix();

        this.mouseDragged(mc, mouseX, mouseY);
    }
}

From source file:allout58.mods.techtree.client.elements.GuiButtonTechNode.java

License:Open Source License

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
    if (this.visible) {
        try {/*from w  w w.  ja v a2s .  com*/
            bar.setMax((float) (ResearchClient.getInstance().getResearch(node.getId()))
                    / (float) (node.getScienceRequired()));
        } catch (Exception e) {
            e.printStackTrace();
        }

        FontRenderer fontRenderer = mc.fontRenderer;
        boolean mouseOver = mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width
                && mouseY < yPosition + height;

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

        String playerUUID = FMLClientHandler.instance().getClient().thePlayer.getUniqueID().toString();

        switch (ResearchClient.getInstance(playerUUID).getMode(node.getId())) {
        case Locked:
            drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + height,
                    Config.INSTANCE.client.colorBtnLocked1, Config.INSTANCE.client.colorBtnLocked2);
            break;
        case Unlocked:
            drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + height,
                    Config.INSTANCE.client.colorBtnUnlocked1, Config.INSTANCE.client.colorBtnUnlocked2);
            try {
                bar.setEnabled(ResearchClient.getInstance().getResearch(node.getId()) > 0);
            } catch (Exception e) {
                e.printStackTrace();
            }
            break;
        case Researching:
            drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + height,
                    Config.INSTANCE.client.colorBtnResearch1, Config.INSTANCE.client.colorBtnResearch2);
            bar.setEnabled(true);
            break;
        case Completed:
            drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + height,
                    Config.INSTANCE.client.colorBtnCompleted1, Config.INSTANCE.client.colorBtnCompleted2);
            bar.setEnabled(false);
            break;
        default:
            System.err.println("ERROR! Invalid button state! o.O");
        }

        if (mouseOver) {
            drawRect(xPosition - 1, yPosition - 1, xPosition + width + 1, yPosition + height + 1, 0x30FFFFFF);
        }

        GL11.glPushMatrix();

        GL11.glScaled(0.75, 0.75, 0.75);
        GL11.glTranslated(xPosition * .33, yPosition * .33, 0);
        fontRenderer.drawString(node.getName(), xPosition + 2, yPosition + 2,
                Config.INSTANCE.client.colorBtnText, true);

        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glScaled(.5, .5, .5);
        GL11.glTranslated(xPosition, yPosition, 0);
        fontRenderer.drawString(ResearchClient.getInstance(playerUUID).getMode(node.getId()).name(),
                xPosition + 2, yPosition + 10 + fontRenderer.FONT_HEIGHT, Config.INSTANCE.client.colorBtnText,
                false);
        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glScaled(1, 1, 1);
        bar.doRender();
        GL11.glPopMatrix();

        this.mouseDragged(mc, mouseX, mouseY);
    }
}