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:com.builtbroken.icbm.content.blast.entity.slime.RenderSlimeRain.java

/**
 * Queries whether should render the specified pass or not.
 *///from w  w w  . j  a v a2s .c o  m
protected int shouldRenderPass(EntitySlimeRain p_77032_1_, int p_77032_2_, float p_77032_3_) {
    if (p_77032_1_.isInvisible()) {
        return 0;
    } else if (p_77032_2_ == 0) {
        this.setRenderPassModel(this.scaleAmount);
        GL11.glEnable(GL11.GL_NORMALIZE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        return 1;
    } else {
        if (p_77032_2_ == 1) {
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        }

        return -1;
    }
}

From source file:com.builtbroken.mc.framework.access.global.gui.frame.group.GuiSubFrameGroup.java

@Override
protected void doRender(Minecraft mc, int mouseX, int mouseY) {
    super.doRender(mc, mouseX, mouseY);
    AccessGroup group = getGroup();/*  w w w  .j  a  v a 2  s.  c  o m*/
    if (group != null) {
        doRender(mc, group, mouseX, mouseY);
    } else {
        drawCenteredString(mc.fontRenderer, "Error: could not load group", x() + (getWidth() / 2),
                y() + (getHeight() / 2), Color.red.getRGB());
    }

    //Reset color
    GL11.glColor4f(1f, 1f, 1f, 1f);
}

From source file:com.builtbroken.mc.prefab.gui.buttons.GuiImageButton.java

@Override
protected void doRender(Minecraft mc, int mouseX, int mouseY) {
    if (!isEnabled()) {
        GL11.glColor4f(0.2f, 0.2f, 0.2f, 1f);
    }/* w  w  w . j a v a2s .  c  o  m*/
    this.drawTexturedModalRect(this.xPosition, this.yPosition, u + getURenderModifier(),
            v + getVRenderModifier(), this.getWidth(), this.getHeight());
    GL11.glColor4f(1f, 1f, 1f, 1f);
}

From source file:com.builtbroken.mc.prefab.gui.buttons.GuiLeftRightArrowButton.java

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
    if (this.visible) {
        mc.getTextureManager().bindTexture(SharedAssets.GUI_COMPONENTS);

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

        this.field_146123_n = mouseX >= this.x() && mouseY >= this.y() && mouseX < this.x() + this.getWidth()
                && mouseY < this.y() + this.getHeight();

        GL11.glEnable(GL11.GL_BLEND);/*from   w w w .j  av a2  s.  co  m*/
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        this.drawTexturedModalRect(this.x(), this.y(), 18 + (!left ? 18 : 0), 216 + (field_146123_n ? 9 : 0),
                15, 9);
        this.mouseDragged(mc, mouseX, mouseY);
    }
}

From source file:com.builtbroken.mc.prefab.gui.components.GuiComponent.java

@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
    update(mc, mouseX, mouseY);/*from   w  w w  . j  a v a2 s. c o m*/
    if (visible()) {
        //Reset color to default
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        preRender(mc, mouseX, mouseY);
        render(mc, mouseX, mouseY);
        postRender(mc, mouseX, mouseY);
        this.mouseDragged(mc, mouseX, mouseY);

        //Reset color
        GL11.glColor4f(1f, 1f, 1f, 1f);
    }
}

From source file:com.builtbroken.mc.prefab.gui.components.GuiComponent.java

/**
 * Render call logic, seperated from update logic
 *
 * @param mc// w  ww .j  av  a  2 s  .c o  m
 * @param mouseX
 * @param mouseY
 */
protected void render(Minecraft mc, int mouseX, int mouseY) {
    //Reset color
    GL11.glColor4f(1f, 1f, 1f, 1f);

    //Draw background
    mc.getTextureManager()
            .bindTexture(getTexture() != null ? getTexture() : SharedAssets.GREY_TEXTURE_40pAlpha);
    drawBackground(mc, mouseX, mouseY);

    //Debug render code
    if (enableDebug) {
        GL11.glColor4f(1, 1, 1, 1);
        this.drawCenteredString(mc.fontRenderer, "" + id, this.x() + (getWidth() / 2),
                this.y() + (getHeight() / 2),
                this instanceof GuiComponentContainer ? Color.red.getRGB() : Color.blue.getRGB());

        if (!(this instanceof GuiButton2)) {
            mc.getTextureManager().bindTexture(SharedAssets.GREY_TEXTURE);

            Color color = Color.RED;
            if (this instanceof GuiComponentContainer) {
                color = Color.blue;
            }
            GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f,
                    color.getAlpha() / 255f);
            this.drawTexturedModalRect(x(), y(), getU(), getV(), getWidth(), 2);
            this.drawTexturedModalRect(x(), y() + getHeight() - 2, getU(), getV(), getWidth(), 2);

            this.drawTexturedModalRect(x(), y(), getU(), getV(), 2, getHeight());
            this.drawTexturedModalRect(x() + getWidth() - 2, y(), getU(), getV(), 2, getHeight());

            color = Color.GREEN;
            GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f,
                    color.getAlpha() / 255f);
            this.drawTexturedModalRect(x(), y(), getU(), getV(), 2, 2);

            color = Color.black;
            GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f,
                    color.getAlpha() / 255f);
            this.drawTexturedModalRect(x() + getWidth() - 2, y(), getU(), getV(), 2, 2);
            this.drawTexturedModalRect(x() + getWidth() - 2, y() + getHeight() - 2, getU(), getV(), 2, 2);
            this.drawTexturedModalRect(x(), y() + getHeight() - 2, getU(), getV(), 2, 2);
        }
    }

    //Main render code
    GL11.glColor4f(1, 1, 1, 1);
    mc.getTextureManager()
            .bindTexture(getTexture() != null ? getTexture() : SharedAssets.GREY_TEXTURE_40pAlpha);
    doRender(mc, mouseX, mouseY);

    //Reset color
    GL11.glColor4f(1f, 1f, 1f, 1f);
}

