Example usage for org.lwjgl.opengl GL11 glPushMatrix

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

Introduction

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

Prototype

public static native void glPushMatrix();

Source Link

Document

Pushes the current matrix stack down by one, duplicating the current matrix in both the top of the stack and the entry below it.

Usage

From source file:com.builtbroken.icbm.content.launcher.block.TileLauncherFrame.java

@SideOnly(Side.CLIENT)
public void renderDynamic(Pos pos, float frame, int pass) {
    GL11.glPushMatrix();
    GL11.glScalef(1f, 1f, 1f);/*w w  w  .  j av a2 s  .c o  m*/
    GL11.glTranslatef(pos.xf() + 0.5f, pos.yf(), pos.zf() + 0.5f);
    if (getMetadata() == 0) {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.LAUNCHER_FRAME_TEXTURE);
        Assets.LAUNCHER_FRAME_BLOCK_MODEL.renderAll();
    } else {
        int rotation = getMetadata();
        switch (rotation) {
        case 1:
            GL11.glRotatef(180, 0, 1, 0);
            break;
        case 2:
            GL11.glRotatef(0, 0, 1, 0);
            break;
        case 3:
            GL11.glRotatef(90, 0, 1, 0);
            break;
        case 4:
            GL11.glRotatef(-90, 0, 1, 0);
            break;
        }
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.LAUNCHER_FRAME_TEXTURE);
        Assets.LAUNCHER_FRAME_BLOCK_TOP_MODEL.renderAll();
    }
    GL11.glPopMatrix();
}

From source file:com.builtbroken.icbm.content.launcher.controller.remote.antenna.ItemRendererAntennaFrame.java

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    int meta = item.getItemDamage();
    GL11.glPushMatrix();
    GL11.glScalef(1f, 1f, 1f);//from   w  w  w  .  j ava  2 s. c o  m
    GL11.glTranslatef(-0.0F, -0.5F, 0.0F);
    if (meta == 0 || meta == 1) {
        //TODO if meta == 1 change texture to say its connected to a base
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_TOWER_MODEL.renderAll();
    } else if (meta == 2) {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_BASE_MODEL.renderAll();
    } else if (meta == 3) {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_INTERSECTION_MODEL.renderAll();
    } else if (meta == 4) {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_NOTCH_MODEL.renderAll();
    } else if (meta == 5) {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_PIKE_MODEL.renderAll();
    } else if (meta == 6) //East West
    {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_ARM2_MODEL.renderAll();
    } else if (meta == 7) //North South
    {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_ARM_MODEL.renderAll();
    }
    GL11.glPopMatrix();
}

From source file:com.builtbroken.icbm.content.launcher.controller.remote.antenna.TESRAntenna.java

@Override
public void renderTileEntityAt(TileEntity tile, double xx, double yy, double zz, float f) {
    GL11.glPushMatrix();
    GL11.glTranslatef((float) xx + 0.5f, (float) yy, (float) zz + 0.5f);
    int meta = tile.getBlockMetadata();
    if (meta == 0 || meta == 1) {
        //TODO if meta == 1 change texture to say its connected to a base
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_TOWER_MODEL.renderAll();
    } else if (meta == 2) {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_BASE_MODEL.renderAll();
    } else if (meta == 3) {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_INTERSECTION_MODEL.renderAll();
    } else if (meta == 4) {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_NOTCH_MODEL.renderAll();
    } else if (meta == 5) {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_PIKE_MODEL.renderAll();
    } else if (meta == 6) //East West
    {//w w  w .  ja va  2 s  .co m
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_ARM2_MODEL.renderAll();
    } else if (meta == 7) //North South
    {
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.ANTENNA_TEXTURE);
        Assets.ANTENNA_ARM_MODEL.renderAll();
    }
    GL11.glPopMatrix();
}

From source file:com.builtbroken.icbm.content.launcher.controller.remote.display.TileSiloInterfaceClient.java

