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:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java

License:Apache License

public final void glAlphaFunc(int func, float ref) {
    GL11.glAlphaFunc(func, ref);
}

From source file:com.colonycraft.rendering.world.ChunkMeshRenderer.java

License:Apache License

public static void renderChunkMesh(World world, Chunk chunk, int meshType) {
    /* Bind the correct texture */
    GL11.glEnable(GL11.GL_TEXTURE_2D);//  w  w w . j a  va  2s.  c o  m
    TextureStorage.getTexture("terrain").bind();

    if (meshType == ChunkMesh.MESH_OPAQUE) {
        GL11.glDisable(GL11.GL_BLEND);
    } else if (meshType == ChunkMesh.MESH_TRANSLUCENT || meshType == ChunkMesh.MESH_GRASS) {
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f);
    }

    ChunkMesh cmesh = chunk.getMesh();
    Mesh mesh = cmesh.getMesh(meshType);
    if (mesh == null)
        return;

    /* Bind the buffer */
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, mesh.getVertexBufferHandle());

    /* Enable the different kinds of data in the buffer */
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    if (meshType == ChunkMesh.MESH_GRASS) {
        GL20.glEnableVertexAttribArray(GRASS_ATTRIBUTE_LIGHT);
    } else {
        GL20.glEnableVertexAttribArray(CHUNK_ATTRIBUTE_LIGHT);
    }

    /* Define the starting positions */
    GL11.glVertexPointer(POSITION_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, POSITION_OFFSET * FLOAT_SIZE);
    GL11.glTexCoordPointer(TEX_COORD_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, TEX_COORD_OFFSET * FLOAT_SIZE);
    GL20.glVertexAttribPointer(CHUNK_ATTRIBUTE_LIGHT, 2, GL11.GL_FLOAT, false, STRIDE * FLOAT_SIZE,
            LIGHT_OFFSET * FLOAT_SIZE);

    /* Draw the buffer */
    GL11.glDrawArrays(GL11.GL_QUADS, 0, mesh.vertices());

    /* Unbind the buffer */
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    /* Disable the different kinds of data */
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    if (meshType == ChunkMesh.MESH_GRASS) {
        GL20.glDisableVertexAttribArray(GRASS_ATTRIBUTE_LIGHT);
    } else {
        GL20.glDisableVertexAttribArray(CHUNK_ATTRIBUTE_LIGHT);
    }

    if (meshType == ChunkMesh.MESH_TRANSLUCENT || meshType == ChunkMesh.MESH_GRASS) {
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }
}

From source file:com.kegare.frozenland.client.renderer.FrozenlandWheatherRenderer.java

License:Minecraft Mod Public

