Example usage for org.lwjgl.opengl GL11 glAlphaFunc

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

Introduction

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

Prototype

public static native void glAlphaFunc(@NativeType("GLenum") int func, @NativeType("GLfloat") float ref);

Source Link

Document

The alpha test discards a fragment conditionally based on the outcome of a comparison between the incoming fragment’s alpha value and a constant value.

Usage

From source file:appeng.client.render.BusRenderer.java

License:Open Source License

@Override
public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) {
    if (item == null) {
        return;//from  ww  w  . j  av  a  2s . co m
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_LIGHTING);

    if (AEConfig.instance.isFeatureEnabled(AEFeature.AlphaPass) && item.getItem() instanceof IAlphaPassItem
            && ((IAlphaPassItem) item.getItem()).useAlphaPass(item)) {
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_BLEND);
    } else {
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.4f);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glDisable(GL11.GL_BLEND);
    }

    if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
        GL11.glTranslatef(-0.2f, -0.1f, -0.3f);
    }

    if (type == ItemRenderType.ENTITY) {
        GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
        GL11.glScalef(0.8f, 0.8f, 0.8f);
        GL11.glTranslatef(-0.8f, -0.87f, -0.7f);
    }

    if (type == ItemRenderType.INVENTORY) {
        GL11.glTranslatef(0.0f, -0.1f, 0.0f);
    }

    GL11.glTranslated(0.2, 0.3, 0.1);
    GL11.glScaled(1.2, 1.2, 1.);

    GL11.glColor4f(1, 1, 1, 1);
    Tessellator.instance.setColorOpaque_F(1, 1, 1);
    Tessellator.instance.setBrightness(14 << 20 | 14 << 4);

    BusRenderHelper.INSTANCE.setBounds(0, 0, 0, 1, 1, 1);
    BusRenderHelper.INSTANCE.setTexture(null);
    BusRenderHelper.INSTANCE.setInvColor(0xffffff);
    this.getRenderer().blockAccess = ClientHelper.proxy.getWorld();

    BusRenderHelper.INSTANCE.setOrientation(ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH);

    this.getRenderer().uvRotateBottom = this.getRenderer().uvRotateEast = this
            .getRenderer().uvRotateNorth = this.getRenderer().uvRotateSouth = this
                    .getRenderer().uvRotateTop = this.getRenderer().uvRotateWest = 0;
    this.getRenderer().useInventoryTint = false;
    this.getRenderer().overrideBlockTexture = null;

    if (item.getItem() instanceof IFacadeItem) {
        final IFacadeItem fi = (IFacadeItem) item.getItem();
        final IFacadePart fp = fi.createPartFromItemStack(item, ForgeDirection.SOUTH);

        if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
            GL11.glRotatef(160.0f, 0.0f, 1.0f, 0.0f);
            GL11.glTranslated(-0.4, 0.1, -1.6);
        }

        if (fp != null) {
            fp.renderInventory(BusRenderHelper.INSTANCE, this.getRenderer());
        }
    } else {
        final IPart ip = this.getRenderer(item, (IPartItem) item.getItem());
        if (ip != null) {
            if (type == ItemRenderType.ENTITY) {
                final int depth = ip.cableConnectionRenderTo();
                GL11.glTranslatef(0.0f, 0.0f, -0.04f * (8 - depth) - 0.06f);
            }

            ip.renderInventory(BusRenderHelper.INSTANCE, this.getRenderer());
        }
    }

    this.getRenderer().uvRotateBottom = this.getRenderer().uvRotateEast = this
            .getRenderer().uvRotateNorth = this.getRenderer().uvRotateSouth = this
                    .getRenderer().uvRotateTop = this.getRenderer().uvRotateWest = 0;

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

From source file:buildcraft.transport.render.FacadeItemRenderer.java

License:Minecraft Mod Public

