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:vazkii.s_hg.client.model.ModelHourglass.java

License:Open Source License

public void render(float fract1, float fract2, boolean flip, int color) {
    if (flip) {// w w  w .j  ava2  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.model.ModelRotating.java

License:Creative Commons License

/** Renders the animated cubes around the model, called after
 * the translations for render() **/
public void renderSpinningCubes(int cubes, float hue) {
    final float modifier = 6F;
    final float rotationModifier = 0.25F;
    final float saturationModifier = 0.1F;
    final float radiusBase = 0.4F;
    final float radiusMod = 0.1F;

    long ticks = ClientTickHandler.elapsedClientTicks;
    float offsetPerCube = 360 / cubes;
    GL11.glPushMatrix();//from   w  w w . j  av a  2 s  .  com
    GL11.glTranslatef(-0.025F, 0.85F, -0.025F);
    for (int i = 0; i < cubes; i++) {
        float offset = offsetPerCube * i;
        float deg = (int) (ticks / rotationModifier % 360F + offset);
        float rad = MathHelper.degreeToRadian(deg);
        float radiusX = (float) (radiusBase + radiusMod * Math.sin(ticks / modifier));
        float radiusZ = (float) (radiusBase + radiusMod * Math.cos(ticks / modifier));
        float x = (float) (radiusX * Math.cos(rad));
        float z = (float) (radiusZ * Math.sin(rad));
        float y = (float) Math.cos((ticks + 50 * i) / 5F) / 10F;

        GL11.glPushMatrix();
        GL11.glTranslatef(x, y, z);
        float xRotate = (float) Math.sin(ticks * rotationModifier) / 2F;
        float zRotate = (float) Math.cos(ticks * rotationModifier) / 2F;

        float sat = (float) Math.max(0.6F, Math.sin(ticks * saturationModifier) / 2F + 0.5F);

        GL11.glRotatef(deg, xRotate, sat, zRotate);
        Color color = Color.getHSBColor(hue, sat, 1F);
        GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
        SpinningCube.render(MiscReference.MODEL_DEFAULT_RENDER_SCALE);

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

From source file:vazkii.tinkerer.client.render.RenderElementiumGuardian.java

License:Creative Commons License

@Override
public void renderSilverfish(EntitySilverfish par1EntitySilverfish, double par2, double par4, double par6,
        float par8, float par9) {
    Color rgbColor = new Color(Color.HSBtoRGB((float) Math.cos((double) ClientTickHandler.elapsedClientTicks
            / ResourcesReference.SPECTRUM_DIVISOR_ELEMENTIUM_GUARDIAN), 0.8F, 1F));
    // Get a color based on hue, acquired trough a cosine function on the elapsed
    // ticks, in order to create an animated spectrum effect. It's kept as an
    // instance of Color to be used in a glColor3f call.

    GL11.glPushMatrix();//from w  w  w .  ja  v  a2  s. c o  m
    GL11.glColor3ub((byte) rgbColor.getRed(), (byte) rgbColor.getGreen(), (byte) rgbColor.getBlue());
    super.renderSilverfish(par1EntitySilverfish, par2, par4, par6, par8, par9);
    GL11.glPopMatrix();
}

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();/*from w  w w.  j a v a2  s.c o m*/
    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  www .j ava 2  s.  co  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 {
            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();//  ww  w  .j ava  2  s.  c  o  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 w w.j a v  a2 s.  c  o m

        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.GuiElementalistTinkeringAltar.java

License:Creative Commons License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(ResourcesReference.GUI_ELEMENTALIST_TINKERING_ALTAR_TEXTURE);
    int xStart = (width - xSize) / 2;
    int yStart = (height - ySize) / 2;

    // Draw Arrow
    drawTexturedModalRect(xStart + 102, yStart + 123, xSize, 18, 26, 15);
    if (altar.getIsCreating()) {
        int time = altar.getProgress();
        int size = (int) Math.round(
                MathHelper.crossMuliply(TileEntityReference.ELEMENTALIST_TINKERING_ALTAR_TIME, 28, time));

        Color color = Color.getHSBColor((float) Math.cos(
                (double) ClientTickHandler.elapsedClientTicks / ResourcesReference.SPECTRUM_DIVISOR_INFUSION),
                1F, 1F);//w  w  w.  j a  va 2s  .  c o  m
        GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
        drawTexturedModalRect(xStart + 102, yStart + 123, xSize, 33, size, 15);
        GL11.glColor3f(1F, 1F, 1F);
    }

    drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);

    // Draw Missing Catalyst Capsule Icons
    if (!altar.hasCatalystCapsuleOnSide(0))
        drawTexturedModalRect(xStart + 13, yStart + 37, xSize, 0, 18, 18);
    if (!altar.hasCatalystCapsuleOnSide(1))
        drawTexturedModalRect(xStart + 145, yStart + 37, xSize, 0, 18, 18);
    if (!altar.hasCatalystCapsuleOnSide(2))
        drawTexturedModalRect(xStart + 13, yStart + 73, xSize, 0, 18, 18);
    if (!altar.hasCatalystCapsuleOnSide(3))
        drawTexturedModalRect(xStart + 145, yStart + 73, xSize, 0, 18, 18);
}