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:cn.lambdacraft.terrain.client.renderer.RenderItemPortal.java

License:Open Source License

private void renderInventory(ItemStack is, RenderBlocks render) {
    GL11.glEnable(GL11.GL_BLEND);//from   w w w.jav a2  s.  c  o m
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR);
    RenderUtils.renderItemInventory(is);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:cn.lambdacraft.terrain.client.renderer.RenderTileXenAmethyst.java

License:Open Source License

/**
 * Render the Amethyst ray/*from  w  w  w  .  jav  a2 s  .c o  m*/
 * @param ent
 * @param t
 * @param x
 * @param y
 * @param z
 */
private void renderRay(TileEntityXenAmethyst ent, Tessellator t, double x, double y, double z) {
    double dx = ent.lastxCoord, dy = ent.lastyCoord, dz = ent.lastzCoord;
    //       double tx = 0.0, ty = 0.4, tz = 0.0;
    double tx = 0.5, ty = 0.2, tz = 0.5;
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.loadTexture(ClientProps.VORTIGAUNT_RAY_PATH[rng.nextInt(3)]);

    Vec3 v1 = RenderUtils.newV3(tx - WIDTH, ty, tz), v2 = RenderUtils.newV3(tx + WIDTH, ty, tz),
            v3 = RenderUtils.newV3(tx, ty - WIDTH, tz), v4 = RenderUtils.newV3(tx, ty + WIDTH, tz);
    double d = Math.sqrt(dx * dx + dy * dy + dz * dz) * 1.3;

    GL11.glTranslated(x, y, z);

    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
    t.startDrawingQuads();
    t.setBrightness(15728880);
    t.setColorRGBA_F(0.663F, 0.263F, 1.0F, 0.65F);
    RenderUtils.addVertex(v1, 0, 0);
    RenderUtils.addVertex(v2, 1, 0);
    RenderUtils.addVertex(v2.addVector(dx, dy, dz), 1, d);
    RenderUtils.addVertex(v1.addVector(dx, dy, dz), 0, d);

    RenderUtils.addVertex(v3, 0, 0);
    RenderUtils.addVertex(v4, 1, 0);
    RenderUtils.addVertex(v4.addVector(dx, dy, dz), 1, d);
    RenderUtils.addVertex(v3.addVector(dx, dy, dz), 0, d);
    t.draw();

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

}

From source file:cn.lambdalib.cgui.gui.CGui.java

License:MIT License

/**
 * Go down the hierarchy tree and draw each widget node. Should be called each rendering frame.
 *///w w w .  j a  v a2s.  c  o m
public void draw(double mx, double my) {
    frameUpdate();
    updateMouse(mx, my);

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

    drawTraverse(mx, my, null, this, getTopWidget(mx, my));

    if (debug) {
        Widget hovering = getHoveringWidget();
        if (hovering != null) {
            GL11.glColor4f(1, .5f, .5f, .8f);
            HudUtils.drawRectOutline(hovering.x, hovering.y, hovering.transform.width * hovering.scale,
                    hovering.transform.height * hovering.scale, 3);
            IFont font = TrueTypeFont.defaultFont();
            font.draw(hovering.getFullName(), hovering.x, hovering.y - 10, new FontOption(10));
        }

    }

    GL11.glEnable(GL11.GL_ALPHA_TEST);
}

From source file:cn.lambdalib.cgui.gui.CGuiScreenContainer.java

License:MIT License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
    GL11.glEnable(GL11.GL_BLEND);/*from  ww  w  .  j  a  v  a 2 s  .c  om*/
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    gui.resize(width, height);
    gui.draw(var2, var3);
}

From source file:cn.lambdalib.template.client.render.entity.RenderCrossedProjectile.java

License:MIT License

@Override
public void doRender(Entity entity, double par2, double par4, double par6, float par8, float par9) {
    Motion3D motion = new Motion3D(entity);
    Tessellator t = Tessellator.instance;

    GL11.glPushMatrix();/*  ww  w  .  j  ava2 s .co  m*/
    {
        Vec3 v1 = newV3(0, HEIGHT, 0), v2 = newV3(0, -HEIGHT, 0), v3 = newV3(LENGTH, -HEIGHT, 0),
                v4 = newV3(LENGTH, HEIGHT, 0), v5 = newV3(0, 0, -HEIGHT), v6 = newV3(0, 0, HEIGHT),
                v7 = newV3(LENGTH, 0, HEIGHT), v8 = newV3(LENGTH, 0, -HEIGHT);

        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        if (renderTexture) {
            bindTexture(TEXTURE_PATH);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glColor3f(colorR, colorG, colorB);
        }
        if (ignoreLight) {
            GL11.glDisable(GL11.GL_LIGHTING);
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
        }

        GL11.glTranslatef((float) par2, (float) par4, (float) par6);

        GL11.glRotatef(90 + entity.rotationYaw, 0.0F, -1.0F, 0.0F); // ?
        GL11.glRotatef(-entity.rotationPitch, 0.0F, 0.0F, 1.0F); // 

        if (this.playerViewOptm) {
            boolean firstPerson = Minecraft.getMinecraft().gameSettings.thirdPersonView == 0;
            if (firstPerson) {
                GL11.glTranslated(fpOffsetX, fpOffsetY, fpOffsetZ);
            } else {
                GL11.glTranslated(tpOffsetX, tpOffsetY, tpOffsetZ);
            }
        }

        t.startDrawingQuads();
        if (ignoreLight)
            t.setBrightness(15728880);

        RenderUtils.addVertex(v1, 0, 0);
        RenderUtils.addVertex(v2, 0, 1);
        RenderUtils.addVertex(v3, 1, 1);
        RenderUtils.addVertex(v4, 1, 0);

        RenderUtils.addVertex(v5, 0, 0);
        RenderUtils.addVertex(v6, 0, 1);
        RenderUtils.addVertex(v7, 1, 1);
        RenderUtils.addVertex(v8, 1, 0);

        t.draw();

        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
    }
    GL11.glPopMatrix();
}

