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.professorvennie.machinerycraft.core.handlers.HudHandler.java

License:Creative Commons License

private void drawBookGUI(BookEntry entry, ScaledResolution res) {
    GL11.glEnable(GL11.GL_BLEND);/* w ww . ja  v  a2s . co  m*/
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    Minecraft mc = Minecraft.getMinecraft();
    int x = res.getScaledWidth() / 2 + 8;
    int y = res.getScaledHeight() / 2 - 4;

    int color = 0xFF5A28;

    String info = StatCollector.translateToLocal("mc.book.shiftToRead");
    int itemX = x - (mc.fontRenderer.getStringWidth(new ItemStack(ModItems.book).getDisplayName()) / 2);
    mc.fontRenderer.drawStringWithShadow(StatCollector.translateToLocal(entry.getUnlocalizedName()), itemX,
            y + 6, color);
    mc.fontRenderer.drawStringWithShadow(info, x - (mc.fontRenderer.getStringWidth(info) / 2), y + 18, color);
    itemRender.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, new ItemStack(ModItems.book), itemX - 20,
            y + 2);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glColor4f(1F, 1F, 1F, 1F);
}

From source file:com.professorvennie.machinerycraft.core.helpers.RenderHelper.java

License:Creative Commons License

public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
    float var7 = (par5 >> 24 & 255) / 255F;
    float var8 = (par5 >> 16 & 255) / 255F;
    float var9 = (par5 >> 8 & 255) / 255F;
    float var10 = (par5 & 255) / 255F;
    float var11 = (par6 >> 24 & 255) / 255F;
    float var12 = (par6 >> 16 & 255) / 255F;
    float var13 = (par6 >> 8 & 255) / 255F;
    float var14 = (par6 & 255) / 255F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*  ww  w. java 2  s  .  c  o m*/
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator var15 = Tessellator.instance;
    var15.startDrawingQuads();
    var15.setColorRGBA_F(var8, var9, var10, var7);
    var15.addVertex(par3, par2, z);
    var15.addVertex(par1, par2, z);
    var15.setColorRGBA_F(var12, var13, var14, var11);
    var15.addVertex(par1, par4, z);
    var15.addVertex(par3, par4, z);
    var15.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:com.projectzed.mod.renderer.FluidTankRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {

    GL11.glTranslated(x, y, z);//from  www.j av a2  s  . c o m
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 0xf0 % 65536, 0xf0 / 65536);

    this.bindTexture(texture);

    drawCuboid((TileEntityFluidTankBase) te, minVec, maxVec, (byte) 0);
    drawCuboid((TileEntityFluidTankBase) te, minVec, maxVec, (byte) 1);

    drawFluid((TileEntityFluidTankBase) te, fluidMinVec, fluidMaxVec);

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glTranslated(-x, -y, -z);
}

From source file:com.redthirddivision.quad.rendering.renderers.GuiRenderer.java

License:Apache License

@Override
public void render(ArrayList<GuiTexture> elements) {
    shader.start();//from   w  w  w.  j a v a  2s . c o  m

    GL30.glBindVertexArray(quad.getVaoID());
    GL20.glEnableVertexAttribArray(0);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    for (GuiTexture gui : elements) {
        GL13.glActiveTexture(GL13.GL_TEXTURE0);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, gui.getTexture());
        Matrix4f matrix = MathHelper.createTransformationMatrix(gui.getPosition(), gui.getScale(),
                new Vector2f(0, 0));
        shader.loadTransformation(matrix);
        GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, quad.getVertexCount());
    }

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);

    shader.stop();
}

From source file:com.runescape.client.revised.editor.modelviewer.Main.java

License:Open Source License

public static void initialize(final Canvas modelCanvas) {
    try {/*  w  w w. j  a v  a 2s . com*/
        Display.setParent(modelCanvas);
        Display.create(new PixelFormat(8, 24, 8, 8));
        Display.makeCurrent();
    } catch (final LWJGLException lwjgle) {
        try {
            Display.create(new PixelFormat(8, 24, 8, 0));
        } catch (final LWJGLException e) {
            e.printStackTrace();
        }
    }
    Display.setVSyncEnabled(false);
    Display.setSwapInterval(0);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glClearDepth(1.0F);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
    GL11.glEnable(GL11.GL_NORMALIZE);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_POINT_SMOOTH);
    GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_DIFFUSE);
    GL11.glCullFace(GL11.GL_BACK);
}

From source file:com.rvantwisk.cnctools.controls.opengl.OpenGLRenderer.java

License:Open Source License

protected void init() {
    GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    GL11.glClearDepth(1.0);/*from w w w.j  av  a2s  .  c  om*/
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

}

From source file:com.savoycraft.gui.TGFrame.java

License:Open Source License

/**
 * Draws a rectangle with a HORIZONTAL gradient between the specified
 * colors./*  w w w .  ja v a  2  s. c  o m*/
 * 
 * From MOJANG code
 */
