Example usage for org.lwjgl.opengl GL11 glBlendFunc

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

Introduction

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

Prototype

public static void glBlendFunc(@NativeType("GLenum") int sfactor, @NativeType("GLenum") int dfactor) 

Source Link

Document

Specifies the weighting factors used by the blend equation, for both RGB and alpha functions and for all draw buffers.

Usage

From source file:com.bluepowermod.client.render.RenderLamp.java

License:Open Source License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    GL11.glPushMatrix();/*from  w  w w. ja  va2 s.c om*/
    {
        switch (type) {
        case ENTITY:
            GL11.glTranslated(-0.5, -0.5, -0.5);
            break;
        case EQUIPPED:
            break;
        case EQUIPPED_FIRST_PERSON:
            GL11.glTranslated(0, -0.1, 0);
            break;
        case INVENTORY:
            GL11.glTranslated(0, -0.1, 0);
            break;
        default:
            break;
        }

        BlockLamp block = (BlockLamp) Block.getBlockFromItem(item.getItem());
        int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
        int r = (block.getColor() & redMask) >> 16;
        int g = (block.getColor() & greenMask) >> 8;
        int b = (block.getColor() & blueMask);

        Vec3dCube cube = new Vec3dCube(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);

        Tessellator t = Tessellator.instance;
        t.startDrawingQuads();
        t.setColorOpaque(r, g, b);

        RenderHelper h = RenderHelper.instance;
        h.reset();
        h.setColor(block.getColor());
        h.renderBox(cube, block.isInverted() ? BlockLamp.on : BlockLamp.off);
        h.reset();

        t.draw();
        if (block.isInverted()) {
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
            // GL11.glAlphaFunc(GL11.GL_EQUAL, (power / 15F) * 1F);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_LIGHTING);
            // GL11.glDisable(GL11.GL_CULL_FACE);
            GL11.glDepthMask(false);
            GL11.glBegin(GL11.GL_QUADS);
            com.bluepowermod.client.render.RenderHelper.drawColoredCube(cube.clone().expand(0.8 / 16D),
                    r / 256D, g / 256D, b / 256D, 0.625D);
            GL11.glEnd();
            GL11.glDepthMask(true);
            GL11.glEnable(GL11.GL_CULL_FACE);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            // GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
            GL11.glDisable(GL11.GL_BLEND);
        }
    }
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.client.render.RenderPartItem.java

License:Open Source License

private void render(float x, float y, float z, float scale, ItemRenderType type, ItemStack item,
        Object... data) {//w w w .  j a  v  a  2  s . co  m

    boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
    boolean alpha = GL11.glGetBoolean(GL11.GL_ALPHA_TEST);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_ALPHA_TEST);

    GL11.glPushMatrix();
    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(x, y, z);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
    try {
        BPPart part = PartManager.getExample(item);
        part.renderItem(type, item, data);
    } catch (Exception ex) {
    }
    GL11.glPopMatrix();

    if (!blend)
        GL11.glDisable(GL11.GL_BLEND);
    if (!alpha)
        GL11.glDisable(GL11.GL_ALPHA_TEST);
}

From source file:com.bluepowermod.part.lamp.PartCageLamp.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)/*w  w  w.j a v  a2  s . co  m*/
public void renderGlow(int pass) {

    Vec3dCube vector = new Vec3dCube(5 / 16D, 2 / 16D, 5 / 16D, 11 / 16D, 11 / 16D, 11 / 16D).rotate(getFace(),
            Vec3d.center);

    double r = ((color.getHex() & 0xFF0000) >> 16) / 256D;
    double g = ((color.getHex() & 0x00FF00) >> 8) / 256D;
    double b = (color.getHex() & 0x0000FF) / 256D;

    if (pass == 1) {
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBegin(GL11.GL_QUADS);
        com.bluepowermod.client.render.RenderHelper.drawColoredCube(vector.clone().expand(0.5 / 16D), r, g, b,
                ((inverted ? 255 - (power & 0xFF) : (power & 0xFF)) / 255D) * 0.625);
        GL11.glEnd();
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glDisable(GL11.GL_BLEND);
    }

}