@Override
public void render(float ticks, WorldClient world, Minecraft mc) {
    ++rendererUpdateCount;/*from   w w  w.  j a  v a 2 s .  co  m*/

    float rainStrength = mc.theWorld.getRainStrength(ticks);

    if (rainStrength > 0.0F) {
        mc.entityRenderer.enableLightmap(ticks);

        if (rainXCoords == null) {
            rainXCoords = new float[1024];
            rainYCoords = new float[1024];

            for (int i = 0; i < 32; ++i) {
                for (int j = 0; j < 32; ++j) {
                    float f1 = j - 16;
                    float f2 = i - 16;
                    float f3 = MathHelper.sqrt_float(f1 * f1 + f2 * f2);

                    rainXCoords[i << 5 | j] = -f2 / f3;
                    rainYCoords[i << 5 | j] = f1 / f3;
                }
            }
        }

        EntityLivingBase entity = mc.renderViewEntity;
        int x = MathHelper.floor_double(entity.posX);
        int y = MathHelper.floor_double(entity.posY);
        int z = MathHelper.floor_double(entity.posZ);
        Tessellator tessellator = Tessellator.instance;
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glNormal3f(0.0F, 1.0F, 0.0F);
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * ticks;
        double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * ticks;
        double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * ticks;
        int i = MathHelper.floor_double(d1);
        byte range = 5;

        if (mc.gameSettings.fancyGraphics) {
            range = 10;
        }

        byte b1 = -1;
        float f1 = rendererUpdateCount + ticks;

        if (mc.gameSettings.fancyGraphics) {
            range = 10;
        }

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

        for (int j = z - range; j <= z + range; ++j) {
            for (int k = x - range; k <= x + range; ++k) {
                int index = (j - z + 16) * 32 + k - x + 16;
                float f2 = rainXCoords[index] * 0.5F;
                float f3 = rainYCoords[index] * 0.5F;
                int height = world.getPrecipitationHeight(k, j);
                int cloud = MathHelper.floor_float(world.provider.getCloudHeight());
                int l = MathHelper.clamp_int(y - range, height, cloud);
                int m = MathHelper.clamp_int(y + range, height, cloud);

                if (l == cloud || m == cloud) {
                    continue;
                }

                float f4 = 1.35F;
                int n = height;

                if (height < i) {
                    n = i;
                }

                if (l != m) {
                    random.setSeed(k * k * 3121 + k * 45238971 ^ j * j * 418711 + j * 13761);

                    if (b1 != 1) {
                        if (b1 >= 0) {
                            tessellator.draw();
                        }

                        b1 = 1;
                        mc.getTextureManager().bindTexture(locationSnowPng);
                        tessellator.startDrawingQuads();
                    }

                    float f5 = ((rendererUpdateCount & 0x1FF) + ticks) / 512.0F;
                    float f6 = random.nextFloat() + f1 * 0.01F * (float) random.nextGaussian();
                    float f7 = random.nextFloat() + f1 * (float) random.nextGaussian() * 0.001F;
                    double xDist = k + 0.5F - entity.posX;
                    double zDist = j + 0.5F - entity.posZ;
                    float f8 = MathHelper.sqrt_double(xDist * xDist + zDist * zDist) / range;
                    tessellator.setBrightness(
                            (world.getLightBrightnessForSkyBlocks(k, n, j, 0) * 3 + 15728880) / 4);
                    tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F,
                            ((1.0F - f8 * f8) * 0.3F + 0.5F) * rainStrength);
                    tessellator.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D);
                    tessellator.addVertexWithUV(k - f2 + 0.5D, l, j - f3 + 0.5D, 0.0F * f4 + f6,
                            l * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.addVertexWithUV(k + f2 + 0.5D, l, j + f3 + 0.5D, 1.0F * f4 + f6,
                            l * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.addVertexWithUV(k + f2 + 0.5D, m, j + f3 + 0.5D, 1.0F * f4 + f6,
                            m * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.addVertexWithUV(k - f2 + 0.5D, m, j - f3 + 0.5D, 0.0F * f4 + f6,
                            m * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.setTranslation(0.0D, 0.0D, 0.0D);
                }
            }
        }

        if (b1 >= 0) {
            tessellator.draw();
        }

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);

        mc.entityRenderer.disableLightmap(ticks);
    }
}

From source file:com.mrcrayfish.furniture.render.tileentity.BlenderRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityBlender blender = (TileEntityBlender) tileEntity;
    ItemStack[] ingredients = blender.getIngredients();

    GL11.glPushMatrix();/* www  .  j a va  2  s.c  om*/
    GL11.glTranslatef((float) posX + 0.5F, (float) posY + 0.2F, (float) posZ + 0.5F);
    GL11.glScalef(0.65F, 0.65F, 0.65F);
    entityFood.hoverStart = 0.0F;
    for (int i = 0; i < ingredients.length; i++) {
        if (ingredients[i] != null) {
            entityFood.setEntityItemStack(ingredients[i]);
            GL11.glRotatef(i * -90F, 0, 1, 0);
            GL11.glRotatef(blender.progress * 18F, 0, 1, 0);
            Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entityFood, 0.0D, 0.2D, 0.0D,
                    0.0F, 0.0F);
        }
    }
    GL11.glPopMatrix();

    if (blender.isBlending() | blender.drinkCount > 0) {
        Tessellator tessellator = Tessellator.getInstance();
        GL11.glPushMatrix();
        GL11.glTranslatef((float) posX + 0.5F, (float) posY + 0.05F, (float) posZ + 0.5F);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);

        float alpha = blender.isBlending() ? (blender.progress / 200F) : (blender.drinkCount > 0 ? 1.0F : 0.0F);
        GL11.glColor4f(blender.currentRed / 255F, blender.currentGreen / 255F, blender.currentBlue / 255F,
                alpha);

        float height = blender.isBlending() ? 0.8F : (0.275F + (0.525F * (blender.drinkCount / 6F)));
        GL11.glBegin(GL11.GL_QUADS);

        // North Face
        GL11.glVertex3d(-0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, height, -0.2);
        GL11.glVertex3d(-0.2, height, -0.2);

        // South Face
        GL11.glVertex3d(-0.2, 0.275, 0.2);
        GL11.glVertex3d(0.2, 0.275, 0.2);
        GL11.glVertex3d(0.2, height, 0.2);
        GL11.glVertex3d(-0.2, height, 0.2);

        // West Face
        GL11.glVertex3d(-0.2, 0.275, -0.2);
        GL11.glVertex3d(-0.2, 0.275, 0.2);
        GL11.glVertex3d(-0.2, height, 0.2);
        GL11.glVertex3d(-0.2, height, -0.2);

        // East Face
        GL11.glVertex3d(0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, 0.2);
        GL11.glVertex3d(0.2, height, 0.2);
        GL11.glVertex3d(0.2, height, -0.2);

        // Top Face
        GL11.glVertex3d(-0.2, height, -0.2);
        GL11.glVertex3d(0.2, height, -0.2);
        GL11.glVertex3d(0.2, height, 0.2);
        GL11.glVertex3d(-0.2, height, 0.2);

        // Bottom Face
        GL11.glVertex3d(-0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, 0.2);
        GL11.glVertex3d(-0.2, 0.275, 0.2);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);

        GL11.glPopMatrix();
    }
}

