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.entities.EntityLaserShotRenderer.java

License:GNU General Public License

private void doRender(EntityLaserShot entity, double x, double y, double z, float rotation,
        float partialTicks) {
    bindEntityTexture(entity);//from   ww  w .ja  v  a  2s .com
    GL11.glPushMatrix();
    float strength = entity.getStrength();
    if (strength >= 1)
        GL11.glColor3f(1, 0, 0);
    else if (strength > 0.75)
        GL11.glColor3f(0.75F, 0, 0.25F);
    else if (strength > 0.6)
        GL11.glColor3f(0.5F, 0, 0.5F);
    else if (strength > 0.35)
        GL11.glColor3f(0.25F, 0, 0.75F);
    else
        GL11.glColor3f(0, 0, 1);
    GL11.glTranslated(x, y, z);
    GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks - 90,
            0, 1, 0);
    GL11.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks,
            0, 0, 1);
    Tessellator t = Tessellator.instance;
    double d1 = 0;
    double d2 = 0.5;
    double d3 = 0 / 32D;
    double d4 = 5 / 32D;
    double d5 = 0.05625;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);

    float f1 = entity.throwableShake - partialTicks;
    if (f1 > 0) {
        float f2 = -MathHelper.sin(f1 * 3) * f1;
        GL11.glRotatef(f2, 0, 0, 1);
    }

    GL11.glRotatef(45, 1, 0, 0);
    GL11.glScaled(d5, d5, d5);
    GL11.glTranslatef(-4, 0, 0);
    for (int i = 0; i < 4; i++) {
        GL11.glRotatef(90, 1, 0, 0);
        GL11.glNormal3d(0, 0, d5);
        t.startDrawingQuads();
        t.addVertexWithUV(-8, -2, 0, d1, d3);
        t.addVertexWithUV(8, -2, 0, d2, d3);
        t.addVertexWithUV(8, 2, 0, d2, d4);
        t.addVertexWithUV(-8, 2, 0, d1, d4);
        t.draw();
    }

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

From source file:buildcraftAdditions.client.render.items.BackPackItemRenderer.java

License:GNU General Public License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    GL11.glPushMatrix();// www  .  ja  v  a 2s  .co m
    switch (type) {
    case EQUIPPED:
        GL11.glRotated(180, 0, 0, 1);
        GL11.glTranslated(-0.75, -0.5, 0);
        break;
    case EQUIPPED_FIRST_PERSON:
        GL11.glTranslated(1, .5, 0);
        GL11.glRotated(270, 0, 1, 0);
        GL11.glRotated(180, 1, 0, 0);
        GL11.glRotated(180, 0, 1, 0);
        break;
    case INVENTORY:
        GL11.glRotated(180, 0, 1, 0);
        GL11.glRotated(180, 1, 0, 0);
        GL11.glTranslated(0, -.25, 0);
    }
    BackPackModel.INSTANCE2.render(null, 0, 0, 0, 0, 0, 0.06f);

    GL11.glPopMatrix();
}

From source file:buildcraftAdditions.client.render.items.BackpackStandItemRenderer.java

License:GNU General Public License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();//from   w w w .j  a  va 2s.c o  m
    switch (type) {
    case ENTITY:
        GL11.glTranslated(0, 1, 0);
        GL11.glRotated(180, 1, 0, 0);
        GL11.glRotated(90, 0, 1, 0);
        break;
    case EQUIPPED:
        GL11.glRotated(180, 0, 0, 1);
        GL11.glTranslated(-0.75, 0, 0);
        GL11.glTranslated(0, -1.5, 0);
        break;
    case EQUIPPED_FIRST_PERSON:
        GL11.glTranslated(1, 1.5, 0);
        GL11.glRotated(90, 0, 1, 0);
        GL11.glRotated(180, 0, 0, 1);
        break;
    case INVENTORY:
        GL11.glRotated(180, 1, 0, 0);
        GL11.glTranslated(0, -1, 0);
        break;
    default:
        break;
    }
    ModelBackpackStand.INSTANCE2.render(null, 0, 0, 0, 0, 0, 0.0625F);

    GL11.glPopMatrix();
}

From source file:buildcraftAdditions.client.render.items.CanisterItemRender.java

License:GNU General Public License

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

    ItemCanister canister = (ItemCanister) item.getItem();

    IIcon overlay = canister.getOverlay();
    IIcon canisterIcon = canister.getIconFromDamage(0);

    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    if (type.equals(ItemRenderType.EQUIPPED)) {
        GL11.glRotated(180, 0, 0, 1);
        GL11.glTranslated(-1, -1, 0);
    } else if (type.equals(ItemRenderType.ENTITY)) {
        GL11.glRotated(180, 0, 0, 1);
        GL11.glRotated(90, 0, 1, 0);
        GL11.glTranslated(-0.5, -0.9, 0);
        if (item.isOnItemFrame()) {
            GL11.glTranslated(0.075, 0.475, 0);
            GL11.glScaled(0.85, 0.85, 0.85);
        }
    } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) {
        GL11.glTranslated(1, 1, 0);
        GL11.glRotated(180, 0, 0, 1);
    }

    FluidStack fluid = Utils.getFluidStackFromItemStack(item);
    if (fluid != null) {
        Fluid f = fluid.getFluid();
        if (f != null) {
            Minecraft.getMinecraft().renderEngine.bindTexture(RenderUtils.MC_ITEM_SHEET);
            renderMask(overlay, f.getIcon(), type);
        }
    }
    Minecraft.getMinecraft().renderEngine.bindTexture(RenderUtils.MC_ITEM_SHEET);

    if (type.equals(ItemRenderType.INVENTORY))
        renderIcon(canisterIcon, 0);
    else
        ItemRenderer.renderItemIn2D(Tessellator.instance, canisterIcon.getMinU(), canisterIcon.getMaxV(),
                canisterIcon.getMaxU(), canisterIcon.getMinV(), canisterIcon.getIconWidth(),
                canisterIcon.getIconHeight(), 0.0625F);

    GL11.glColor4f(1, 1, 1, 1);
    GL11.glPopMatrix();
}