@Override
@SideOnly(Side.CLIENT)/*from w ww .  jav  a  2 s .  c  o m*/
public void renderDynamic(Pos pos, float frame, int pass) {
    //Render launcher
    GL11.glPushMatrix();
    GL11.glTranslatef(pos.xf() + 0.5f, pos.yf() - 0.561f, pos.zf() + 0.5f);
    switch (getDirection()) {
    case EAST:
        break;
    case WEST:
        GL11.glRotatef(180f, 0, 1f, 0);
        break;
    case SOUTH:
        GL11.glRotatef(-90f, 0, 1f, 0);
        break;
    default:
        GL11.glRotatef(90f, 0, 1f, 0);
        break;
    }
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.FoF_STATION_TEXTURE);
    Assets.FoF_STATION_MODEL.renderOnly("Group_006", "Group_007");
    GL11.glPopMatrix();
}

From source file:com.builtbroken.icbm.content.launcher.launcher.large.TileLargeLauncher.java

@Override
@SideOnly(Side.CLIENT)//  w  ww .  j  ava2  s .c om
public void renderDynamic(Pos pos, float frame, int pass) {
    //Render launcher
    GL11.glPushMatrix();
    GL11.glTranslatef(pos.xf() - 0.5f, pos.yf() + 0.5f, pos.zf() + 2.5f);
    GL11.glScalef(1.5f, 1.5f, 1.5f);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.GREY_FAKE_TEXTURE);
    Assets.STANDARD_MISSILE_MODEL.renderAll();
    GL11.glPopMatrix();
}

From source file:com.builtbroken.icbm.content.launcher.launcher.standard.TileStandardLauncherClient.java

@Override
@SideOnly(Side.CLIENT)// ww w .j ava  2s  .  c  om
public void renderDynamic(Pos center, float f, int pass) {
    if (missile != null) {
        //Render launcher
        GL11.glPushMatrix();
        Pos pos = center.add(getDirection()).add(0.5, 0, 0.5);
        GL11.glTranslatef(pos.xf(), pos.yf(), pos.zf());
        GL11.glRotatef(45f, 0, 1, 0);
        if (missile instanceof ICustomMissileRender) {
            GL11.glTranslatef(0, ((ICustomMissileRender) missile).getRenderHeightOffset(), 0);
            ((ICustomMissileRender) missile).renderMissileInWorld(0, 0, f);
        }
        GL11.glPopMatrix();
    } else if (recipe != null) {
        if (!processedModel) {
            processModel();
        }
        //Render launcher
        GL11.glPushMatrix();

        Pos pos = center;

        final float yf = 2.2f;
        switch (ForgeDirection.getOrientation(getMetadata())) {
        case NORTH:
            pos = pos.add(-0.65, yf, 0.95);
            break;
        case SOUTH:
            pos = pos.add(-0.65, yf, 2.95);
            break;
        case EAST:
            pos = pos.add(.35, yf, 1.95);
            break;
        case WEST:
            pos = pos.add(-1.65, yf, 1.95);
            break;
        }
        GL11.glTranslatef(pos.xf(), pos.yf(), pos.zf());
        GL11.glRotatef(45f, 0, 1, 0);
        GL11.glScalef(0.85f, 0.85f, 0.85f);
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.GREY_FAKE_TEXTURE);
        //TODO render crafting progress
        //TODO render ghost of missile frame

        //Render frame pieces
        for (int i = 0; i < recipe.frameLevel && i < frame.length; i++) {
            frame[i].render();
        }
        //Only render guts of missile if frame is completed
        if (recipe.frameCompleted) {
            if (recipe.warhead != null) {
                warhead.render();
            }
            if (recipe.rocketComputer != null) {
                guidance.render();
            }
            if (recipe.rocketEngine != null) {
                for (GroupObject o : engine) {
                    o.render();
                }
            }
            //Render Skin
            if (recipe.platesContained > 0) {
                for (int i = 0; i < recipe.platesContained; i++) {
                    //TODO fix layers as they are not perfect, could be naming of parts
                    int layer = i / StandardMissileCrafting.PLATE_PER_LEVEL_COUNT;
                    int set = i % StandardMissileCrafting.PLATE_PER_LEVEL_COUNT;
                    if (layer < skinLayers.length) {
                        skinLayers[layer][set].render();
                    }
                }
            }
        }

        GL11.glPopMatrix();
    }
}