From source file:com.bluepowermod.part.lamp.PartFixture.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)//from w w  w. ja  v a  2 s.  c o  m
public void renderGlow(int pass) {

    Vec3dCube vector = new Vec3dCube(3 / 16D, 2 / 16D, 3 / 16D, 1.0 - (3 / 16D), 8 / 16D, 13 / 16D)
            .rotate(getFace(), Vec3d.center);

    double r = ((color.getHex() & 0xFF0000) >> 16) / 256D;
    double g = ((color.getHex() & 0x00FF00) >> 8) / 256D;
    double b = (color.getHex() & 0x0000FF) / 256D;
    if (pass == 1) {
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBegin(GL11.GL_QUADS);
        com.bluepowermod.client.render.RenderHelper.drawColoredCube(vector.clone().expand(0.5 / 16D), r, g, b,
                ((inverted ? 255 - (power & 0xFF) : (power & 0xFF)) / 255D) * 0.625);
        GL11.glEnd();
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glDisable(GL11.GL_BLEND);
    }
}

From source file:com.builtbroken.atomic.content.items.cell.RendererItemCell.java

protected void renderFluid(ItemRenderType type, ItemStack item) {
    final FluidStack fluidStack = ((ItemFluidCell) item.getItem()).getFluid(item);
    if (fluidStack != null) {
        final Fluid fluid = fluidStack.getFluid();

        if (fluid != null) {
            final IIcon maskIcon = ASItems.itemFluidCell.getIconFromDamage(-1);
            final IIcon subIcon = fluid.getFlowingIcon() != null ? fluid.getFlowingIcon() : fluid.getIcon();

            if (maskIcon != null && subIcon != null) {
                GL11.glEnable(GL11.GL_BLEND);
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                GL11.glDisable(GL11.GL_CULL_FACE);
                Tessellator tessellator = Tessellator.instance;

                //Render mask TODO change mask verts to show fill %
                bindItemTexture(item.getItem());
                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, 1);
                generatedGeometry(maskIcon, type, 10, 0.001);
                tessellator.draw();//from  w w  w. j  av  a 2  s  . c o m

                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, -1); //TODO don't think is needed for inventory
                generatedGeometry(maskIcon, type, -0.0635, -0.0635);
                tessellator.draw();

                //Render fluid
                bindFluidTexture(fluid);

                GL11.glDepthFunc(GL11.GL_EQUAL);
                GL11.glDepthMask(false);

                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, 1);
                generatedGeometry(subIcon, type, 10, 0.001);
                tessellator.draw();

                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, -1); //TODO don't think is needed for inventory
                generatedGeometry(subIcon, type, -0.0635, -0.0635);
                tessellator.draw();

                GL11.glDisable(GL11.GL_BLEND);
                GL11.glDepthMask(true);
                GL11.glDepthFunc(GL11.GL_LEQUAL);
                GL11.glEnable(GL11.GL_CULL_FACE);
                GL11.glColor4f(1, 1, 1, 1);
            }
        }
    }
}

From source file:com.builtbroken.icbm.content.blast.entity.slime.RenderSlimeRain.java

/**
 * Queries whether should render the specified pass or not.
 *///from ww w. j  a v  a2 s  . co 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.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  www.  j  a  va 2s .c  om
        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.damagedearth.Utilities.Components.TrueTypeFont.java

License:Open Source License