protected void drawGradientRectH(int par1, int par2, int par3, int par4, int par5, int par6) {
    float f = (float) (par5 >> 24 & 255) / 255.0F;
    float f1 = (float) (par5 >> 16 & 255) / 255.0F;
    float f2 = (float) (par5 >> 8 & 255) / 255.0F;
    float f3 = (float) (par5 & 255) / 255.0F;
    float f4 = (float) (par6 >> 24 & 255) / 255.0F;
    float f5 = (float) (par6 >> 16 & 255) / 255.0F;
    float f6 = (float) (par6 >> 8 & 255) / 255.0F;
    float f7 = (float) (par6 & 255) / 255.0F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.setColorRGBA_F(f5, f6, f7, f4);
    tessellator.addVertex((double) par3, (double) par2, (double) this.zLevel);
    tessellator.setColorRGBA_F(f1, f2, f3, f);
    tessellator.addVertex((double) par1, (double) par2, (double) this.zLevel);
    tessellator.addVertex((double) par1, (double) par4, (double) this.zLevel);
    tessellator.setColorRGBA_F(f5, f6, f7, f4);
    tessellator.addVertex((double) par3, (double) par4, (double) this.zLevel);
    tessellator.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:com.shinoow.abyssalcraft.client.gui.necronomicon.buttons.ButtonCategory.java

License:Apache License

@Override
public void drawButton(Minecraft mc, int mx, int my) {
    FontRenderer fr = mc.fontRenderer;//from   ww  w. j  ava  2  s . c om
    boolean inside = mx >= xPosition && my >= yPosition && mx < xPosition + width && my < yPosition + height;
    float time = 5F;
    if (inside)
        ticksHovered = Math.min(time, ticksHovered);
    else
        ticksHovered = Math.max(0F, ticksHovered);

    ResourceLocation res = getTexture(icon);
    if (res == null)
        res = getTexture(AbyssalCraft.necronomicon);

    mc.renderEngine.bindTexture(res);

    float s = 1F / 48F;

    GL11.glPushMatrix();
    GL11.glColor4f(1F, 1F, 1F, 1);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glScalef(0.5F, 0.5F, 0.5F);
    drawTexturedModalRect(xPosition * 2, yPosition * 2, zLevel * 2, 0, 0, 48, 48, s, s);
    //      drawTexturedModalRect(xPosition, yPosition, 0, 16, 48, 48);
    GL11.glPopMatrix();
    fr.drawString(displayString, xPosition + 20, yPosition + 10, 0);
}

From source file:com.shinoow.abyssalcraft.client.render.block.RenderODB.java

License:Apache License

public void doRender(EntityODBPrimed par1EntityODBPrimed, double par2, double par4, double par6, float par8,
        float par9) {
    GL11.glPushMatrix();// w  ww.  j av a 2 s  .  co  m
    GL11.glTranslatef((float) par2, (float) par4, (float) par6);
    float var10;
    if (par1EntityODBPrimed.fuse - par9 + 1.0F < 10.0F) {
        var10 = 1.0F - (par1EntityODBPrimed.fuse - par9 + 1.0F) / 10.0F;

        if (var10 < 0.0F)
            var10 = 0.0F;
        if (var10 > 1.0F)
            var10 = 1.0F;

        var10 *= var10;
        var10 *= var10;
        float var11 = 1.0F + var10 * 0.3F;
        GL11.glScalef(var11, var11, var11);
    }

    var10 = (1.0F - (par1EntityODBPrimed.fuse - par9 + 1.0F) / 100.0F) * 0.8F;
    bindEntityTexture(par1EntityODBPrimed);
    blockRenderer.renderBlockAsItem(AbyssalCraft.ODB, 0, par1EntityODBPrimed.getBrightness(par9));

    if (par1EntityODBPrimed.fuse / 5 % 2 == 0) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, var10);
        blockRenderer.renderBlockAsItem(AbyssalCraft.ODB, 0, 1.0F);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
    GL11.glPopMatrix();
}

From source file:com.shinoow.abyssalcraft.client.render.block.RenderODBc.java

License:Apache License

public void doRender(EntityODBcPrimed par1EntityODBcPrimed, double par2, double par4, double par6, float par8,
        float par9) {

    GL11.glPushMatrix();/*from   ww w  .  java 2 s  . com*/
    GL11.glTranslatef((float) par2, (float) par4, (float) par6);
    float var10;

    if (par1EntityODBcPrimed.fuse - par9 + 1.0F < 10.0F) {
        var10 = 1.0F - (par1EntityODBcPrimed.fuse - par9 + 1.0F) / 10.0F;

        if (var10 < 0.0F)
            var10 = 0.0F;
        if (var10 > 1.0F)
            var10 = 1.0F;

        var10 *= var10;
        var10 *= var10;
        float var11 = 1.0F + var10 * 0.3F;
        GL11.glScalef(var11, var11, var11);
    }

    var10 = (1.0F - (par1EntityODBcPrimed.fuse - par9 + 1.0F) / 100.0F) * 0.8F;
    bindEntityTexture(par1EntityODBcPrimed);
    blockRenderer.renderBlockAsItem(AbyssalCraft.ODBcore, 0, par1EntityODBcPrimed.getBrightness(par9));

    if (par1EntityODBcPrimed.fuse / 5 % 2 == 0) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, var10);
        blockRenderer.renderBlockAsItem(AbyssalCraft.ODBcore, 0, 1.0F);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
    GL11.glPopMatrix();
}