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:buildcraftAdditions.client.render.tileentities.RendererBackPackStand.java

License:GNU General Public License

@Override
public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float fl) {
    if (entity == null || !(entity instanceof TileBackpackStand))
        return;/*  w  w  w . ja  v  a  2 s .  c  om*/
    int orientation = entity.getWorldObj().getBlockMetadata(entity.xCoord, entity.yCoord, entity.zCoord);
    int angle;
    switch (orientation) {
    case 2:
        angle = 0;
        break;
    case 3:
        angle = 180;
        break;
    case 4:
        angle = 90;
        break;
    case 5:
        angle = -90;
        break;
    default:
        angle = 0;
    }
    GL11.glPushMatrix();
    GL11.glTranslated(x + 0.5, y + 2.4, z + 0.5);
    GL11.glRotated(angle, 0, 1, 0);
    GL11.glRotated(180, 1, 0, 0);
    GL11.glScaled(10, 10, 10);
    ModelBackpackStand.INSTANCE.render(null, 0, 0, 0, 0, 0, 0.01f);
    GL11.glPopMatrix();

    TileBackpackStand stand = (TileBackpackStand) entity;
    if (stand.inventory.getStackInSlot(0) == null)
        return;
    GL11.glPushMatrix();
    GL11.glTranslated(x + 0.5, y + 1.4, z + 0.5);
    GL11.glRotated(angle, 0, 1, 0);
    GL11.glRotated(180, 1, 0, 0);
    BackPackModel.INSTANCE.render(null, 0, 0, 0, 0, 0, 0.1F);
    GL11.glPopMatrix();

    ItemStack bStack = stand.inventory.getStackInSlot(0);
    ItemKineticBackpack backpack = (ItemKineticBackpack) bStack.getItem();
    if (backpack.getInstalledCapsule(bStack, 0) != 0) {
        GL11.glPushMatrix();
        switch (orientation) {
        case 2:
            GL11.glTranslated(x + 0.7, y + 3.15, z + 0.07);
            break;
        case 3:
            GL11.glTranslated(x + 0.3, y + 3.15, z + 0.93);
            break;
        case 4:
            GL11.glTranslated(x + 0.07, y + 3.15, z + 0.3);
            break;
        case 5:
            GL11.glTranslated(x + 0.92, y + 3.15, z + 0.71);
            break;
        }
        GL11.glScaled(2, 2, 2);
        GL11.glRotated(angle, 0, 1, 0);
        GL11.glRotated(180, 1, 0, 0);
        ModelCapsule.INSTANCE.render(null, 0, 0, 0, 0, 0, 0.05F, backpack.getInstalledCapsule(bStack, 0));
        GL11.glPopMatrix();
    }
    if (backpack.getInstalledCapsule(bStack, 1) != 0) {
        GL11.glPushMatrix();
        switch (orientation) {
        case 2:
            GL11.glTranslated(x + 0.3, y + 3.15, z + 0.07);
            break;
        case 3:
            GL11.glTranslated(x + 0.7, y + 3.15, z + 0.93);
            break;
        case 4:
            GL11.glTranslated(x + 0.08, y + 3.15, z + 0.69);
            break;
        case 5:
            GL11.glTranslated(x + 0.93, y + 3.15, z + 0.3);
            break;
        }
        GL11.glRotated(angle, 0, 1, 0);
        GL11.glScaled(2, 2, 2);
        GL11.glRotated(180, 1, 0, 0);
        ModelCapsule.INSTANCE.render(null, 0, 0, 0, 0, 0, 0.05F, backpack.getInstalledCapsule(bStack, 1));
        GL11.glPopMatrix();
    }
    if (backpack.getInstalledCapsule(bStack, 2) != 0) {
        GL11.glPushMatrix();
        switch (orientation) {
        case 2:
            GL11.glTranslated(x + 0.7, y + 2.85, z + 0.07);
            break;
        case 3:
            GL11.glTranslated(x + 0.3, y + 2.85, z + 0.93);
            break;
        case 4:
            GL11.glTranslated(x + 0.07, y + 2.85, z + 0.3);
            break;
        case 5:
            GL11.glTranslated(x + 0.92, y + 2.85, z + 0.71);
            break;
        }

        GL11.glScaled(2, 2, 2);
        GL11.glRotated(angle, 0, 1, 0);
        GL11.glRotated(180, 1, 0, 0);
        ModelCapsule.INSTANCE.render(null, 0, 0, 0, 0, 0, 0.05F, backpack.getInstalledCapsule(bStack, 2));
        GL11.glPopMatrix();
    }
    if (backpack.getInstalledCapsule(bStack, 3) != 0) {
        GL11.glPushMatrix();
        switch (orientation) {
        case 2:
            GL11.glTranslated(x + 0.3, y + 2.85, z + 0.07);
            break;
        case 3:
            GL11.glTranslated(x + 0.7, y + 2.85, z + 0.93);
            break;
        case 4:
            GL11.glTranslated(x + 0.07, y + 2.85, z + 0.71);
            break;
        case 5:
            GL11.glTranslated(x + 0.92, y + 2.85, z + 0.31);
            break;
        }
        GL11.glScaled(2, 2, 2);
        GL11.glRotated(angle, 0, 1, 0);
        GL11.glRotated(180, 1, 0, 0);
        ModelCapsule.INSTANCE.render(null, 0, 0, 0, 0, 0, 0.05F, backpack.getInstalledCapsule(bStack, 3));
        GL11.glPopMatrix();
    }
}