public void drawString(float x, float y, String whatchars, int startIndex, int endIndex, float scaleX,
        float scaleY, int format) {

    IntObject intObject = null;/*from w w  w. j  a va2 s. co m*/
    int charCurrent;

    int totalwidth = 0;
    int i = startIndex, d, c;
    float startY = 0;

    switch (format) {
    case ALIGN_RIGHT: {
        d = -1;
        c = correctR;

        while (i < endIndex) {
            if (whatchars.charAt(i) == '\n')
                startY -= fontHeight;
            i++;
        }
        break;
    }
    case ALIGN_CENTER: {
        for (int l = startIndex; l <= endIndex; l++) {
            charCurrent = whatchars.charAt(l);
            if (charCurrent == '\n')
                break;
            if (charCurrent < 256) {
                intObject = charArray[charCurrent];
            } else {
                intObject = (IntObject) customChars.get(new Character((char) charCurrent));
            }
            totalwidth += intObject.width - correctL;
        }
        totalwidth /= -2;
    }
    case ALIGN_LEFT:
    default: {
        d = 1;
        c = correctL;
        break;
    }

    }

    GL11.glEnable(GL11.GL_BLEND); // Enabled blending
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); // selects blending method
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, fontTextureID);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glBegin(GL11.GL_QUADS);

    while (i >= startIndex && i <= endIndex) {

        charCurrent = whatchars.charAt(i);
        if (charCurrent < 256) {
            intObject = charArray[charCurrent];
        } else {
            intObject = (IntObject) customChars.get(new Character((char) charCurrent));
        }

        if (intObject != null) {
            if (d < 0)
                totalwidth += (intObject.width - c) * d;
            if (charCurrent == '\n') {
                startY -= fontHeight * d;
                totalwidth = 0;
                if (format == ALIGN_CENTER) {
                    for (int l = i + 1; l <= endIndex; l++) {
                        charCurrent = whatchars.charAt(l);
                        if (charCurrent == '\n')
                            break;
                        if (charCurrent < 256) {
                            intObject = charArray[charCurrent];
                        } else {
                            intObject = (IntObject) customChars.get(new Character((char) charCurrent));
                        }
                        totalwidth += intObject.width - correctL;
                    }
                    totalwidth /= -2;
                }
                //if center get next lines total width/2;
            } else {
                drawQuad((totalwidth + intObject.width) * scaleX + x, startY * scaleY + y,
                        totalwidth * scaleX + x, (startY + intObject.height) * scaleY + y,
                        intObject.storedX + intObject.width, intObject.storedY + intObject.height,
                        intObject.storedX, intObject.storedY);
                if (d > 0)
                    totalwidth += (intObject.width - c) * d;
            }
            i += d;

        }
    }
    GL11.glEnd();

    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

/**
 * Renders a box with any size and any color.
 *
 * @param x//from   w  ww. ja  v a  2  s . com
 * @param y
 * @param z
 * @param x2
 * @param y2
 * @param z2
 * @param color
 */
public static void box(double x, double y, double z, double x2, double y2, double z2, float red, float green,
        float blue, float alpha) {
    x = x - Minecraft.getMinecraft().getRenderManager().renderPosX;
    y = y - Minecraft.getMinecraft().getRenderManager().renderPosY;
    z = z - Minecraft.getMinecraft().getRenderManager().renderPosZ;
    x2 = x2 - Minecraft.getMinecraft().getRenderManager().renderPosX;
    y2 = y2 - Minecraft.getMinecraft().getRenderManager().renderPosY;
    z2 = z2 - Minecraft.getMinecraft().getRenderManager().renderPosZ;
    GL11.glBlendFunc(770, 771);
    GL11.glEnable(GL_BLEND);
    GL11.glLineWidth(2.0F);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glDepthMask(false);
    GL11.glColor4f(red, green, blue, alpha);
    drawColorBox(new AxisAlignedBB(x, y, z, x2, y2, z2), red, green, blue, alpha);
    GL11.glColor4d(0, 0, 0, 0.5F);
    drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x2, y2, z2));
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDisable(GL_BLEND);
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

/**
 * Renders a frame with any size and any color.
 *
 * @param x/*from  w w  w. j  av  a2  s. c o m*/
 * @param y
 * @param z
 * @param x2
 * @param y2
 * @param z2
 * @param color
 */
public static void frame(double x, double y, double z, double x2, double y2, double z2, Color color) {
    x = x - Minecraft.getMinecraft().getRenderManager().renderPosX;
    y = y - Minecraft.getMinecraft().getRenderManager().renderPosY;
    z = z - Minecraft.getMinecraft().getRenderManager().renderPosZ;
    x2 = x2 - Minecraft.getMinecraft().getRenderManager().renderPosX;
    y2 = y2 - Minecraft.getMinecraft().getRenderManager().renderPosY;
    z2 = z2 - Minecraft.getMinecraft().getRenderManager().renderPosZ;
    GL11.glBlendFunc(770, 771);
    GL11.glEnable(GL_BLEND);
    GL11.glLineWidth(2.0F);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    setColor(color);
    drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x2, y2, z2));
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDisable(GL_BLEND);
}