Example usage for org.lwjgl.opengl GL11 glColor3ub

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

Introduction

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

Prototype

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

Source Link

Document

Unsigned version of #glColor3b Color3b

Usage

From source file:thaumic.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.getWorldObj() == 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.ja v  a 2  s  .c  o m
    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 {
            IIcon 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:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glColor3ub(byte a, byte b, byte c) {
    GL11.glColor3ub(a, b, c);
}

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

License:Open Source License

private void dispatchRenders(IInventory inv, EntityPlayer player, RenderType type, float partialTicks) {
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if (stack != null) {
            Item item = stack.getItem();

            if (item instanceof IPhantomInkable) {
                IPhantomInkable inkable = (IPhantomInkable) item;
                if (inkable.hasPhantomInk(stack))
                    continue;
            }//from w w w  .  j a va 2  s.c om

            if (item instanceof ICosmeticAttachable) {
                ICosmeticAttachable attachable = (ICosmeticAttachable) item;
                ItemStack cosmetic = attachable.getCosmeticItem(stack);
                if (cosmetic != null) {
                    GlStateManager.pushMatrix();
                    GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255); // Some of the baubles use this so we must restore it manually as well
                    GlStateManager.color(1F, 1F, 1F, 1F);
                    ((IBaubleRender) cosmetic.getItem()).onPlayerBaubleRender(cosmetic, player, type,
                            partialTicks);
                    GlStateManager.popMatrix();
                    continue;
                }
            }

            if (item instanceof IBaubleRender) {
                GlStateManager.pushMatrix();
                GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255); // Some of the baubles use this so we must restore it manually as well
                GlStateManager.color(1F, 1F, 1F, 1F);
                ((IBaubleRender) stack.getItem()).onPlayerBaubleRender(stack, player, type, partialTicks);
                GlStateManager.popMatrix();
            }
        }
    }
}

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

License:Open Source License

public void render(float fract1, float fract2, boolean flip, int color) {
    if (flip) {/*w ww. j ava 2 s. c  om*/
        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());

    GL11.glPushAttrib(GL11.GL_TRANSFORM_BIT);
    GlStateManager.disableRescaleNormal();
    GlStateManager.enableNormalize();

    if (fract1 > 0) {
        GlStateManager.pushMatrix();
        if (flip)
            GlStateManager.translate(-2.5F * f, 1.0F * f, -2.5F * f);
        else {
            GlStateManager.rotate(180F, 0F, 0F, 1F);
            GlStateManager.translate(-2.5F * f, -6.0F * f, -2.5F * f);
        }

        GlStateManager.scale(1F, fract1, 1F);
        sand1.render(f);
        GlStateManager.popMatrix();
    }

    if (fract2 > 0) {
        GlStateManager.pushMatrix();
        if (flip)
            GlStateManager.translate(-2.5F * f, -6.0F * f, -2.5F * f);
        else {
            GlStateManager.rotate(180F, 0F, 0F, 1F);
            GlStateManager.translate(-2.5F * f, 1.0F * f, -2.5F * f);
        }

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

        sand2.render(f);
        GlStateManager.popMatrix();
    }

    GL11.glPopAttrib();

    GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
    glass1.render(f);
    glass2.render(f);
}

From source file:vazkii.botania.client.render.tile.RenderTileBrewery.java

License:Open Source License

public void renderItemStack(ItemStack stack) {
    if (stack != null) {
        Minecraft mc = Minecraft.getMinecraft();
        mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture
                : TextureMap.locationItemsTexture);

        float s = 0.25F;
        GL11.glScalef(s, s, s);/*from   ww w. j av a 2  s. com*/
        GL11.glScalef(2F, 2F, 2F);
        if (!ForgeHooksClient.renderEntityItem(
                new EntityItem(brewery.getWorldObj(), brewery.xCoord, brewery.yCoord, brewery.zCoord, stack),
                stack, 0F, 0F, brewery.getWorldObj().rand, mc.renderEngine, RenderBlocks.getInstance(), 1)) {
            GL11.glScalef(0.5F, 0.5F, 0.5F);
            if (stack.getItem() instanceof ItemBlock
                    && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) {
                GL11.glScalef(0.5F, 0.5F, 0.5F);
                GL11.glTranslatef(1F, 1.1F, 0F);
                GL11.glPushMatrix();
                RenderBlocks.getInstance().renderBlockAsItem(Block.getBlockFromItem(stack.getItem()),
                        stack.getItemDamage(), 1F);
                GL11.glPopMatrix();
                GL11.glTranslatef(-1F, -1.1F, 0F);
                GL11.glScalef(2F, 2F, 2F);
            } else {
                int renderPass = 0;
                do {
                    IIcon 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.getIconWidth(),
                                icon.getIconHeight(), 1F / 16F);
                        GL11.glColor3f(1F, 1F, 1F);
                    }
                    renderPass++;
                } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
            }
        }
        GL11.glScalef(1F / s, 1F / s, 1F / s);

        Minecraft.getMinecraft().renderEngine.bindTexture(texture);
    }
}