From source file:buildcraftAdditions.client.render.tileentities.RendererDuster.java

License:GNU General Public License

@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float fl) {
    if (tile != null && tile instanceof TileBaseDuster) {
        TileBaseDuster duster = (TileBaseDuster) tile;
        GL11.glPushMatrix();/*from   w w w .j a v  a  2s  .c o  m*/
        GL11.glTranslated(x + .5, y + .5 + getYOffset(), z + .5);
        float angle = 0;
        switch (ForgeDirection.getOrientation(duster.getBlockMetadata())) {
        case NORTH:
            angle = 0;
            break;
        case SOUTH:
            angle = 180;
            break;
        case WEST:
            angle = 90;
            break;
        case EAST:
            angle = -90;
            break;
        default:
            break;
        }
        GL11.glRotatef(angle, 0, 1, 0);
        ItemStack stack = duster.getStackInSlot(0);
        if (stack != null && stack.getItem() != null && stack.stackSize > 0) {
            EntityItem item = new EntityItem(Minecraft.getMinecraft().theWorld, 0, 0, 0, stack);
            item.hoverStart = 0;
            RenderManager.instance.renderEntityWithPosYaw(item, 0, 0, 0, 0, 0);
        }
        GL11.glPopMatrix();
    }
}

From source file:buildcraftAdditions.client.render.tileentities.RendererDusterKinetic.java

License:GNU General Public License

@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float fl) {
    super.renderTileEntityAt(tile, x, y, z, fl);
    if (tile != null && tile instanceof TileKineticDuster) {
        TileKineticDuster duster = (TileKineticDuster) tile;
        GL11.glPushMatrix();//  w w w.j  a v a  2s  .  com
        GL11.glTranslated(x + .5, y + 1.5, z + .5);
        GL11.glRotated(180, 1, 0, 0);
        model.render(duster.progressStage);
        GL11.glPopMatrix();
    }
}

From source file:buildcraftAdditions.client.render.tileentities.RendererKEBT2.java

License:GNU General Public License

@Override
public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float fl) {
    TileKEBT2 keb = (TileKEBT2) entity;//from  ww w .jav a 2  s.c  o  m
    if (!keb.isMaster())
        return;
    bindTexture(side[keb.energyState]);
    RenderHelper.disableStandardItemLighting();
    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();

    //NORTH
    tessellator.addVertexWithUV(0, 0, -1, 1, 1);
    tessellator.addVertexWithUV(0, 2, -1, 1, 0);
    tessellator.addVertexWithUV(2, 2, -1, 0, 0);
    tessellator.addVertexWithUV(2, 0, -1, 0, 1);

    //EAST
    tessellator.addVertexWithUV(2, 0, -1, 0, 1);
    tessellator.addVertexWithUV(2, 2, -1, 0, 0);
    tessellator.addVertexWithUV(2, 2, 1, 1, 0);
    tessellator.addVertexWithUV(2, 0, 1, 1, 1);

    //SOUTH
    tessellator.addVertexWithUV(2, 0, 1, 0, 1);
    tessellator.addVertexWithUV(2, 2, 1, 0, 0);
    tessellator.addVertexWithUV(0, 2, 1, 1, 0);
    tessellator.addVertexWithUV(0, 0, 1, 1, 1);

    //WEST
    tessellator.addVertexWithUV(0, 0, 1, 1, 1);
    tessellator.addVertexWithUV(0, 2, 1, 1, 0);
    tessellator.addVertexWithUV(0, 2, -1, 0, 0);
    tessellator.addVertexWithUV(0, 0, -1, 0, 1);
    tessellator.draw();

    bindTexture(topAndBottom);
    tessellator.startDrawingQuads();

    //BOTTOM
    tessellator.addVertexWithUV(2, 0, -1, 1, 1);
    tessellator.addVertexWithUV(2, 0, 1, 1, 0);
    tessellator.addVertexWithUV(0, 0, 1, 0, 0);
    tessellator.addVertexWithUV(0, 0, -1, 0, 1);

    //TOP
    tessellator.addVertexWithUV(0, 2, -1, 0, 1);
    tessellator.addVertexWithUV(0, 2, 1, 0, 0);
    tessellator.addVertexWithUV(2, 2, 1, 1, 0);
    tessellator.addVertexWithUV(2, 2, -1, 1, 1);

    tessellator.draw();
    GL11.glPopMatrix();
    RenderHelper.enableStandardItemLighting();
}