From source file:buildcraftAdditions.client.render.items.KineticDusterItemRenderer.java

License:GNU General Public License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    GL11.glPushMatrix();//from w w  w .  j  ava2s .co  m
    GL11.glRotated(180, 0, 0, 1);
    switch (type) {
    case EQUIPPED:
    case EQUIPPED_FIRST_PERSON:
        GL11.glTranslated(-0.5, -1.5, 0.5);
        break;
    case INVENTORY:
    case ENTITY:
        GL11.glTranslated(0, -1, 0);
        break;
    default:
        break;
    }
    model.render(0);

    GL11.glPopMatrix();
}

From source file:buildcraftAdditions.client.render.KineticToolItemRender.java

License:GNU General Public License

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    IIcon overlayChainsaw = tool.overlayChainsaw;
    IIcon overlayDigger = tool.overlayDigger;
    IIcon overlayDrill = tool.overlayDrill;
    IIcon overlayHoe = tool.overlayHoe;/*from www .  j ava 2 s  .c  o m*/
    IIcon toolIcon = tool.getIconFromDamage(0);

    GL11.glPushMatrix();
    if (type.equals(ItemRenderType.EQUIPPED)) {
        GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D);
        GL11.glTranslated(-1.0D, -1.0D, 0.0D);
    } else if (type.equals(ItemRenderType.ENTITY)) {
        GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D);
        GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D);
        GL11.glTranslated(-0.5D, -0.9D, 0.0D);
        if (item.isOnItemFrame()) {
            GL11.glTranslated(0.1D, 0.4D, 0.0D);
            GL11.glScaled(0.85D, 0.85D, 0.85D);
        }
    } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) {
        GL11.glTranslated(1.0D, 1.0D, 0.0D);
        GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D);
    }

    String lastUsedMode = "";
    if (item.stackTagCompound != null && item.stackTagCompound.hasKey("lastUsedMode"))
        lastUsedMode = item.stackTagCompound.getString("lastUsedMode");
    if (lastUsedMode.equals("axe")) {
        Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);
        renderMask(overlayChainsaw, overlayChainsaw, type);
    }

    if (lastUsedMode.equals("shovel")) {
        Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);
        renderMask(overlayDigger, overlayDigger, type);
    }

    if (lastUsedMode.equals("pickaxe")) {
        Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);
        renderMask(overlayDrill, overlayDrill, type);
    }

    if (lastUsedMode.equals("hoe")) {
        Minecraft.getMinecraft().renderEngine.bindTexture(ITEM_TEXTURE);
        renderMask(overlayHoe, overlayHoe, type);
    }

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

    if (!type.equals(ItemRenderType.INVENTORY))
        ItemRenderer.renderItemIn2D(Tessellator.instance, toolIcon.getMinU(), toolIcon.getMaxV(),
                toolIcon.getMaxU(), toolIcon.getMinV(), toolIcon.getIconWidth(), toolIcon.getIconHeight(),
                0.0625F);
    else
        renderIcon(toolIcon, 0.0D);

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

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

License:GNU General Public License

@Override
public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float fl) {
    GL11.glPushMatrix();/*from  ww w  .  j  a va2 s .  co m*/
    GL11.glTranslated(x, y, z);
    TileBaseDuster duster = (TileBaseDuster) entity;
    ItemStack stack = duster.getStackInSlot(0);
    EntityItem item;
    if (stack != null) {
        item = new EntityItem(Minecraft.getMinecraft().theWorld, 0, 0, 0, stack);
        item.hoverStart = 0;
        RenderManager.instance.renderEntityWithPosYaw(item, 0.5, 1.05, 0.5, 0, 0);
    }
    GL11.glPopMatrix();
}

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

License:GNU General Public License

@Override
public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float fl) {
    GL11.glPushMatrix();//from  w  ww .j  av  a 2s .co m
    GL11.glTranslated(x, y, z);
    TileBaseDuster duster = (TileBaseDuster) entity;
    ItemStack stack = duster.getStackInSlot(0);
    EntityItem item;
    if (stack != null) {
        item = new EntityItem(Minecraft.getMinecraft().theWorld, 0, 0, 0, stack);
        item.hoverStart = 0;
        RenderManager.instance.renderEntityWithPosYaw(item, 0.5, 0.5, 0.5, 0, 0);
    }
    GL11.glPopMatrix();
}

From source file:buildcraftAdditions.client.render.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 www  .ja  va2  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:buildcraftAdditions.client.render.RendererKEBT3.java

License:GNU General Public License

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

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

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

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

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

    bindTexture(topAndBottom);
    tessellator.startDrawingQuads();

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

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

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