Example usage for org.lwjgl.opengl GL11 glColor4ub

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

Introduction

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

Prototype

public static native void glColor4ub(@NativeType("GLubyte") byte red, @NativeType("GLubyte") byte green,
        @NativeType("GLubyte") byte blue, @NativeType("GLubyte") byte alpha);

Source Link

Document

Unsigned version of #glColor4b Color4b

Usage

From source file:vazkii.botania.client.core.handler.BoundTileRenderer.java

License:Open Source License

private static void renderBlockOutlineAt(BlockPos pos, int color, float thickness) {
    double renderPosX, renderPosY, renderPosZ;

    try {/*  w w  w.  java 2 s.c  om*/
        renderPosX = (double) ClientMethodHandles.renderPosX_getter
                .invokeExact(Minecraft.getMinecraft().getRenderManager());
        renderPosY = (double) ClientMethodHandles.renderPosY_getter
                .invokeExact(Minecraft.getMinecraft().getRenderManager());
        renderPosZ = (double) ClientMethodHandles.renderPosZ_getter
                .invokeExact(Minecraft.getMinecraft().getRenderManager());
    } catch (Throwable t) {
        return;
    }

    GlStateManager.pushMatrix();
    GlStateManager.translate(pos.getX() - renderPosX, pos.getY() - renderPosY, pos.getZ() - renderPosZ + 1);
    Color colorRGB = new Color(color);
    GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(),
            (byte) 255);

    World world = Minecraft.getMinecraft().theWorld;
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    drawWireframe: {
        if (block != null) {
            AxisAlignedBB axis;

            if (block instanceof IWireframeAABBProvider)
                axis = ((IWireframeAABBProvider) block).getWireframeAABB(world, pos);
            else
                axis = state.getSelectedBoundingBox(world, pos);

            if (axis == null)
                break drawWireframe;

            axis = axis.offset(-pos.getX(), -pos.getY(), -(pos.getZ() + 1));

            GlStateManager.scale(1F, 1F, 1F);

            GL11.glLineWidth(thickness);
            renderBlockOutline(axis);

            GL11.glLineWidth(thickness + 3F);
            GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(),
                    (byte) 64);
            renderBlockOutline(axis);
        }
    }

    GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) 255);
    GlStateManager.popMatrix();
}

From source file:vazkii.botania.client.core.handler.HUDHandler.java

License:Open Source License

private static void renderManaInvBar(ScaledResolution res, boolean hasCreative, int totalMana,
        int totalMaxMana) {
    Minecraft mc = Minecraft.getMinecraft();
    int width = 182;
    int x = res.getScaledWidth() / 2 - width / 2;
    int y = res.getScaledHeight() - ConfigHandler.manaBarHeight;

    if (!hasCreative) {
        if (totalMaxMana == 0)
            width = 0;// w w  w.j a v a 2 s . c o  m
        else
            width *= (double) totalMana / (double) totalMaxMana;
    }

    if (width == 0) {
        if (totalMana > 0)
            width = 1;
        else
            return;
    }

    Color color = new Color(Color.HSBtoRGB(0.55F,
            (float) Math.min(1F, Math.sin(System.currentTimeMillis() / 200D) * 0.5 + 1F), 1F));
    GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(),
            (byte) (255 - color.getRed()));
    mc.renderEngine.bindTexture(manaBar);

    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderHelper.drawTexturedModalRect(x, y, 0, 0, 251, width, 5);
    GlStateManager.disableBlend();
    GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) 255);
}

From source file:vazkii.botania.client.core.handler.HUDHandler.java

License:Open Source License