From source file:com.mrcrayfish.furniture.render.tileentity.CupRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityCup tileEntityCup = (TileEntityCup) tileEntity;
    if (tileEntityCup.getDrink() != null) {
        Tessellator tessellator = Tessellator.getInstance();
        GL11.glPushMatrix();/* w  ww . j  av a  2  s. c  o  m*/
        GL11.glTranslatef((float) posX + 0.5F, (float) posY, (float) posZ + 0.5F);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);

        GL11.glColor4f(tileEntityCup.red / 255F, tileEntityCup.green / 255F, tileEntityCup.blue / 255F, 1.0F);

        GL11.glBegin(GL11.GL_QUADS);

        // North Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.4, -0.125);
        GL11.glVertex3d(-0.125, 0.4, -0.125);

        // South Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(0.125, 0.4, 0.125);
        GL11.glVertex3d(-0.125, 0.4, 0.125);

        // West Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(-0.125, 0.4, 0.125);
        GL11.glVertex3d(-0.125, 0.4, -0.125);

        // East Face
        GL11.glVertex3d(0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(0.125, 0.4, 0.125);
        GL11.glVertex3d(0.125, 0.4, -0.125);

        // Top Face
        GL11.glVertex3d(-0.125, 0.4, -0.125);
        GL11.glVertex3d(0.125, 0.4, -0.125);
        GL11.glVertex3d(0.125, 0.4, 0.125);
        GL11.glVertex3d(-0.125, 0.4, 0.125);

        // Bottom Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, 0.125);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);

        GL11.glPopMatrix();
    }
}

From source file:com.n8lm.zener.nifty.NiftyGUISystem.java

License:Open Source License