From source file:vazkii.botania.client.render.tile.RenderTileIncensePlate.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float ticks) {
    TileIncensePlate plate = (TileIncensePlate) tileentity;

    int meta = plate.getWorldObj() != null ? plate.getBlockMetadata() : 0;

    GL11.glPushMatrix();/*from ww w.  j  a v a2 s  . c  om*/
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GL11.glTranslated(d0, d1, d2);
    Minecraft.getMinecraft().renderEngine.bindTexture(texture);
    GL11.glTranslatef(0.5F, 1.5F, 0.5F);
    GL11.glScalef(1F, -1F, -1F);
    GL11.glRotatef(ROTATIONS[Math.max(Math.min(ROTATIONS.length, meta - 2), 0)], 0F, 1F, 0F);
    model.render();
    GL11.glScalef(1F, -1F, -1F);

    ItemStack stack = plate.getStackInSlot(0);
    if (stack != null) {
        GL11.glPushMatrix();
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
        float s = 0.4F;
        GL11.glTranslatef(0.1F, -1.46F, 0F);
        GL11.glScalef(s, s, s);
        GL11.glRotatef(180F, 0F, 1F, 0F);

        int renderPass = 0;
        do {
            IIcon 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.getIconWidth(),
                        icon.getIconHeight(), 1F / 32F);
                GL11.glColor3f(1F, 1F, 1F);
            }
            renderPass++;
        } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
        GL11.glPopMatrix();
    }
    GL11.glColor3f(1F, 1F, 1F);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:vazkii.botania.client.render.tile.RenderTileRuneAltar.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partticks) {
    TileRuneAltar altar = (TileRuneAltar) tileentity;

    GL11.glPushMatrix();/* w  w  w  . j a  va2s.co m*/
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GL11.glTranslated(x, y, z);

    int items = 0;
    for (int i = 0; i < altar.getSizeInventory(); i++)
        if (altar.getStackInSlot(i) == null)
            break;
        else
            items++;
    float[] angles = new float[altar.getSizeInventory()];

    float anglePer = 360F / items;
    float totalAngle = 0F;
    for (int i = 0; i < angles.length; i++)
        angles[i] = totalAngle += anglePer;

    double time = ClientTickHandler.ticksInGame + partticks;

    for (int i = 0; i < altar.getSizeInventory(); i++) {
        GL11.glPushMatrix();
        GL11.glScalef(0.5F, 0.5F, 0.5F);
        GL11.glTranslatef(1F, 2.5F, 1F);
        GL11.glRotatef(angles[i] + (float) time, 0F, 1F, 0F);
        GL11.glTranslatef(2.25F, 0F, 0.5F);
        GL11.glRotatef(90F, 0F, 1F, 0F);
        GL11.glTranslated(0D, 0.15 * Math.sin((time + i * 10) / 5D), 0F);
        ItemStack stack = altar.getStackInSlot(i);
        Minecraft mc = Minecraft.getMinecraft();
        if (stack != null) {
            mc.renderEngine.bindTexture(stack.getItem() instanceof ItemBlock ? TextureMap.locationBlocksTexture
                    : TextureMap.locationItemsTexture);

            GL11.glScalef(2F, 2F, 2F);
            if (!ForgeHooksClient.renderEntityItem(
                    new EntityItem(altar.getWorldObj(), altar.xCoord, altar.yCoord, altar.zCoord, stack), stack,
                    0F, 0F, altar.getWorldObj().rand, mc.renderEngine, renderBlocks, 1)) {
                GL11.glScalef(0.5F, 0.5F, 0.5F);
                if (stack.getItem() instanceof ItemBlock && RenderBlocks
                        .renderItemIn3d(Block.getBlockFromItem(stack.getItem()).getRenderType())) {
                    GL11.glScalef(0.5F, 0.5F, 0.5F);
                    GL11.glTranslatef(1F, 1.1F, 0F);
                    renderBlocks.renderBlockAsItem(Block.getBlockFromItem(stack.getItem()),
                            stack.getItemDamage(), 1F);
                    GL11.glTranslatef(-1F, -1.1F, 0F);
                    GL11.glScalef(2F, 2F, 2F);
                } else {
                    int renderPass = 0;
                    do {
                        IIcon 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.getIconWidth(), icon.getIconHeight(), 1F / 16F);
                            GL11.glColor3f(1F, 1F, 1F);
                        }
                        renderPass++;
                    } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
                }
            }
        }
        GL11.glPopMatrix();
    }

    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glPushMatrix();
    GL11.glTranslatef(0.5F, 1.8F, 0.5F);
    GL11.glRotatef(180F, 1F, 0F, 1F);
    int repeat = 15;
    cubes.renderSpinningCubes(2, repeat, repeat);
    GL11.glPopMatrix();

    GL11.glTranslatef(0F, 0.2F, 0F);
    float scale = altar.getTargetMana() == 0 ? 0
            : (float) altar.getCurrentMana() / (float) altar.getTargetMana() / 75F;

    if (scale != 0) {
        int seed = altar.xCoord ^ altar.yCoord ^ altar.zCoord;
        GL11.glTranslatef(0.5F, 0.7F, 0.5F);
        RenderHelper.renderStar(0x00E4D7, scale, scale, scale, seed);
    }
    GL11.glEnable(GL11.GL_ALPHA_TEST);

    GL11.glPopMatrix();
}