private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY,
        float translateZ) {
    if (lastTime < System.currentTimeMillis()) {
        renderState = !renderState;//from  ww  w .ja  v a  2s.  c om
        lastTime = System.currentTimeMillis() + 1000L;
    }

    Block block = null;
    int decodedMeta = 0;

    int type = ItemFacade.getType(item);
    Block[] blocks = ItemFacade.getBlocks(item);
    int[] metas = ItemFacade.getMetaValues(item);
    if (blocks == null || blocks.length == 0 || metas == null || metas.length != blocks.length) {
        return;
    }

    if (type == ItemFacade.TYPE_BASIC || (type == ItemFacade.TYPE_PHASED && renderState)) {
        block = blocks[0];
        decodedMeta = metas[0];
    } else if (type == ItemFacade.TYPE_PHASED && blocks.length >= 2) {
        block = blocks[1];
        decodedMeta = metas[1];
    }

    try {
        int color = item.getItem().getColorFromItemStack(new ItemStack(block, 1, decodedMeta), 0);
        RenderUtils.setGLColorFromInt(color);
    } catch (Throwable error) {
    }

    Tessellator tessellator = Tessellator.instance;

    if (block == null) {
        return;
    }

    if (tryGetBlockIcon(block, 0, decodedMeta) == null) {
        return;
    }

    // Render Facade
    GL11.glPushMatrix();

    // Enable glBlending for transparency
    if (block.getRenderBlockPass() > 0) {
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    }

    block.setBlockBounds(0F, 0F, 1F - 1F / 16F, 1F, 1F, 1F);
    render.setRenderBoundsFromBlock(block);
    GL11.glTranslatef(translateX, translateY, translateZ);
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1F, 0.0F);
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 0, decodedMeta));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 1, decodedMeta));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 2, decodedMeta));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 3, decodedMeta));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 4, decodedMeta));
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, tryGetBlockIcon(block, 5, decodedMeta));
    tessellator.draw();
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

    // Disable blending
    if (block.getRenderBlockPass() > 0) {
        GL11.glDisable(GL11.GL_BLEND);
    }

    GL11.glPopMatrix();

    // Render StructurePipe
    block = BuildCraftTransport.genericPipeBlock;
    IIcon textureID = BuildCraftTransport.instance.pipeIconProvider
            .getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe

    block.setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS,
            CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS - 1F / 16F);
    block.setBlockBoundsForItemRender();
    render.setRenderBoundsFromBlock(block);
    GL11.glTranslatef(translateX, translateY, translateZ + 0.25F);

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -0F, 0.0F);
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, textureID);
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}

From source file:cn.academy.ability.electro.client.render.skill.RailgunPlaneEffect.java

License:Open Source License

@SideOnly(Side.CLIENT)
@Override//ww w. j av a 2  s . co  m
public void renderHandEffect(EntityPlayer player, HandRenderType type, long dt) {
    if (type == HandRenderType.EQUIPPED)
        return;
    if (dt < DELAY)
        return;
    dt -= DELAY;

    double tz = dt * dt / 3e4;
    double TRANS_TIME = ANIM_LEN * 0.2;
    double alpha = (dt < TRANS_TIME ? dt / TRANS_TIME
            : (dt > ANIM_LEN - TRANS_TIME ? (ANIM_LEN - dt) / TRANS_TIME : 1));

    //Draw a screen-filling blackout
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluOrtho2D(0, 255, 0, 255);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glDepthMask(false);
    GL11.glLoadIdentity();
    {
        GL11.glTranslated(0, 0, 0);
        GL11.glColor4d(0, 0, 0, 0.2 * alpha);
        HudUtils.setZLevel(1);
        HudUtils.drawModalRect(0, 0, 255, 255);
        HudUtils.setZLevel(-90);
    }
    GL11.glDepthMask(true);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_MODELVIEW); //Restore the matrix

    //Draw the real effect

    GL11.glColor4d(1, 1, 1, alpha * 0.6);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f);
    GL11.glPushMatrix();
    {
        GL11.glTranslated(-.4, 0.85 + tz * 0.37, tz);
        GL11.glRotated(-20.4, 1, 0, 0);

        drawSingleSide(7);

        //         GL11.glPushMatrix(); {
        //            GL11.glTranslated(-2.3, 0, 0);
        //            drawSingleSide(7);
        //         } GL11.glPopMatrix();
    }
    GL11.glPopMatrix();

    GL11.glDisable(GL11.GL_ALPHA_TEST);
}

From source file:cn.academy.vanilla.generic.client.render.RippleMarkRender.java

License:GNU General Public License

@Override
public void doRender(Entity entity, double x, double y, double z, float a, float b) {
    EntityRippleMark mark = (EntityRippleMark) entity;
    long dt = GameTimer.getTime() - mark.creationTime;

    GL11.glDisable(GL11.GL_CULL_FACE);//from w  w  w.  j  av  a 2s .co m
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0);
    GL11.glDepthMask(false);
    GL11.glPushMatrix();

    GL11.glTranslated(x, y, z);

    for (int i = 0; i < timeOffsets.length; ++i) {
        GL11.glPushMatrix();

        long mod = (dt - timeOffsets[i]) % CYCLE;
        float size = getSize(mod);

        GL11.glTranslatef(0, getHeight(mod), 0);
        GL11.glScalef(size, 1, size);
        material.color = mark.color.copy();
        material.color.a *= getAlpha(mod);
        mesh.draw(material);

        GL11.glPopMatrix();
    }

    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.1f);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}

From source file:cn.academy.vanilla.meltdowner.client.render.RenderMdShield.java

License:GNU General Public License

