Example usage for org.lwjgl.opengl GL11 glPopMatrix

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

Introduction

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

Prototype

public static native void glPopMatrix();

Source Link

Document

Pops the top entry off the current matrix stack, replacing the current matrix with the matrix that was the second entry in the stack.

Usage

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;//from   w  w w. ja  va  2  s  .com
            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();
}

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

License:Minecraft Mod Public

private void renderSolids(Pipe<PipeTransportItems> pipe, double x, double y, double z) {
    GL11.glPushMatrix();/* w  w w .j a  v a 2s .com*/
    GL11.glDisable(2896 /* GL_LIGHTING */);

    float light = pipe.container.getWorldObj().getLightBrightness(pipe.container.xCoord, pipe.container.yCoord,
            pipe.container.zCoord);

    int count = 0;
    for (TravelingItem item : pipe.transport.items) {
        if (count >= MAX_ITEMS_TO_RENDER) {
            break;
        }

        doRenderItem(item, x + item.xCoord - pipe.container.xCoord, y + item.yCoord - pipe.container.yCoord,
                z + item.zCoord - pipe.container.zCoord, light, item.color);
        count++;
    }

    GL11.glEnable(2896 /* GL_LIGHTING */);
    GL11.glPopMatrix();
}

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

License:Minecraft Mod Public

public void doRenderItem(TravelingItem travellingItem, double x, double y, double z, float light,
        EnumColor color) {/*from  w  w w .  j  a  v a2  s. c  om*/

    if (travellingItem == null || travellingItem.getItemStack() == null) {
        return;
    }

    float renderScale = 0.7f;
    ItemStack itemstack = travellingItem.getItemStack();
    GL11.glPushMatrix();
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glTranslatef(0, 0.25F, 0);
    GL11.glScalef(renderScale, renderScale, renderScale);
    dummyEntityItem.setEntityItemStack(itemstack);
    customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);

    if (color != null) {
        bindTexture(TextureMap.locationBlocksTexture);
        RenderInfo block = new RenderInfo();

        block.texture = PipeIconProvider.TYPE.ItemBox.getIcon();

        float pix = 0.0625F;

        float min = -4 * pix;
        float max = 4 * pix;

        block.minY = min;
        block.maxY = max;

        block.minZ = min;
        block.maxZ = max;

        block.minX = min;
        block.maxX = max;

        RenderUtils.setGLColorFromInt(color.getLightHex());
        RenderEntityBlock.INSTANCE.renderBlock(block, null, 0, 0, 0, false, true);
    }

    GL11.glPopMatrix();
}

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

License:Minecraft Mod Public

private void renderPower(Pipe pipe, double x, double y, double z) {
    PipeTransportPower pow = (PipeTransportPower) pipe.transport;

    GL11.glPushMatrix();// w ww  .  ja  v a 2 s.  c om
    GL11.glDisable(2896 /* GL_LIGHTING */);

    ForgeHooksClient.bindTexture(DefaultProps.TEXTURE_BLOCKS, 0);

    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);

    int[] displayList = pow.overload ? displayPowerListOverload : displayPowerList;

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

        GL11.glRotatef(angleY[i], 0, 1, 0);
        GL11.glRotatef(angleZ[i], 0, 0, 1);

        if (pow.displayPower[i] >= 1.0) {
            short stage = pow.displayPower[i];

            if (stage < displayList.length) {
                GL11.glCallList(displayList[stage]);
            } else {
                GL11.glCallList(displayList[displayList.length - 1]);
            }
        }

        GL11.glPopMatrix();
    }

    GL11.glEnable(2896 /* GL_LIGHTING */);
    GL11.glPopMatrix();
}

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

License:Minecraft Mod Public