From source file:cn.lambdalib.template.client.render.item.RenderModelItem.java

License:MIT License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glEnable(GL11.GL_BLEND);/*from  w ww .j  a v  a  2 s.  c o  m*/
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    switch (type) {
    case EQUIPPED:
    case EQUIPPED_FIRST_PERSON:
        renderEquipped(item, (RenderBlocks) data[0], (EntityLivingBase) data[1], type);
        break;
    case ENTITY:
        renderEntityItem((RenderBlocks) data[0], (EntityItem) data[1]);
        break;
    case INVENTORY:
        renderInventory();
        break;
    default:
        break;

    }
}

From source file:cn.lambdalib.util.client.auxgui.AuxGuiHandler.java

License:MIT License

@SubscribeEvent
public void drawHudEvent(RenderGameOverlayEvent event) {
    GL11.glDepthFunc(GL11.GL_ALWAYS);/*from   www  . j a va  2  s  .  co  m*/
    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.pushTextureState();

    if (event.type == ElementType.EXPERIENCE) {
        Iterator<AuxGui> iter = auxGuiList.iterator();
        startIterating();
        while (iter.hasNext()) {
            AuxGui gui = iter.next();
            if (!gui.isDisposed()) {
                if (!gui.lastFrameActive)
                    gui.lastActivateTime = GameTimer.getTime();
                gui.draw(event.resolution);
                gui.lastFrameActive = true;
            }
        }
        endIterating();
    }

    RenderUtils.popTextureState();
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.lambdalib.util.client.HudUtils.java

License:MIT License

public static void drawGradientRect(int x0, int y0, int x1, int y1, int color1, int color2) {
    float f = (color1 >> 24 & 255) / 255.0F;
    float f1 = (color1 >> 16 & 255) / 255.0F;
    float f2 = (color1 >> 8 & 255) / 255.0F;
    float f3 = (color1 & 255) / 255.0F;
    float f4 = (color2 >> 24 & 255) / 255.0F;
    float f5 = (color2 >> 16 & 255) / 255.0F;
    float f6 = (color2 >> 8 & 255) / 255.0F;
    float f7 = (color2 & 255) / 255.0F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);//w  w w  . j  a  v  a 2s .  co  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 t = Tessellator.instance;
    t.startDrawingQuads();
    t.setColorRGBA_F(f1, f2, f3, f);
    t.addVertex(x1, y0, -90D);
    t.addVertex(x0, y0, -90D);
    t.setColorRGBA_F(f5, f6, f7, f4);
    t.addVertex(x0, y1, -90D);
    t.addVertex(x1, y1, -90D);
    t.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:cn.lambdalib.util.client.RenderUtils.java

License:MIT License

public static void renderOverlayEquip(ResourceLocation src) {
    //Setup/* w  w  w  .  ja v a 2s. c o m*/
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    //Push texture mat
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    float f9 = GameTimer.getAbsTime() % 3000L / 3000.0F * 8.0F;
    GL11.glTranslatef(f9, 0.0F, 0.0F); //xOffset loops between 0.0 and 8.0
    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();

    //Second pass
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    f9 = GameTimer.getAbsTime() % 4873L / 4873.0F * 8.0F; //Loop between 0 and 8, longer loop
    GL11.glTranslatef(-f9, 0.0F, 0.0F); //Still xOffset
    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); //However, different rotation!
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();
    //Pop texture mat
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.lambdalib.util.client.RenderUtils.java

License:MIT License

public static void renderOverlayInv(ResourceLocation src) {
    GL11.glDepthFunc(GL11.GL_EQUAL);/*  ww w  .  j av a2 s  .co m*/
    GL11.glDisable(GL11.GL_LIGHTING);
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    //GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    float f9 = GameTimer.getAbsTime() % 3000L / 3000.0F * 8.0F;
    GL11.glTranslatef(f9, 0.0F, 0.0F);
    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glPopMatrix();
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    f9 = GameTimer.getAbsTime() % 4873L / 4873.0F * 8.0F;
    GL11.glTranslatef(-f9, 0.0F, 0.0F);
    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}