public static void renderManaBar(int x, int y, int color, float alpha, int mana, int maxMana) {
    Minecraft mc = Minecraft.getMinecraft();

    GlStateManager.color(1F, 1F, 1F, alpha);
    mc.renderEngine.bindTexture(manaBar);
    RenderHelper.drawTexturedModalRect(x, y, 0, 0, 0, 102, 5);

    int manaPercentage = Math.max(0, (int) ((double) mana / (double) maxMana * 100));

    if (manaPercentage == 0 && mana > 0)
        manaPercentage = 1;//from www.ja  v  a  2  s .  c o  m

    RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, 100, 3);

    Color color_ = new Color(color);
    GL11.glColor4ub((byte) color_.getRed(), (byte) color_.getGreen(), (byte) color_.getBlue(),
            (byte) (255F * alpha));
    RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, Math.min(100, manaPercentage), 3);
    GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) 255);
}

From source file:vazkii.botania.client.core.handler.SubTileRadiusRenderHandler.java

License:Open Source License

public void renderRectangle(AxisAlignedBB aabb) {
    GL11.glPushMatrix();//from   w  w w . j a v  a2  s  . co m
    GL11.glTranslated(aabb.minX - RenderManager.renderPosX, aabb.minY - RenderManager.renderPosY,
            aabb.minZ - RenderManager.renderPosZ);
    int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);

    Color colorRGB = new Color(color);
    GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32);

    double f = 1F / 16F;
    double x = aabb.maxX - aabb.minX - f;
    double z = aabb.maxZ - aabb.minZ - f;

    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertex(x, f, f);
    tessellator.addVertex(f, f, f);
    tessellator.addVertex(f, f, z);
    tessellator.addVertex(x, f, z);
    tessellator.draw();

    x += f;
    z += f;
    double f1 = f + f / 4F;
    GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64);
    tessellator.startDrawingQuads();
    tessellator.addVertex(x, f1, 0);
    tessellator.addVertex(0, f1, 0);
    tessellator.addVertex(0, f1, z);
    tessellator.addVertex(x, f1, z);
    tessellator.draw();

    GL11.glPopMatrix();
}

From source file:vazkii.botania.client.core.handler.SubTileRadiusRenderHandler.java

License:Open Source License

public void renderCircle(ChunkCoordinates center, double radius) {
    GL11.glPushMatrix();/* ww  w .ja  v  a2 s.  c  o  m*/
    double x = center.posX + 0.5;
    double y = center.posY;
    double z = center.posZ + 0.5;
    GL11.glTranslated(x - RenderManager.renderPosX, y - RenderManager.renderPosY, z - RenderManager.renderPosZ);
    int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);

    Color colorRGB = new Color(color);
    GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 32);

    double f = 1F / 16F;

    int totalAngles = 360;
    int drawAngles = 360;
    int step = totalAngles / drawAngles;

    radius -= f;
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawing(GL11.GL_TRIANGLE_FAN);
    tessellator.addVertex(0, f, 0);
    for (int i = 0; i < totalAngles + 1; i += step) {
        double rad = (totalAngles - i) * Math.PI / 180.0;
        double xp = Math.cos(rad) * radius;
        double zp = Math.sin(rad) * radius;
        tessellator.addVertex(xp, f, zp);
    }
    tessellator.addVertex(0, f, 0);
    tessellator.draw();

    radius += f;
    double f1 = f + f / 4F;
    GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64);
    tessellator.startDrawing(GL11.GL_TRIANGLE_FAN);
    tessellator.addVertex(0, f1, 0);
    for (int i = 0; i < totalAngles + 1; i += step) {
        double rad = (totalAngles - i) * Math.PI / 180.0;
        double xp = Math.cos(rad) * radius;
        double zp = Math.sin(rad) * radius;
        tessellator.addVertex(xp, f1, zp);
    }
    tessellator.addVertex(0, f1, 0);
    tessellator.draw();
    GL11.glPopMatrix();
}

From source file:vazkii.botania.client.render.item.RenderLens.java

License:Open Source License