From source file:butchery.client.TubRenderer.java

License:Minecraft Mod Public

public void renderTubModelAt(TileEntityTub entity, double x, double y, double z, float var8) {
    GL11.glPushMatrix();// w  w w  . ja va  2 s .com
    GL11.glTranslated(x - 0.5, y - 0.3125F, z - 0.44);
    GL11.glPushMatrix();
    bindTextureByName(TUB_TEXTURE);
    Model.renderModel(0.0625F);
    Model.renderWater(entity, 0.0625F, x, y, z);
    GL11.glPopMatrix();
    GL11.glPopMatrix();
}

From source file:ccm.burialservices.client.renderers.GraveRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float tickTime) {
    GraveTE te = (GraveTE) tileentity;//from w w w  .  jav  a2  s.c  o m

    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z); //Center to block

    ResourceLocation skin = te.getLocationSkin();

    float f5 = 0.9F;
    float f6 = 0.0625F;

    switch (te.getBlockMetadata()) {
    case 0:
        break;
    case 1:
        GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(-1, 0, 0);
        break;
    case 2:
        GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(-1, 0, -1);
        break;
    case 3:
        GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(0, 0, -1);
        break;
    }

    GL11.glTranslated(0.5, 0.1d, 0.5);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glScalef(f6, f6, f6);

    Minecraft.getMinecraft().renderEngine.bindTexture(skin);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);

    MODEL_BIPED.bipedHead.rotateAngleX = (float) Math.toRadians(15F);
    MODEL_BIPED.bipedHead.render(f5);
    MODEL_BIPED.bipedBody.render(f5);
    MODEL_BIPED.bipedRightArm.render(f5);
    MODEL_BIPED.bipedLeftArm.render(f5);
    MODEL_BIPED.bipedRightLeg.render(f5);
    MODEL_BIPED.bipedLeftLeg.render(f5);

    GL11.glPopMatrix();

    ItemStack is = te.getHolding();
    if (is != null) {
        renderItemHolding(0, te.getBlockMetadata(), is, x, y, z, tickTime);
        if (is.getItem().requiresMultipleRenderPasses()) {
            for (int i = 1; i < is.getItem().getRenderPasses(is.getItemDamage()); i++) {
                renderItemHolding(i, te.getBlockMetadata(), is, x, y, z, tickTime);
            }
        }
    }

    renderSign(x, y, z, tickTime, te.text, te.getBlockMetadata(), is != null);
}

From source file:ccm.burialservices.client.renderers.GraveRenderer.java

License:Open Source License

private void renderSign(double x, double y, double z, float tickTime, String[] signText, int meta,
        boolean renderingItem) {
    if (signText.length == 0)
        return;// w w  w. ja  va  2s  . c o  m
    int i = 0;
    for (String line : signText)
        if (!Strings.isNullOrEmpty(line)) {
            i++;
        }
    if (i == 0)
        return;

    GL11.glPushMatrix();
    float f1 = 0.6666667F;
    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.75F * f1, (float) z + 0.5F);
    float f2 = 0.0F;

    switch (meta) {
    case 0:
        break;
    case 1:
        f2 = 90f;
        break;
    case 2:
        f2 = 180f;
        break;
    case 3:
        f2 = -90f;

    }
    GL11.glTranslated(0, -0.3, 0);
    if (renderingItem)
        GL11.glTranslated(0, 0.03, 0);

    GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-90F, 1.0F, 0.0F, 0.0F);
    GL11.glTranslated(0, -1.2, 0);

    GL11.glTranslatef(0.0F, -0.3125F, -0.4375F);
    GL11.glTranslatef(0f, 0.8F, 0.5f);
    MODEL_SIGN.signStick.showModel = false;

    this.bindTexture(SIGN_TEXTURE);
    GL11.glPushMatrix();
    GL11.glScalef(f1, -f1, -f1);
    MODEL_SIGN.renderSign();
    GL11.glPopMatrix();
    FontRenderer fontrenderer = this.getFontRenderer();
    f2 = 0.016666668F * f1;
    GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1);
    GL11.glScalef(f2, -f2, f2);
    GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2);
    GL11.glDepthMask(false);
    byte b0 = 0;

    for (int j = 0; j < signText.length; ++j) {
        GL11.glPushMatrix();
        String s = signText[j];
        int width = fontrenderer.getStringWidth(s);
        if (width > 95) {
            float f = 1f - ((width) * 0.0015f);
            GL11.glScalef(f, f, f);
        }
        fontrenderer.drawString(s, -width / 2, j * 10 - 20, b0);
        GL11.glPopMatrix();
    }

    GL11.glDepthMask(true);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:ccm.burialservices.client.renderers.GraveRenderer.java