From source file:com.builtbroken.icbm.content.launcher.silo.TileStandardSilo.java

@Override
@SideOnly(Side.CLIENT)/*  w  w  w .  j  a  va2  s  .  c om*/
public void renderDynamic(Pos pos, float frame, int pass) {
    //Render launcher
    GL11.glPushMatrix();
    GL11.glTranslatef(pos.xf(), pos.yf(), pos.zf() + 1);
    FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.STANDARD_SILO_TEXTURE);
    Assets.STANDARD_SILO_MODEL.renderAll();
    GL11.glPopMatrix();

    //Render missile
    if (getMissile() != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(pos.xf() + 0.5f, pos.yf() + 2.75f, pos.zf() + 0.5f);
        //TODO rotate
        if (getMissile() instanceof ICustomMissileRender) {
            ((ICustomMissileRender) getMissile()).renderMissileInWorld(0, 0, frame);
        }
        GL11.glPopMatrix();
    }
}

From source file:com.builtbroken.icbm.content.missile.tile.TileCrashedMissile.java

@Override
@SideOnly(Side.CLIENT)//w w w  . ja  v  a 2 s. co m
public void renderDynamic(Pos pos, float frame, int pass) {
    GL11.glPushMatrix();
    if (missile != null) {
        GL11.glTranslated(pos.x() + 0.5,
                pos.y() + (float) (missile.getHeight() / 2.0) - (float) (missile.getHeight() / 3.0),
                pos.z() + 0.5);
        if (block != null) {
            GL11.glTranslated(0, block.getBlockBoundsMaxY(), 0);
        }
        if (posOffset != null) {
            GL11.glTranslated(posOffset.x(), posOffset.y(), posOffset.z());
        }
        if (!(missile instanceof ICustomMissileRender)
                || !((ICustomMissileRender) missile).renderMissileInWorld(yaw - 90, pitch - 90, frame)) {
            renderDefaultMissile();
        }
    } else {
        GL11.glTranslated(pos.x() + 0.5, pos.y() + .4, pos.z() + 0.5);
        if (posOffset != null) {
            GL11.glTranslated(posOffset.x(), posOffset.y(), posOffset.z());
        }
        renderDefaultMissile();
    }
    GL11.glPopMatrix();
    if (block != null) {
        GL11.glPushMatrix();
        GL11.glTranslated(pos.x() + 0.5, pos.y() + 0.5, pos.z() + 0.5);
        RenderUtility.renderInventoryBlock(RenderUtility.renderBlocks, block, meta);
        GL11.glPopMatrix();
    }
}

From source file:com.builtbroken.icbm.content.rail.RenderMissileCart.java