@Override
protected void processSystem() {

    glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight());

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();/*from   w  w w  .j a va  2  s  . c  o  m*/
    GL11.glOrtho(0, game.getContainer().getWidth(), game.getContainer().getHeight(), 0, -9999, 9999);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    glPushAttrib(GL_ENABLE_BIT);

    GL11.glDisable(GL11.GL_DEPTH_TEST);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_NOTEQUAL, 0);

    GL11.glDisable(GL11.GL_LIGHTING);

    // Back to GL Texture 0 Unit
    glActiveTexture(GL_TEXTURE0);
    glEnable(GL_TEXTURE_2D);
    //glBindTexture();

    nifty.update();
    nifty.render(false);

    glPopAttrib();

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
}

From source file:com.shinoow.abyssalcraft.client.render.entity.RenderDragonBoss.java

License:Apache License

/**
 * Renders the dragon model. Called by renderModel.
 *//*from   w ww.  j  a v  a 2 s .co  m*/
protected void renderDragonModel(EntityDragonBoss par1EntityDragonBoss, float par2, float par3, float par4,
        float par5, float par6, float par7) {
    if (par1EntityDragonBoss.deathTicks > 0) {
        float f6 = par1EntityDragonBoss.deathTicks / 200.0F;
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, f6);
        bindTexture(field_110842_f);
        mainModel.render(par1EntityDragonBoss, par2, par3, par4, par5, par6, par7);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDepthFunc(GL11.GL_EQUAL);
    }

    bindEntityTexture(par1EntityDragonBoss);
    mainModel.render(par1EntityDragonBoss, par2, par3, par4, par5, par6, par7);

    if (par1EntityDragonBoss.hurtTime > 0) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f(1.0F, 0.0F, 0.0F, 0.5F);
        mainModel.render(par1EntityDragonBoss, par2, par3, par4, par5, par6, par7);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
    }
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

public InspectorCanvas(Composite parent, int style, GLData data) {
    super(parent, style, data);
    setCurrent();/*  ww w . ja  v a  2s  .  com*/

    // Clear the canvas.
    GL11.glClearColor(CLEAR_COLOR[0], CLEAR_COLOR[1], CLEAR_COLOR[2], CLEAR_COLOR[3]);
    GL11.glClearDepth(1.0f);
    GL11.glLineWidth(1.0f);
    GL11.glPointSize(1.0f);

    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

    GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
    GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST);

    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);

    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.01f);

    GL11.glEnable(GL11.GL_STENCIL_TEST);
    GL11.glStencilFunc(GL11.GL_ALWAYS, 0x1, 0xf);
    GL11.glStencilOp(GL11.GL_INCR, GL11.GL_KEEP, GL11.GL_INCR);

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

    reset();

    mTransform = new Matrix4f();
    mTransform.setIdentity();

    addListener(SWT.Resize, this);
    addListener(SWT.Paint, this);
    addMouseListener(this);
    addMouseWheelListener(this);
}

From source file:de.mineformers.robots.client.renderer.tileentity.TileFactoryControllerRenderer.java

License:LGPL

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTicks) {
    if (((TileFactoryController) tileentity).isValidMultiblock()) {
        GL11.glPushMatrix();/*w  w w .  ja  v  a  2  s.co m*/
        int i = 15728880;

        int j = i % 65536;
        int k = i / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j / 1.0F, (float) k / 1.0F);
        GL11.glTranslated(x + 0.5F, y + 0.65F, z + 0.5f);
        switch (((TileFactoryController) tileentity).getOrientation()) {
        case WEST:
            GL11.glRotatef(90, 0, 1, 0);
            break;
        case EAST:
            GL11.glRotatef(-90, 0, 1, 0);
            break;
        case SOUTH:
            GL11.glRotatef(180, 0, 1, 0);
            break;
        }
        GL11.glTranslatef(0, 0, -0.47F);
        GL11.glScalef(0.3F, 0.3F, 0.3F);
        GL11.glRotatef(180, 1, 0, 0);
        GL11.glRotatef(180, 0, 1, 0);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glColor4f(255F, 255F, 255F, 255F);
        this.bindTexture(robotTexture);
        robot.justRender();
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glPopMatrix();
    }
}