public static void render(ItemStack item, int color_) {
    int dmg = item.getItemDamage();
    IIcon icon = item.getItem().getIconFromDamageForRenderPass(dmg, 1);
    float f = icon.getMinU();
    float f1 = icon.getMaxU();
    float f2 = icon.getMinV();
    float f3 = icon.getMaxV();
    float scale = 1F / 16F;

    GL11.glColor4f(1F, 1F, 1F, 1F);//  www.  ja v a  2s  . c  o m
    ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(),
            scale);

    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    Color color = new Color(color_);
    GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255);

    boolean shiny = ItemLens.getStoredColor(item) != -1;
    icon = ItemLens.iconGlass;
    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(0F, 0F, -0.5F);
    renderShinyLensIcon(icon, shiny);
    GL11.glRotatef(180F, 0F, 1F, 0F);
    GL11.glTranslatef(-16F, 0F, 0F);
    renderShinyLensIcon(icon, shiny);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();

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

From source file:vazkii.gencreator.client.SelectionRenderHandler.java

License:Creative Commons License

private void renderBlockOutlineAt(ChunkCoordinates pos, int color) {
    GL11.glPushMatrix();/*from w w w .ja v  a2 s  . co m*/
    GL11.glTranslated(pos.posX - RenderManager.renderPosX, pos.posY + 1 - RenderManager.renderPosY,
            pos.posZ - RenderManager.renderPosZ);
    GL11.glScalef(1.0F, -1.0F, -1.0F);
    Color colorRGB = new Color(color);
    GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(),
            (byte) 127);
    renderBlockOutline();
    GL11.glPopMatrix();
}

From source file:vazkii.gencreator.client.SelectionRenderHandler.java

License:Creative Commons License

private void renderSizedOutlineAt(ChunkCoordinates pos, int color, ChunkCoordinates size) {
    GL11.glPushMatrix();/*from ww w .ja v  a 2  s  .c o m*/
    GL11.glTranslated(pos.posX - RenderManager.renderPosX, pos.posY - RenderManager.renderPosY,
            pos.posZ - RenderManager.renderPosZ);
    //GL11.glScalef(1.0F, -1.0F, -1.0F);
    Color colorRGB = new Color(color);
    GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(),
            (byte) 190);
    renderSizedOutline(size);
    GL11.glPopMatrix();
}

From source file:vazkii.recubed.client.renders.PieChartRender.java

License:Creative Commons License