@Override
public void doRender(Entity _entity, double x, double y, double z, float a, float b) {
    if (RenderUtils.isInShadowPass()) {
        return;// w  w  w.  jav a 2s .  c  o m
    }

    long time = GameTimer.getTime();
    EntityMdShield entity = (EntityMdShield) _entity;

    // Calculate rotation
    long dt;
    if (entity.lastRender == 0)
        dt = 0;
    else
        dt = time - entity.lastRender;

    float rotationSpeed = MathUtils.lerpf(0.8f, 2f, Math.min(entity.ticksExisted / 30.0f, 1f));
    entity.rotation += rotationSpeed * dt;
    if (entity.rotation >= 360f)
        entity.rotation -= 360f;

    ShaderSimple.instance().useProgram();
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.05f);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();

    GL11.glTranslated(x, y, z);
    GL11.glRotatef(-entity.rotationYaw, 0, 1, 0);
    GL11.glRotatef(entity.rotationPitch, 1, 0, 0);
    GL11.glRotatef(entity.rotation, 0, 0, 1);

    float size = EntityMdShield.SIZE * MathUtils.lerpf(0.2f, 1f, Math.min(entity.ticksExisted / 15.0f, 1f));
    float alpha = Math.min(entity.ticksExisted / 6.0f, 1.0f);

    GL11.glScalef(size, size, 1);

    RenderUtils.loadTexture(texture);
    mesh.draw(ShaderSimple.instance());

    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.1f);
    GL20.glUseProgram(0);

    entity.lastRender = time;
}

From source file:cn.lambdalib.particle.RenderParticle.java

License:MIT License

@Override
public void doRender(Entity ent, double x, double y, double z, float a, float b) {
    if (RenderUtils.isInShadowPass())
        return;/* www .ja  v a2 s  .c o  m*/

    Particle ish = (Particle) ent;
    if (!ish.updated)
        return;

    ish.updateSprite(sprite);

    GL11.glAlphaFunc(GL11.GL_GREATER, 0.05f);
    GL11.glPushMatrix();

    if (ish.needViewOptimize()) {
        GL11.glTranslated(0, -0.2, 0);
    }

    GL11.glTranslated(x, y, z);
    if (ish.customRotation) {
        GL11.glRotatef(ish.rotationYaw, 0, 1, 0);
        GL11.glRotatef(ish.rotationPitch, 0, 0, 1);
    } else {
        GL11.glRotatef(180F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    }

    sprite.draw();

    GL11.glPopMatrix();
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.1f);
}

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

License:MIT License

@Override
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
    GL11.glEnable(GL11.GL_BLEND);/*from www  . ja  v  a2 s  .co m*/
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glDisable(GL11.GL_CULL_FACE);
    if (!hasLight)
        GL11.glDisable(GL11.GL_LIGHTING);
    //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glAlphaFunc(GL11.GL_GREATER, minTolerateAlpha);
    GL11.glPushMatrix();
    {
        GL11.glTranslatef((float) par2, (float) par4, (float) par6);
        GL11.glScalef(size, size, size);
        postTranslate(par1Entity);
        if (icon != null)
            RenderUtils.loadTexture(icon);

        Tessellator t = Tessellator.instance;
        this.func_77026_a(par1Entity, t);

    }
    GL11.glPopMatrix();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:com.a2client.corex.Render.java

License:Open Source License

static public void setAlphaTest(int v) {
    if (alpha_test != v) {
        alpha_test = v;/*from w  w  w .  ja v  a2  s  .c om*/
        if (v > 0) {
            GL11.glEnable(GL11.GL_ALPHA_TEST);
            GL11.glAlphaFunc(GL11.GL_GREATER, (float) v / 255);
        } else {
            GL11.glDisable(GL11.GL_ALPHA_TEST);
        }
    }
}

From source file:com.ardor3d.scene.state.lwjgl.LwjglBlendStateUtil.java

License:Open Source License

protected static void applyTest(final boolean enabled, final BlendState state, final BlendStateRecord record) {
    if (record.isValid()) {
        if (enabled) {
            if (!record.testEnabled) {
                GL11.glEnable(GL11.GL_ALPHA_TEST);
                record.testEnabled = true;
            }/*from   w  w w. ja  v a 2  s.c  o m*/
            final int glFunc = getGLFuncValue(state.getTestFunction());
            if (record.alphaFunc != glFunc || record.alphaRef != state.getReference()) {
                GL11.glAlphaFunc(glFunc, state.getReference());
                record.alphaFunc = glFunc;
                record.alphaRef = state.getReference();
            }
        } else if (record.testEnabled) {
            GL11.glDisable(GL11.GL_ALPHA_TEST);
            record.testEnabled = false;
        }

    } else {
        if (enabled) {
            GL11.glEnable(GL11.GL_ALPHA_TEST);
            record.testEnabled = true;
            final int glFunc = getGLFuncValue(state.getTestFunction());
            GL11.glAlphaFunc(glFunc, state.getReference());
            record.alphaFunc = glFunc;
            record.alphaRef = state.getReference();
        } else {
            GL11.glDisable(GL11.GL_ALPHA_TEST);
            record.testEnabled = false;
        }
    }
}

From source file:com.auroraengine.opengl.GLWindow.java

License:Open Source License

/**
 * Currently serves as a simple test for implementing some GL settings.
 *
 * @throws GLException/*from  ww  w. j  a v  a2 s  .  c o  m*/
 */
public static void updateGL() throws GLException {
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.5f);
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}