License:Open Source License

private static void renderItemHolding(int i, int meta, ItemStack stack, double x, double y, double z,
        float tickTime) {
    Icon icon = stack.getItem().getIcon(stack, i);

    if (icon == null)
        return;//from   w  w w .  j a va 2  s .c o  m

    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z); //Center to block

    switch (meta) {
    case 0:
        break;
    case 1:
        GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(-1, 0, 0);
        break;
    case 2:
        GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(-1, 0, -1);
        break;
    case 3:
        GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F);
        GL11.glTranslated(0, 0, -1);
        break;
    }

    if (stack.getItem() instanceof ItemSword) {
        GL11.glTranslated(0.44, 0.1d, 1.85);
        GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
    } else {
        GL11.glTranslated(0.5, 0.1d, 0.5);
    }
    GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);

    TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
    texturemanager.bindTexture(texturemanager.getResourceLocation(stack.getItemSpriteNumber()));
    Tessellator tessellator = Tessellator.instance;

    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    GL11.glTranslatef(0.65f, 0.6f, -0.1f); // Center on block
    GL11.glRotatef(135f, 0, 0, 1);

    ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(),
            icon.getIconWidth(), icon.getIconHeight(), 0.06F);

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

From source file:ccm.pay2spawn.util.Helper.java

License:Open Source License

public static void renderPoint(Tessellator tess, int x, int y, int z) {
    GL11.glPushMatrix();// w ww .j av a 2 s  .  c o m
    GL11.glTranslated(x, y, z);
    GL11.glScalef(1.01f, 1.01f, 1.01f);
    tess.startDrawing(GL11.GL_LINES);

    // FRONT
    tess.addVertex(0, 0, 0);
    tess.addVertex(0, 1, 0);

    tess.addVertex(0, 1, 0);
    tess.addVertex(1, 1, 0);

    tess.addVertex(1, 1, 0);
    tess.addVertex(1, 0, 0);

    tess.addVertex(1, 0, 0);
    tess.addVertex(0, 0, 0);

    // BACK
    tess.addVertex(0, 0, -1);
    tess.addVertex(0, 1, -1);
    tess.addVertex(0, 0, -1);
    tess.addVertex(1, 0, -1);
    tess.addVertex(1, 0, -1);
    tess.addVertex(1, 1, -1);
    tess.addVertex(0, 1, -1);
    tess.addVertex(1, 1, -1);

    // betweens.
    tess.addVertex(0, 0, 0);
    tess.addVertex(0, 0, -1);

    tess.addVertex(0, 1, 0);
    tess.addVertex(0, 1, -1);

    tess.addVertex(1, 0, 0);
    tess.addVertex(1, 0, -1);

    tess.addVertex(1, 1, 0);
    tess.addVertex(1, 1, -1);

    tess.draw();
    GL11.glPopMatrix();
}

From source file:ccm.placeableTools.client.SwordSignGui.java

License:Open Source License

/**
 * Draws the screen and all the components in it.
 *//*from www.ja v a  2 s .c o  m*/
public void drawScreen(int par1, int par2, float par3) {
    this.drawDefaultBackground();
    this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 40, 16777215);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) (this.width / 2), 0.0F, 50.0F);
    float f1 = 93.75F;
    GL11.glScalef(-f1, -f1, -f1);
    GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
    Block block = this.te.getBlockType();

    if (block == Block.signPost) {
        float f2 = (float) (this.te.getBlockMetadata() * 360) / 16.0F;
        GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(0.0F, -1.0625F, 0.0F);
    } else {
        int k = this.te.getBlockMetadata();
        float f3 = 0.0F;

        if (k == 2) {
            f3 = 180.0F;
        }

        if (k == 4) {
            f3 = 90.0F;
        }

        if (k == 5) {
            f3 = -90.0F;
        }

        GL11.glRotatef(f3, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(0.0F, -1.0625F, 0.0F);
    }

    if (this.updateCounter / 6 % 2 == 0) {
        fakeSign.lineBeingEdited = editLine;
    }

    TileEntityRenderer.instance.renderTileEntityAt(this.fakeSign, -0.5D, -0.75D, -0.5D, 0.0F);
    GL11.glPopMatrix();
    super.drawScreen(par1, par2, par3);
}