@Override
public void doRender(final Entity entity, final double xx, final double yy, final double zz,
        final float p_76986_8_, final float delta) {
    final EntityMissileCart cart = (EntityMissileCart) entity;
    float f5 = cart.prevRotationPitch + (cart.rotationPitch - cart.prevRotationPitch) * delta;

    double x2 = MathHelper.lerp(cart.lastRenderX, xx, delta);
    double y2 = MathHelper.lerp(cart.lastRenderY, yy, delta);
    double z2 = MathHelper.lerp(cart.lastRenderZ, zz, delta);

    GL11.glPushMatrix();
    GL11.glTranslated(x2, y2, z2);//from  w  w w .j a  va 2 s .c  om
    GL11.glRotatef(180.0F - delta, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-f5, 0.0F, 0.0F, 1.0F);

    cart.lastRenderX = x2;
    cart.lastRenderY = y2;
    cart.lastRenderZ = z2;

    if (cart.getType() == MissileCartTypes.SMALL) {
        GL11.glPushMatrix();
        GL11.glTranslatef(0f, 0.05f, 0f);
        GL11.glRotated(90, 0, 1, 0);

        GL11.glRotated(cart.rotationYaw, 0, 1, 0);

        //Renders the cart
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.SMALL_WORKSTATION_TEXTURE2);
        Assets.CART1x3.renderAll();

        if (cart.getCargoMissile() != null) {
            //Render missile
            GL11.glRotated(-90, 0, 1, 0);
            renderMissile(cart.getCargoMissile(), cart.railSide, cart.facingDirection);
        }

        GL11.glPopMatrix();
    } else if (cart.getType() == MissileCartTypes.MICRO) {
        GL11.glPushMatrix();
        GL11.glTranslatef(0f, .32f, 0f);
        GL11.glRotated(90, 0, 1, 0);

        //Renders the cart
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.GREY_FAKE_TEXTURE);
        Assets.CART1x1.renderAll();

        if (cart.getCargoMissile() != null) {
            GL11.glTranslated(0, -0.44, 0);
            if (cart.getCargoMissile() instanceof ICustomMissileRender) {
                GL11.glTranslatef(0f, ((ICustomMissileRender) cart.getCargoMissile()).getRenderHeightOffset(),
                        0f);
            }
            renderMissile(cart.getCargoMissile(), ForgeDirection.EAST, ForgeDirection.UP);
        }

        GL11.glPopMatrix();
    } else if (cart.getType() == MissileCartTypes.ThreeByThree) {
        GL11.glPushMatrix();
        GL11.glTranslatef(0f, -0.05f, 0f);
        GL11.glRotated(90, 0, 1, 0);

        //Renders the cart
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.GREY_FAKE_TEXTURE);
        Assets.CART3x3.renderAll();

        if (cart.getCargoMissile() != null) {
            GL11.glTranslated(0, -0.3, 0);
            if (cart.getCargoMissile() instanceof ICustomMissileRender) {
                GL11.glTranslatef(0f, ((ICustomMissileRender) cart.getCargoMissile()).getRenderHeightOffset(),
                        0f);
            }
            renderMissile(cart.getCargoMissile(), ForgeDirection.EAST, ForgeDirection.UP);
        }

        GL11.glPopMatrix();
    } else {
        float halfWidth = cart.width / 2.0F;
        float halfLength = cart.length / 2.0F;
        float yaw = (float) Math.abs(MathUtility.clampAngleTo180(cart.rotationYaw));
        if (yaw >= 45 && yaw <= 135) {
            halfWidth = cart.length / 2.0F;
            halfLength = cart.width / 2.0F;
        }
        AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(-(double) halfWidth, 0, -(double) halfLength,

                +(double) halfWidth, 0.3, +(double) halfLength);

        GL11.glPushMatrix();
        GL11.glTranslated(xx, yy, zz);
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(Assets.GREY_FAKE_TEXTURE);
        RenderUtility.renderCube(bounds, Blocks.iron_block, Blocks.iron_block.getIcon(0, 0));

        if (cart.getCargoMissile() != null) {
            GL11.glTranslated(0, -0.1, 0);
            if (cart.getCargoMissile() instanceof ICustomMissileRender) {
                GL11.glTranslatef(0f, ((ICustomMissileRender) cart.getCargoMissile()).getRenderHeightOffset(),
                        0f);
            }
            renderMissile(cart.getCargoMissile(), ForgeDirection.EAST, ForgeDirection.UP);
        }
        GL11.glPopMatrix();
    }
    GL11.glPopMatrix();

    if (Engine.runningAsDev) {
        drawBounds(cart, xx, yy, zz);
    }
}

From source file:com.builtbroken.mc.prefab.gui.components.GuiComponentContainer.java

@Override
protected void doRender(Minecraft mc, int mouseX, int mouseY) {
    super.doRender(mc, mouseX, mouseY);
    for (GuiComponent component : getComponents()) {
        //Reset color
        GL11.glColor4f(1f, 1f, 1f, 1f);//from   w  w  w .  j a  va 2s .c o m

        GL11.glPushMatrix();
        component.drawButton(mc, mouseX, mouseY);
        GL11.glPopMatrix();
    }

    //Reset color
    GL11.glColor4f(1f, 1f, 1f, 1f);
}