private void renderLiquids(Pipe pipe, double x, double y, double z) {
    PipeTransportLiquids liq = (PipeTransportLiquids) pipe.transport;

    GL11.glPushMatrix();//  w  ww .  ja  va  2  s.  c  o m
    GL11.glDisable(2896 /* GL_LIGHTING */);

    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);

    // sides

    boolean sides = false, above = false;

    for (int i = 0; i < 6; ++i) {
        // ILiquidTank tank = liq.getTanks()[i];
        // LiquidStack liquid = tank.getLiquid();
        LiquidStack liquid = liq.renderCache[i];
        // int amount = liquid != null ? liquid.amount : 0;
        // int amount = liquid != null ? liq.renderAmmount[i] : 0;

        if (liquid != null && liquid.amount > 0) {
            DisplayLiquidList d = getListFromBuffer(liquid, pipe.worldObj);

            if (d == null) {
                continue;
            }

            int stage = (int) ((float) liquid.amount / (float) (liq.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;
                GL11.glRotatef(angleY[i], 0, 1, 0);
                GL11.glRotatef(angleZ[i], 0, 0, 1);
                list = d.sideHorizontal[stage];
                break;
            default:
            }

            GL11.glCallList(list);
            GL11.glPopMatrix();
        }
    }
    // CENTER
    // ILiquidTank tank = liq.getTanks()[ForgeDirection.Unknown.ordinal()];
    // LiquidStack liquid = tank.getLiquid();
    LiquidStack liquid = liq.renderCache[ForgeDirection.UNKNOWN.ordinal()];

    // int amount = liquid != null ? liquid.amount : 0;
    // int amount = liquid != null ? liq.renderAmmount[ForgeDirection.Unknown.ordinal()] : 0;
    if (liquid != null && liquid.amount > 0) {
        // DisplayLiquidList d = getListFromBuffer(liq.getTanks()[ForgeDirection.Unknown.ordinal()].getLiquid(), pipe.worldObj);
        DisplayLiquidList d = getListFromBuffer(liquid, pipe.worldObj);

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

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

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

    }

    GL11.glEnable(2896 /* GL_LIGHTING */);
    GL11.glPopMatrix();
}

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

License:Minecraft Mod Public

private void renderSolids(Pipe pipe, double x, double y, double z) {
    GL11.glPushMatrix();//from   www.  j  a  v  a 2 s. c o  m
    GL11.glDisable(2896 /* GL_LIGHTING */);

    float light = pipe.worldObj.getLightBrightness(pipe.xCoord, pipe.yCoord, pipe.zCoord);

    int count = 0;
    for (EntityData data : ((PipeTransportItems) pipe.transport).travelingEntities.values()) {
        if (count >= MAX_ITEMS_TO_RENDER) {
            break;
        }

        doRenderItem(data.item, x + data.item.getPosition().x - pipe.xCoord,
                y + data.item.getPosition().y - pipe.yCoord, z + data.item.getPosition().z - pipe.zCoord,
                light);
        count++;
    }

    GL11.glEnable(2896 /* GL_LIGHTING */);
    GL11.glPopMatrix();
}

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

License:Minecraft Mod Public

public void doRenderItem(IPipedItem entityitem, double d, double d1, double d2, float f1) {

    if (entityitem == null || entityitem.getItemStack() == null)
        return;/*from w  w w .  ja  v  a 2s . co m*/

    float renderScale = 0.7f;
    ItemStack itemstack = entityitem.getItemStack();
    GL11.glPushMatrix();
    GL11.glTranslatef((float) d, (float) d1, (float) d2);
    GL11.glTranslatef(0, 0.25F, 0);
    GL11.glScalef(renderScale, renderScale, renderScale);
    dummyEntityItem.func_92058_a(itemstack);
    customRenderItem.doRenderItem(dummyEntityItem, 0, 0, 0, 0, 0);
    GL11.glPopMatrix();
}

From source file:buildcraft.transport.RenderPipe.java

License:Minecraft Mod Public

private void renderPower(Pipe pipe, double x, double y, double z) {
    PipeTransportPower pow = (PipeTransportPower) pipe.transport;

    GL11.glPushMatrix();/*from  w w w  .  j  a va2s .  c om*/
    GL11.glDisable(2896 /* GL_LIGHTING */);

    MinecraftForgeClient.bindTexture(DefaultProps.TEXTURE_BLOCKS);

    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);

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

        GL11.glRotatef(angleY[i], 0, 1, 0);
        GL11.glRotatef(angleZ[i], 0, 0, 1);

        if (pow.displayPower[i] >= 1.0) {
            int stage = 0;

            for (; stage < displayPowerStages; ++stage)
                if (displayPowerLimits[stage] > pow.displayPower[i])
                    break;

            if (stage < displayPowerList.length)
                GL11.glCallList(displayPowerList[stage]);
            else
                GL11.glCallList(displayPowerList[displayPowerList.length - 1]);
        }

        GL11.glPopMatrix();
    }

    GL11.glEnable(2896 /* GL_LIGHTING */);
    GL11.glPopMatrix();
}