From source file:vazkii.botania.client.render.tile.RenderTileSparkChanger.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float pticks) {
    GL11.glPushMatrix();//from www . j ava 2s  .  co m
    GL11.glTranslated(d0, d1, d2);
    GL11.glRotated(90F, 1F, 0F, 0F);
    GL11.glTranslatef(0.8F, 0.2F, -0.22F);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    ItemStack stack = ((TileSparkChanger) tileentity).getStackInSlot(0);
    if (stack != null) {
        GL11.glPushMatrix();
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
        float s = 0.6F;
        GL11.glScalef(s, s, s);
        GL11.glRotatef(180F, 0F, 1F, 0F);

        int renderPass = 0;
        do {
            IIcon 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.getIconWidth(),
                        icon.getIconHeight(), 1F / 16F);
                GL11.glColor3f(1F, 1F, 1F);
            }
            renderPass++;
        } while (renderPass < stack.getItem().getRenderPasses(stack.getItemDamage()));
        GL11.glPopMatrix();
    }
    GL11.glColor4f(1F, 1F, 1F, 1F);
    GL11.glPopMatrix();
}

From source file:vazkii.botania.common.item.equipment.bauble.ItemBloodPendant.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)//from  w w w .j a va 2s .  c  o  m
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
    if (type == RenderType.BODY) {
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
        Helper.rotateIfSneaking(player);
        boolean armor = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST) != null;
        GlStateManager.rotate(180F, 1F, 0F, 0F);
        GlStateManager.translate(-0.26F, -0.4F, armor ? 0.2F : 0.15F);
        GlStateManager.scale(0.5F, 0.5F, 0.5F);

        for (TextureAtlasSprite icon : new TextureAtlasSprite[] { MiscellaneousIcons.INSTANCE.bloodPendantChain,
                MiscellaneousIcons.INSTANCE.bloodPendantGem }) {
            float f = icon.getMinU();
            float f1 = icon.getMaxU();
            float f2 = icon.getMinV();
            float f3 = icon.getMaxV();
            IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(),
                    icon.getIconHeight(), 1F / 32F);

            Color color = new Color(Minecraft.getMinecraft().getItemColors().getColorFromItemstack(stack, 1));
            GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
            int light = 15728880;
            int lightmapX = light % 65536;
            int lightmapY = light / 65536;
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY);
        }
        GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
    }
}

From source file:vazkii.priscemagica.client.core.helper.RenderHelper.java

License:Creative Commons License

public static void renderIcon(int x, int y, Icon icon, int color) {
    GL11.glColor3ub((byte) ((color >> 16) & 255), (byte) ((color >> 8) & 255), (byte) (color & 255));
    itemRenderer.renderIcon(x, y, icon, 16, 16);
    GL11.glColor3f(1F, 1F, 1F);/*from  w w w  .ja va  2 s  .  com*/
}