Example usage for org.lwjgl.opengl GL11 glEnable

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

Introduction

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

Prototype

public static void glEnable(@NativeType("GLenum") int target) 

Source Link

Document

Enables the specified OpenGL state.

Usage

From source file:buildcraft.robotics.gui.GuiZonePlan.java

License:Minecraft Mod Public

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    super.drawGuiContainerBackgroundLayer(f, x, y);

    if (getContainer().mapTexture.width <= WINDOWED_MAP_WIDTH) {
        mapXMin = guiLeft + 8 + ((WINDOWED_MAP_WIDTH - getContainer().mapTexture.width) / 2);
    } else {//  ww w .  ja v a  2s. c o m
        mapXMin = (width - getContainer().mapTexture.width) / 2;
    }

    if (getContainer().mapTexture.height <= WINDOWED_MAP_HEIGHT) {
        mapYMin = guiTop + 9 + ((WINDOWED_MAP_HEIGHT - getContainer().mapTexture.height) / 2);
    } else {
        mapYMin = (height - getContainer().mapTexture.height) / 2;
    }

    getContainer().mapTexture.draw(mapXMin, mapYMin, zLevel);

    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_BLEND);

    currentSelection.draw(mapXMin, mapYMin, zLevel);

    GL11.glPopAttrib();
    GL11.glDisable(GL11.GL_BLEND);

    newSelection.updateTexture();

    if (inSelection && selX2 != 0) {
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_BLEND);

        int x1 = selX1 < selX2 ? selX1 : selX2;
        int x2 = selX1 < selX2 ? selX2 : selX1;
        int y1 = selY1 < selY2 ? selY1 : selY2;
        int y2 = selY1 < selY2 ? selY2 : selY1;

        drawTexturedModalRect(x1, y1, 0, 0, x2 - x1 + 1, y2 - y1 + 1);
        GL11.glPopAttrib();
        GL11.glDisable(GL11.GL_BLEND);
    }

    if (!isFullscreen()) {
        drawBackgroundSlots(x, y);

        bindTexture(texture);

        GL11.glEnable(GL11.GL_ALPHA_TEST);
        drawTexturedModalRect(guiLeft + colorSelected.x, guiTop + colorSelected.y, 0, 228, 16, 16);
        drawTexturedModalRect(guiLeft + 236, guiTop + 27, 16, 228, 8,
                (int) ((zonePlan.progress / (float) TileZonePlan.CRAFT_TIME) * 27));
    }
}

From source file:buildcraft.robotics.render.RenderRobot.java

License:Minecraft Mod Public

private void doRenderRobot(float factor, TextureManager texManager, float storagePercent, boolean isAsleep) {
    box.render(factor);//w w  w.  ja  v  a2s  . co m

    if (!isAsleep) {
        float lastBrightnessX = OpenGlHelper.lastBrightnessX;
        float lastBrightnessY = OpenGlHelper.lastBrightnessY;

        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);

        GL11.glColor4f(1.0F, 1.0F, 1.0F, storagePercent);
        texManager.bindTexture(overlay_red);
        box.render(factor);

        GL11.glDisable(GL11.GL_BLEND);

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        texManager.bindTexture(overlay_cyan);
        box.render(factor);

        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopMatrix();

        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY);
    }

}

From source file:buildcraft.robots.render.RenderRobot.java

License:Minecraft Mod Public

private void doRenderRobot(float factor, TextureManager texManager) {
    box.render(factor);/*from  www .  ja  v  a2  s.co  m*/

    GL11.glPushMatrix();
    texManager.bindTexture(overlay);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
    GL11.glDepthMask(true);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 61680, 0);
    box.render(factor);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:buildcraft.silicon.render.RenderLaserBlock.java

License:Minecraft Mod Public

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
    TileLaser laser = (TileLaser) tileentity;

    if (laser != null) {
        GL11.glPushMatrix();//from  ww w  .  ja  va  2s .  c om
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        GL11.glTranslated(x, y, z);
        GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord);

        GL11.glPushMatrix();
        RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, laser.laser,
                laser.getTexture());
        GL11.glPopMatrix();

        //GL11.glEnable(GL11.GL_LIGHTING);
        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   w w w .  j  a  v  a 2 s .c o m*/
        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:buildcraft.transport.render.GateItemRenderer.java

License:Minecraft Mod Public

private void render(ItemRenderType type, ItemStack stack) {
    GL11.glPushMatrix();/*from w  ww . j  av a  2 s  . c o  m*/
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_ALPHA_TEST); // In certain cases gets disabled by this point
    IIcon icon = ItemGate.getLogic(stack).getIconItem();
    renderItem.renderIcon(0, 0, icon, 16, 16);

    if (type == ItemRenderType.ENTITY) {
        GL11.glTranslatef(0, 0, -0.01f);
    }

    icon = ItemGate.getMaterial(stack).getIconItem();
    if (icon != null) {
        renderItem.renderIcon(0, 0, icon, 16, 16);
    }

    for (IGateExpansion expansion : ItemGate.getInstalledExpansions(stack)) {
        icon = expansion.getOverlayItem();
        if (icon != null) {
            renderItem.renderIcon(0, 0, icon, 16, 16);
        }
    }
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

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