From source file:buildcraft.transport.RenderPipe.java

License:Minecraft Mod Public

private void renderLiquids(Pipe pipe, double x, double y, double z) {
    PipeTransportLiquids liq = (PipeTransportLiquids) pipe.transport;

    GL11.glPushMatrix();/*  w  ww  . j  ava2s.c  o m*/
    GL11.glDisable(2896 /* GL_LIGHTING */);

    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F);

    // sides

    boolean sides = false, above = false;

    for (int i = 0; i < 6; ++i) {
        //ILiquidTank tank = liq.getTanks()[i];
        //LiquidStack liquid = tank.getLiquid();
        LiquidStack liquid = liq.renderCache[i];
        //int amount = liquid != null ? liquid.amount : 0;
        //int amount = liquid != null ? liq.renderAmmount[i] : 0;

        if (liquid != null && liquid.amount > 0) {
            DisplayLiquidList d = getListFromBuffer(liquid, pipe.worldObj);

            if (d == null)
                continue;

            int stage = (int) ((float) liquid.amount / (float) (PipeTransportLiquids.LIQUID_IN_PIPE)
                    * (displayLiquidStages - 1));

            GL11.glPushMatrix();
            int list = 0;

            switch (Orientations.values()[i]) {
            case YPos:
                above = true;
                list = d.sideVertical[stage];
                break;
            case YNeg:
                GL11.glTranslatef(0, -0.75F, 0);
                list = d.sideVertical[stage];
                break;
            case XPos:
            case XNeg:
            case ZPos:
            case ZNeg:
                sides = true;
                GL11.glRotatef(angleY[i], 0, 1, 0);
                GL11.glRotatef(angleZ[i], 0, 0, 1);
                list = d.sideHorizontal[stage];
                break;
            }

            GL11.glCallList(list);
            GL11.glPopMatrix();
        }
    }
    // CENTER
    //      ILiquidTank tank = liq.getTanks()[Orientations.Unknown.ordinal()];
    //      LiquidStack liquid = tank.getLiquid();
    LiquidStack liquid = liq.renderCache[Orientations.Unknown.ordinal()];

    //int amount = liquid != null ? liquid.amount : 0; 
    //int amount = liquid != null ? liq.renderAmmount[Orientations.Unknown.ordinal()] : 0;
    if (liquid != null && liquid.amount > 0) {
        //DisplayLiquidList d = getListFromBuffer(liq.getTanks()[Orientations.Unknown.ordinal()].getLiquid(), pipe.worldObj);
        DisplayLiquidList d = getListFromBuffer(liquid, pipe.worldObj);

        if (d != null) {
            int stage = (int) ((float) liquid.amount / (float) (PipeTransportLiquids.LIQUID_IN_PIPE)
                    * (displayLiquidStages - 1));

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

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

    }

    GL11.glEnable(2896 /* GL_LIGHTING */);
    GL11.glPopMatrix();
}

From source file:buildcraft.transport.RenderPipe.java

License:Minecraft Mod Public

private void renderSolids(Pipe pipe, double x, double y, double z) {
    GL11.glPushMatrix();/*from  w w w.  j  a va 2s.  c  o m*/
    GL11.glDisable(2896 /* GL_LIGHTING */);

    float light = pipe.worldObj.getLightBrightness(pipe.xCoord, pipe.yCoord, pipe.zCoord);

    int count = 0;
    for (EntityData data : ((PipeTransportItems) pipe.transport).travelingEntities.values()) {
        if (count >= numItemsToRender)
            break;

        doRenderItem(data.item, x + data.item.getPosition().x - pipe.xCoord,
                y + data.item.getPosition().y - pipe.yCoord, z + data.item.getPosition().z - pipe.zCoord,
                light);
        count++;
    }

    GL11.glEnable(2896 /* GL_LIGHTING */);
    GL11.glPopMatrix();
}