From source file:de.sanandrew.core.manpack.util.client.helpers.ItemRenderHelper.java

License:Creative Commons License

/**
 * Renders an IIcon instance in 3D.//from  w w  w  .  j a  v a  2 s .c om
 *
 * @param icon     the icon to be rendered
 * @param isBlock  if it should be rendered as a block or not
 * @param hasAlpha if it has a transparent texture
 * @param color    the tint it should be rendered in
 */
public static void renderIconIn3D(IIcon icon, boolean isBlock, boolean hasAlpha, int color) {
    GL11.glPushMatrix();

    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    if (isBlock) {
        Minecraft.getMinecraft().renderEngine
                .bindTexture(Minecraft.getMinecraft().renderEngine.getResourceLocation(0));
        if (hasAlpha) {
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
            GL11.glEnable(GL11.GL_BLEND);
            OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        }

        GL11.glTranslatef(0.5F, 0.5F, 0.0F);
        GL11.glScalef(0.5F, 0.5F, 0.5F);

        GL11.glPushMatrix();

        Tessellator tessellator = Tessellator.instance;

        float red = (color >> 16 & 255) / 255.0F;
        float green = (color >> 8 & 255) / 255.0F;
        float blue = (color & 255) / 255.0F;
        GL11.glColor4f(red, green, blue, 1.0F);

        Blocks.stone.setBlockBoundsForItemRender();
        renderBlocksRi.setRenderBoundsFromBlock(Blocks.stone);
        GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

        tessellator.startDrawingQuads();
        tessellator.setNormal(0.0F, -1.0F, 0.0F);
        renderBlocksRi.renderFaceYNeg(Blocks.stone, 0.0D, 0.0D, 0.0D, icon);
        tessellator.draw();
        tessellator.startDrawingQuads();
        tessellator.setNormal(0.0F, 1.0F, 0.0F);
        renderBlocksRi.renderFaceYPos(Blocks.stone, 0.0D, 0.0D, 0.0D, icon);
        tessellator.draw();
        tessellator.startDrawingQuads();
        tessellator.setNormal(0.0F, 0.0F, -1.0F);
        renderBlocksRi.renderFaceZNeg(Blocks.stone, 0.0D, 0.0D, 0.0D, icon);
        tessellator.draw();
        tessellator.startDrawingQuads();
        tessellator.setNormal(0.0F, 0.0F, 1.0F);
        renderBlocksRi.renderFaceZPos(Blocks.stone, 0.0D, 0.0D, 0.0D, icon);
        tessellator.draw();
        tessellator.startDrawingQuads();
        tessellator.setNormal(-1.0F, 0.0F, 0.0F);
        renderBlocksRi.renderFaceXNeg(Blocks.stone, 0.0D, 0.0D, 0.0D, icon);
        tessellator.draw();
        tessellator.startDrawingQuads();
        tessellator.setNormal(1.0F, 0.0F, 0.0F);
        renderBlocksRi.renderFaceXPos(Blocks.stone, 0.0D, 0.0D, 0.0D, icon);
        tessellator.draw();

        GL11.glPopMatrix();

        if (hasAlpha) {
            GL11.glDisable(GL11.GL_BLEND);
        }
    } else {
        if (hasAlpha) {
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
            GL11.glEnable(GL11.GL_BLEND);
            OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        }

        float red = (color >> 16 & 255) / 255.0F;
        float green = (color >> 8 & 255) / 255.0F;
        float blue = (color & 255) / 255.0F;
        GL11.glColor4f(red, green, blue, 1.0F);
        renderItemIn3D(icon, false, 1);

        if (hasAlpha) {
            GL11.glDisable(GL11.GL_BLEND);
        }
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
    TextureUtil.func_147945_b();
}