License:Minecraft Mod Public

private void renderPipeItem(RenderBlocks render, ItemStack item, float translateX, float translateY,
        float translateZ) {
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT); //don't break other mods' guis when holding a pipe
    //force transparency
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);

    // GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
    Tessellator tessellator = Tessellator.instance;

    Block block = BuildCraftTransport.genericPipeBlock;
    IIcon icon = item.getItem().getIconFromDamage(0);

    if (icon == null) {
        icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager()
                .getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
    }/*www . j  a  v  a 2  s. co m*/

    block.setBlockBounds(CoreConstants.PIPE_MIN_POS, 0.0F, CoreConstants.PIPE_MIN_POS,
            CoreConstants.PIPE_MAX_POS, 1.0F, CoreConstants.PIPE_MAX_POS);
    block.setBlockBoundsForItemRender();
    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, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, icon);
    tessellator.draw();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

    GL11.glPopAttrib(); // nicely leave the rendering how it was
}

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

License:Minecraft Mod Public

private void pipeWireRender(TileGenericPipe pipe, float cx, float cy, float cz, PipeWire color, double x,
        double y, double z) {

    PipeRenderState state = pipe.renderState;

    float minX = CoreConstants.PIPE_MIN_POS;
    float minY = CoreConstants.PIPE_MIN_POS;
    float minZ = CoreConstants.PIPE_MIN_POS;

    float maxX = CoreConstants.PIPE_MAX_POS;
    float maxY = CoreConstants.PIPE_MAX_POS;
    float maxZ = CoreConstants.PIPE_MAX_POS;

    boolean foundX = false, foundY = false, foundZ = false;

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.WEST)) {
        minX = 0;/*from w  w  w .  j  a va  2 s  .  com*/
        foundX = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.EAST)) {
        maxX = 1;
        foundX = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.DOWN)) {
        minY = 0;
        foundY = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.UP)) {
        maxY = 1;
        foundY = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.NORTH)) {
        minZ = 0;
        foundZ = true;
    }

    if (state.wireMatrix.isWireConnected(color, ForgeDirection.SOUTH)) {
        maxZ = 1;
        foundZ = true;
    }

    boolean center = false;

    if (minX == 0 && maxX != 1 && (foundY || foundZ)) {
        if (cx == CoreConstants.PIPE_MIN_POS) {
            maxX = CoreConstants.PIPE_MIN_POS;
        } else {
            center = true;
        }
    }

    if (minX != 0 && maxX == 1 && (foundY || foundZ)) {
        if (cx == CoreConstants.PIPE_MAX_POS) {
            minX = CoreConstants.PIPE_MAX_POS;
        } else {
            center = true;
        }
    }

    if (minY == 0 && maxY != 1 && (foundX || foundZ)) {
        if (cy == CoreConstants.PIPE_MIN_POS) {
            maxY = CoreConstants.PIPE_MIN_POS;
        } else {
            center = true;
        }
    }

    if (minY != 0 && maxY == 1 && (foundX || foundZ)) {
        if (cy == CoreConstants.PIPE_MAX_POS) {
            minY = CoreConstants.PIPE_MAX_POS;
        } else {
            center = true;
        }
    }

    if (minZ == 0 && maxZ != 1 && (foundX || foundY)) {
        if (cz == CoreConstants.PIPE_MIN_POS) {
            maxZ = CoreConstants.PIPE_MIN_POS;
        } else {
            center = true;
        }
    }

    if (minZ != 0 && maxZ == 1 && (foundX || foundY)) {
        if (cz == CoreConstants.PIPE_MAX_POS) {
            minZ = CoreConstants.PIPE_MAX_POS;
        } else {
            center = true;
        }
    }

    boolean found = foundX || foundY || foundZ;

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    RenderHelper.disableStandardItemLighting();

    GL11.glColor3f(1, 1, 1);
    GL11.glTranslatef((float) x, (float) y, (float) z);

    float scale = 1.001f;
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

    bindTexture(TextureMap.locationBlocksTexture);

    RenderInfo renderBox = new RenderInfo();
    renderBox.texture = BuildCraftTransport.instance.wireIconProvider
            .getIcon(state.wireMatrix.getWireIconIndex(color));

    // Z render

    if (minZ != CoreConstants.PIPE_MIN_POS || maxZ != CoreConstants.PIPE_MAX_POS || !found) {
        renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx,
                cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, minZ,
                cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F,
                cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, maxZ);
        RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord,
                pipe.zCoord, true, true);
    }

    // X render

    if (minX != CoreConstants.PIPE_MIN_POS || maxX != CoreConstants.PIPE_MAX_POS || !found) {
        renderBox.setBounds(minX, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy,
                cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, maxX,
                cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F,
                cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
        RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord,
                pipe.zCoord, true, true);
    }

    // Y render

    if (minY != CoreConstants.PIPE_MIN_POS || maxY != CoreConstants.PIPE_MAX_POS || !found) {
        renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, minY,
                cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz,
                cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, maxY,
                cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
        RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord,
                pipe.zCoord, true, true);
    }

    if (center || !found) {
        renderBox.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx,
                cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy,
                cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz,
                cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F,
                cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F,
                cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F);
        RenderEntityBlock.INSTANCE.renderBlock(renderBox, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord,
                pipe.zCoord, true, true);
    }

    RenderHelper.enableStandardItemLighting();

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

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