From source file:com.builtbroken.mc.prefab.gui.components.GuiComponent.java

/**
 * Background render method//  w  w  w .j  a va  2 s  .co  m
 *
 * @param mc
 * @param mouseX
 * @param mouseY
 */
protected void drawBackground(Minecraft mc, int mouseX, int mouseY) {
    //Set color
    Color color = getBackgroundColor();
    if (color != null) {
        GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f,
                color.getAlpha() / 255f);
    } else {
        //Reset color
        GL11.glColor4f(1f, 1f, 1f, 1f);
    }

    //Draw
    this.drawTexturedModalRect(this.x(), this.y(), getU(), getV(), this.getWidth(), this.getHeight());

    //Reset color
    GL11.glColor4f(1f, 1f, 1f, 1f);
}

From source file:com.builtbroken.mc.prefab.gui.components.GuiComponentContainer.java

@Override
protected void doRender(Minecraft mc, int mouseX, int mouseY) {
    super.doRender(mc, mouseX, mouseY);
    for (GuiComponent component : getComponents()) {
        //Reset color
        GL11.glColor4f(1f, 1f, 1f, 1f);

        GL11.glPushMatrix();/*from  w w w  .  j  av a 2  s.  c  o m*/
        component.drawButton(mc, mouseX, mouseY);
        GL11.glPopMatrix();
    }

    //Reset color
    GL11.glColor4f(1f, 1f, 1f, 1f);
}

From source file:com.builtbroken.mc.prefab.gui.components.GuiScrollBar.java

@Override
protected void drawBackground(Minecraft mc, int mouseX, int mouseY) {
    //Render background for scroll bar
    Color color = new Color(144, 144, 144);
    GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getGreen() / 255f, 1.0F);
    Render2DHelper.renderWithRepeatVertical(xPosition, yPosition + barWidth, barU, barV, barWidth, barHeight,
            getTopHeight(), getBotHeight(), middleHeight);

    if (maxScroll > 0) {
        //Calculate slider render size
        int maxScroll = this.maxScroll + 1;
        float heightP = Math.min(1f, 1f / (float) maxScroll);
        int barHeight = (int) (heightP * totalSize);

        //Calculate slider render position
        float barPercent = (float) (getCurrentScroll() + 1) / (float) maxScroll;
        int sliderRenderY = Math.max((int) (barPercent * this.totalSize) - barHeight + yPosition, yPosition);

        //Set color to red and render scroll bar
        color = new Color(119, 119, 119);
        GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getGreen() / 255f, 1.0F);

        //Render slider
        Render2DHelper.renderWithRepeatVertical(xPosition + 1, sliderRenderY + GuiButton9px.SIZE, sbarU, sbarV,
                sbarWidth, sbarHeight, 4, 4, barHeight - 8);
    }/* ww w  . ja v  a2 s. com*/
}

From source file:com.CiD.MysteryMod.TecEvolution.Buildcraft.FluidRenderer.java

License:Minecraft Mod Public

public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing) {
    if (fluidStack == null) {
        return null;
    }//from w  w w .j  av  a2  s.  co  m
    Fluid fluid = fluidStack.getFluid();
    if (fluid == null) {
        return null;
    }
    Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
    int[] diplayLists = cache.get(fluid);
    if (diplayLists != null) {
        return diplayLists;
    }

    diplayLists = new int[DISPLAY_STAGES];

    if (fluid.getBlock() != null) {
        liquidBlock.baseBlock = fluid.getBlock();
        liquidBlock.texture = getFluidTexture(fluidStack, flowing);
    } else {
        liquidBlock.baseBlock = Blocks.water;
        liquidBlock.texture = getFluidTexture(fluidStack, flowing);
    }

    cache.put(fluid, diplayLists);

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);

    for (int s = 0; s < DISPLAY_STAGES; ++s) {
        diplayLists[s] = GLAllocation.generateDisplayLists(1);
        GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/);

        liquidBlock.minX = 0f;
        liquidBlock.minY = 0;
        liquidBlock.minZ = 0;

        liquidBlock.maxX = 1f;
        liquidBlock.maxY = (float) s / (float) DISPLAY_STAGES;
        liquidBlock.maxZ = 1;

        RenderEntityBlock.INSTANCE.renderBlock(liquidBlock);

        GL11.glEndList();
    }

    GL11.glColor4f(1, 1, 1, 1);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);

    return diplayLists;
}