public Entry renderChart(int radius, int x, int y, int mx, int my) {
    GL11.glPushMatrix();/*from w  w w . ja  v a  2s  .c om*/
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    Entry tooltip = null;
    float tooltipDeg = 0;

    boolean mouseIn = (x - mx) * (x - mx) + (y - my) * (y - my) <= radius * radius;
    float angle = mouseAngle(x, y, mx, my);
    int highlight = 5;

    GL11.glShadeModel(GL11.GL_SMOOTH);
    float totalDeg = 0;
    for (Entry entry : entries) {
        boolean mouseInSector = mouseIn && angle > totalDeg && angle < totalDeg + entry.angle;
        Color color = new Color(entry.color).brighter();
        Color color1 = ClientCacheHandler.useGradients ? new Color(entry.color).darker().darker() : color;

        if (mouseInSector) {
            tooltip = entry;
            tooltipDeg = totalDeg;

            radius += highlight;
        }

        GL11.glBegin(GL11.GL_TRIANGLE_FAN);

        GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255);
        GL11.glVertex2i(x, y);

        GL11.glColor4ub((byte) color1.getRed(), (byte) color1.getGreen(), (byte) color1.getBlue(), (byte) 255);
        for (float i = entry.angle; i >= 0; i -= 0.01) {
            float rad = (float) ((i + totalDeg) / 180F * Math.PI);
            GL11.glVertex2d(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius);
        }
        totalDeg += entry.angle;

        GL11.glColor4ub((byte) 0, (byte) 0, (byte) 0, (byte) 255);
        GL11.glVertex2i(x, y);
        GL11.glEnd();

        if (mouseInSector)
            radius -= highlight;
    }
    GL11.glShadeModel(GL11.GL_FLAT);

    totalDeg = 0;
    GL11.glLineWidth(2F);
    GL11.glColor4f(0F, 0F, 0F, 1F);
    for (Entry entry : entries) {
        if (Math.round(entry.angle) == 360)
            break;

        boolean mouseInSector = mouseIn && angle > totalDeg && angle < totalDeg + entry.angle;

        if (mouseInSector)
            radius += highlight;

        float rad = (float) (totalDeg / 180F * Math.PI);

        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex2i(x, y);
        GL11.glVertex2d(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius);
        GL11.glEnd();

        if (mouseInSector)
            radius -= highlight;

        totalDeg += entry.angle;
    }

    GL11.glLineWidth(3F);
    GL11.glColor4f(0F, 0F, 0F, 1F);

    GL11.glBegin(GL11.GL_LINE_LOOP);
    for (float i = 0; i < 360; i++) {
        boolean sectorHighlighted = tooltip != null && i >= tooltipDeg && i < tooltip.angle + tooltipDeg;
        boolean first = tooltip != null && tooltip.angle != 360 && i - tooltipDeg == 0;
        boolean last = tooltip != null && tooltip.angle != 360 && i - (tooltipDeg + tooltip.angle) == -1;

        if (first)
            addVertexForAngle(x, y, i, radius);

        if (sectorHighlighted)
            radius += highlight;

        addVertexForAngle(x, y, i, radius);

        if (last)
            addVertexForAngle(x, y, i + 1, radius);

        if (sectorHighlighted)
            radius -= highlight;
    }
    GL11.glEnd();

    if (tooltip != null) {
        List<String> tooltipList = new ArrayList(
                Arrays.asList(StatCollector.translateToLocal(tooltip.name), EnumChatFormatting.GRAY + ""
                        + tooltip.val + " (" + Math.round(tooltip.angle / 3.6F * 100D) / 100D + "%)"));
        if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips)
            tooltipList.add(EnumChatFormatting.GRAY + "" + EnumChatFormatting.ITALIC + tooltip.name);
        RenderHelper.renderTooltip(mx, my, tooltipList);
    }

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glPopMatrix();

    return tooltip;
}

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

License:Creative Commons License

@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
    List<String> renderString = null;

    if (transmutator.getStackInSlot(0) != null) {
        ObjectTags tags = ThaumcraftCraftingManager.getObjectTags(transmutator.getStackInSlot(0));
        int degPerTag = 360 / tags.size();
        int renderDeg = -90;
        for (EnumTag tag : tags.getAspects()) {
            int amount = tags.getAmount(tag);
            int xpos = (int) (50 + 35 * Math.cos(renderDeg * Math.PI / 180));
            int ypos = (int) (16 + 35 * Math.sin(renderDeg * Math.PI / 180));
            UtilsFX.drawTag(mc, xpos, ypos, tag, amount * ConfigurationHandler.transmutatorEssentiaMultiplier,
                    this, false, false);
            float deg = (float) (transmutator.ticksExisted * amount % 360F);

            int color = tag.color;
            int red = color >> 16 & 0xFF;
            int green = color >> 8 & 0xFF;
            int blue = color & 0xFF;
            GL11.glColor4ub((byte) red, (byte) green, (byte) blue, (byte) 128);
            if (transmutator.foundTags.getAmount(tag) >= amount
                    * ConfigurationHandler.transmutatorEssentiaMultiplier)
                renderGlyphsAt(xpos + 8, ypos + 8, deg);

            if (i > xpos + x && i < xpos + x + 16 && j > ypos + y && j < ypos + y + 16)
                renderString = Arrays.asList(tag.name, tag.meaning);
            renderDeg += degPerTag;/*from ww w. j  a  va  2 s.c om*/
        }

        if (renderString != null)
            UtilsFX.drawCustomTooltip(this, itemRenderer, fontRenderer, renderString, i - x, j - y,
                    EnumChatFormatting.AQUA.ordinal());
    }
}