License:Minecraft Mod Public

private void pipeGateRender(TileGenericPipe pipe, double x, double y, double z) {
    GL11.glPushMatrix();//from  w w  w. j  a va2  s.c  o m
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    //      GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    //      GL11.glDisable(GL11.GL_TEXTURE_2D);
    RenderHelper.disableStandardItemLighting();

    GL11.glColor3f(1, 1, 1);
    GL11.glTranslatef((float) x, (float) y, (float) z);

    bindTexture(TextureMap.locationBlocksTexture);

    IIcon iconLogic;
    if (pipe.renderState.isGateLit()) {
        iconLogic = pipe.pipe.gate.logic.getIconLit();
    } else {
        iconLogic = pipe.pipe.gate.logic.getIconDark();
    }

    float translateCenter = 0;

    // Render base gate
    renderGate(pipe, iconLogic, 0, 0.1F, 0, 0);

    float pulseStage = pipe.pipe.gate.getPulseStage() * 2F;

    if (pipe.renderState.isGatePulsing() || pulseStage != 0) {
        // Render pulsing gate
        float amplitude = 0.10F;
        float start = 0.01F;

        if (pulseStage < 1) {
            translateCenter = (pulseStage * amplitude) + start;
        } else {
            translateCenter = amplitude - ((pulseStage - 1F) * amplitude) + start;
        }

        renderGate(pipe, iconLogic, 0, 0.13F, translateCenter, translateCenter);
    }

    IIcon materialIcon = pipe.pipe.gate.material.getIconBlock();
    if (materialIcon != null) {
        renderGate(pipe, materialIcon, 1, 0.13F, translateCenter, translateCenter);
    }

    for (IGateExpansion expansion : pipe.pipe.gate.expansions.keySet()) {
        renderGate(pipe, expansion.getOverlayBlock(), 2, 0.13F, translateCenter, translateCenter);
    }

    RenderHelper.enableStandardItemLighting();

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

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

License:Minecraft Mod Public

private void renderFluids(Pipe<PipeTransportFluids> pipe, double x, double y, double z) {
    PipeTransportFluids trans = pipe.transport;

    boolean needsRender = false;
    for (int i = 0; i < 7; ++i) {
        FluidStack fluidStack = trans.renderCache[i];
        if (fluidStack != null && fluidStack.amount > 0) {
            needsRender = true;/* w  ww . j av  a2  s .  c om*/
            break;
        }
    }

    if (!needsRender) {
        return;
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(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);

    GL11.glTranslatef((float) x, (float) y, (float) z);

    // sides

    boolean sides = false, above = false;

    for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
        int i = side.ordinal();

        FluidStack fluidStack = trans.renderCache[i];

        if (fluidStack == null || fluidStack.amount <= 0) {
            continue;
        }

        if (!pipe.container.isPipeConnected(side)) {
            continue;
        }

        DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.getWorldObj());

        if (d == null) {
            continue;
        }

        int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));

        GL11.glPushMatrix();
        int list = 0;

        switch (ForgeDirection.VALID_DIRECTIONS[i]) {
        case UP:
            above = true;
            list = d.sideVertical[stage];
            break;
        case DOWN:
            GL11.glTranslatef(0, -0.75F, 0);
            list = d.sideVertical[stage];
            break;
        case EAST:
        case WEST:
        case SOUTH:
        case NORTH:
            sides = true;
            // Yes, this is kind of ugly, but was easier than transform the coordinates above.
            GL11.glTranslatef(0.5F, 0.0F, 0.5F);
            GL11.glRotatef(angleY[i], 0, 1, 0);
            GL11.glRotatef(angleZ[i], 0, 0, 1);
            GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
            list = d.sideHorizontal[stage];
            break;
        default:
        }
        bindTexture(TextureMap.locationBlocksTexture);
        RenderUtils.setGLColorFromInt(trans.colorRenderCache[i]);
        GL11.glCallList(list);
        GL11.glPopMatrix();
    }
    // CENTER
    FluidStack fluidStack = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()];

    if (fluidStack != null && fluidStack.amount > 0) {
        DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.getWorldObj());

        if (d != null) {
            int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1));

            bindTexture(TextureMap.locationBlocksTexture);
            RenderUtils.setGLColorFromInt(trans.colorRenderCache[ForgeDirection.UNKNOWN.ordinal()]);

            if (above) {
                GL11.glCallList(d.centerVertical[stage]);
            }

            if (!above || sides) {
                GL11.glCallList(d.centerHorizontal[stage]);
            }
        }

    }

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