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:appeng.client.gui.implementations.GuiCraftingCPU.java

License:Open Source License

@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
    String title = this.getGuiDisplayName(GuiText.CraftingStatus.getLocal());

    if (this.craftingCpu.getEstimatedTime() > 0 && !this.visual.isEmpty()) {
        final long etaInMilliseconds = TimeUnit.MILLISECONDS.convert(this.craftingCpu.getEstimatedTime(),
                TimeUnit.NANOSECONDS);
        final String etaTimeText = DurationFormatUtils.formatDuration(etaInMilliseconds,
                GuiText.ETAFormat.getLocal());
        title += " - " + etaTimeText;
    }/*  w w w . j  a  v  a2  s . com*/

    this.fontRendererObj.drawString(title, TITLE_LEFT_OFFSET, TITLE_TOP_OFFSET, TEXT_COLOR);

    int x = 0;
    int y = 0;
    final int viewStart = this.getScrollBar().getCurrentScroll() * 3;
    final int viewEnd = viewStart + 3 * 6;

    String dspToolTip = "";
    final List<String> lineList = new LinkedList<String>();
    int toolPosX = 0;
    int toolPosY = 0;

    final int offY = 23;

    final ReadableNumberConverter converter = ReadableNumberConverter.INSTANCE;
    for (int z = viewStart; z < Math.min(viewEnd, this.visual.size()); z++) {
        final IAEItemStack refStack = this.visual.get(z);// repo.getReferenceItem( z );
        if (refStack != null) {
            GL11.glPushMatrix();
            GL11.glScaled(0.5, 0.5, 0.5);

            final IAEItemStack stored = this.storage.findPrecise(refStack);
            final IAEItemStack activeStack = this.active.findPrecise(refStack);
            final IAEItemStack pendingStack = this.pending.findPrecise(refStack);

            int lines = 0;

            if (stored != null && stored.getStackSize() > 0) {
                lines++;
            }
            boolean active = false;
            if (activeStack != null && activeStack.getStackSize() > 0) {
                lines++;
                active = true;
            }
            boolean scheduled = false;
            if (pendingStack != null && pendingStack.getStackSize() > 0) {
                lines++;
                scheduled = true;
            }

            if (AEConfig.instance.useColoredCraftingStatus && (active || scheduled)) {
                final int bgColor = (active ? AEColor.Green.blackVariant : AEColor.Yellow.blackVariant)
                        | BACKGROUND_ALPHA;
                final int startX = (x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET) * 2;
                final int startY = ((y * offY + ITEMSTACK_TOP_OFFSET) - 3) * 2;
                drawRect(startX, startY, startX + (SECTION_LENGTH * 2), startY + (offY * 2) - 2, bgColor);
            }

            final int negY = ((lines - 1) * 5) / 2;
            int downY = 0;

            if (stored != null && stored.getStackSize() > 0) {
                final String str = GuiText.Stored.getLocal() + ": "
                        + converter.toWideReadableForm(stored.getStackSize());
                final int w = 4 + this.fontRendererObj.getStringWidth(str);
                this.fontRendererObj.drawString(str,
                        (int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19
                                - (w * 0.5)) * 2),
                        (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);

                if (this.tooltip == z - viewStart) {
                    lineList.add(GuiText.Stored.getLocal() + ": " + Long.toString(stored.getStackSize()));
                }

                downY += 5;
            }

            if (activeStack != null && activeStack.getStackSize() > 0) {
                final String str = GuiText.Crafting.getLocal() + ": "
                        + converter.toWideReadableForm(activeStack.getStackSize());
                final int w = 4 + this.fontRendererObj.getStringWidth(str);

                this.fontRendererObj.drawString(str,
                        (int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19
                                - (w * 0.5)) * 2),
                        (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);

                if (this.tooltip == z - viewStart) {
                    lineList.add(
                            GuiText.Crafting.getLocal() + ": " + Long.toString(activeStack.getStackSize()));
                }

                downY += 5;
            }

            if (pendingStack != null && pendingStack.getStackSize() > 0) {
                final String str = GuiText.Scheduled.getLocal() + ": "
                        + converter.toWideReadableForm(pendingStack.getStackSize());
                final int w = 4 + this.fontRendererObj.getStringWidth(str);

                this.fontRendererObj.drawString(str,
                        (int) ((x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19
                                - (w * 0.5)) * 2),
                        (y * offY + ITEMSTACK_TOP_OFFSET + 6 - negY + downY) * 2, TEXT_COLOR);

                if (this.tooltip == z - viewStart) {
                    lineList.add(
                            GuiText.Scheduled.getLocal() + ": " + Long.toString(pendingStack.getStackSize()));
                }
            }

            GL11.glPopMatrix();
            final int posX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 19;
            final int posY = y * offY + ITEMSTACK_TOP_OFFSET;

            final ItemStack is = refStack.copy().getItemStack();

            if (this.tooltip == z - viewStart) {
                dspToolTip = Platform.getItemDisplayName(is);

                if (lineList.size() > 0) {
                    dspToolTip = dspToolTip + '\n' + Joiner.on("\n").join(lineList);
                }

                toolPosX = x * (1 + SECTION_LENGTH) + ITEMSTACK_LEFT_OFFSET + SECTION_LENGTH - 8;
                toolPosY = y * offY + ITEMSTACK_TOP_OFFSET;
            }

            this.drawItem(posX, posY, is);

            x++;

            if (x > 2) {
                y++;
                x = 0;
            }
        }
    }

    if (this.tooltip >= 0 && dspToolTip.length() > 0) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        this.drawTooltip(toolPosX, toolPosY + 10, 0, dspToolTip);
        GL11.glPopAttrib();
    }
}

From source file:appeng.client.gui.implementations.GuiNetworkStatus.java

License:Open Source License

@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
    final ContainerNetworkStatus ns = (ContainerNetworkStatus) this.inventorySlots;

    this.fontRendererObj.drawString(GuiText.NetworkDetails.getLocal(), 8, 6, 4210752);

    this.fontRendererObj.drawString(
            GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong(ns.getCurrentPower(), false), 13,
            16, 4210752);/* w w w . j  a v a 2 s  .c o  m*/
    this.fontRendererObj.drawString(
            GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong(ns.getMaxPower(), false), 13, 26,
            4210752);

    this.fontRendererObj.drawString(
            GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong(ns.getAverageAddition(), true),
            13, 143 - 10, 4210752);
    this.fontRendererObj.drawString(
            GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong(ns.getPowerUsage(), true), 13,
            143 - 20, 4210752);

    final int sectionLength = 30;

    int x = 0;
    int y = 0;
    final int xo = 12;
    final int yo = 42;
    final int viewStart = 0;// myScrollBar.getCurrentScroll() * 5;
    final int viewEnd = viewStart + 5 * 4;

    String toolTip = "";
    int toolPosX = 0;
    int toolPosY = 0;

    for (int z = viewStart; z < Math.min(viewEnd, this.repo.size()); z++) {
        final IAEItemStack refStack = this.repo.getReferenceItem(z);
        if (refStack != null) {
            GL11.glPushMatrix();
            GL11.glScaled(0.5, 0.5, 0.5);

            String str = Long.toString(refStack.getStackSize());
            if (refStack.getStackSize() >= 10000) {
                str = Long.toString(refStack.getStackSize() / 1000) + 'k';
            }

            final int w = this.fontRendererObj.getStringWidth(str);
            this.fontRendererObj.drawString(str,
                    (int) ((x * sectionLength + xo + sectionLength - 19 - (w * 0.5)) * 2),
                    (y * 18 + yo + 6) * 2, 4210752);

            GL11.glPopMatrix();
            final int posX = x * sectionLength + xo + sectionLength - 18;
            final int posY = y * 18 + yo;

            if (this.tooltip == z - viewStart) {
                toolTip = Platform.getItemDisplayName(this.repo.getItem(z));

                toolTip += ('\n' + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
                if (refStack.getCountRequestable() > 0) {
                    toolTip += ('\n' + GuiText.EnergyDrain.getLocal() + ": "
                            + Platform.formatPowerLong(refStack.getCountRequestable(), true));
                }

                toolPosX = x * sectionLength + xo + sectionLength - 8;
                toolPosY = y * 18 + yo;
            }

            this.drawItem(posX, posY, this.repo.getItem(z));

            x++;

            if (x > 4) {
                y++;
                x = 0;
            }
        }
    }

    if (this.tooltip >= 0 && toolTip.length() > 0) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        this.drawTooltip(toolPosX, toolPosY + 10, 0, toolTip);
        GL11.glPopAttrib();
    }
}

From source file:appeng.client.gui.widgets.GuiImgButton.java

License:Open Source License

@Override
public void drawButton(final Minecraft par1Minecraft, final int par2, final int par3) {
    if (this.visible) {
        final int iconIndex = this.getIconIndex();

        if (this.halfSize) {
            this.width = 8;
            this.height = 8;

            GL11.glPushMatrix();
            GL11.glTranslatef(this.xPosition, this.yPosition, 0.0F);
            GL11.glScalef(0.5f, 0.5f, 0.5f);

            if (this.enabled) {
                GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            } else {
                GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
            }/*from  w w w. j a v  a 2s . c  o  m*/

            par1Minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png"));
            this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
                    && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;

            final int uv_y = (int) Math.floor(iconIndex / 16);
            final int uv_x = iconIndex - uv_y * 16;

            this.drawTexturedModalRect(0, 0, 256 - 16, 256 - 16, 16, 16);
            this.drawTexturedModalRect(0, 0, uv_x * 16, uv_y * 16, 16, 16);
            this.mouseDragged(par1Minecraft, par2, par3);

            GL11.glPopMatrix();
        } else {
            if (this.enabled) {
                GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            } else {
                GL11.glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
            }

            par1Minecraft.renderEngine.bindTexture(ExtraBlockTextures.GuiTexture("guis/states.png"));
            this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition
                    && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;

            final int uv_y = (int) Math.floor(iconIndex / 16);
            final int uv_x = iconIndex - uv_y * 16;

            this.drawTexturedModalRect(this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16);
            this.drawTexturedModalRect(this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16);
            this.mouseDragged(par1Minecraft, par2, par3);
        }
    }
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}

From source file:appeng.client.render.AppEngRenderItem.java

License:Open Source License

@Override
public void renderItemOverlayIntoGUI(final FontRenderer fontRenderer, final TextureManager textureManager,
        final ItemStack is, final int par4, final int par5, final String par6Str) {
    if (is != null) {
        final float scaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f;
        final float inverseScaleFactor = 1.0f / scaleFactor;
        final int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1;

        final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
        fontRenderer.setUnicodeFlag(false);

        if (is.getItem().showDurabilityBar(is)) {
            final double health = is.getItem().getDurabilityForDisplay(is);
            final int j1 = (int) Math.round(13.0D - health * 13.0D);
            final int k = (int) Math.round(255.0D - health * 255.0D);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_ALPHA_TEST);
            GL11.glDisable(GL11.GL_BLEND);
            final Tessellator tessellator = Tessellator.instance;
            final int l = 255 - k << 16 | k << 8;
            final int i1 = (255 - k) / 4 << 16 | 16128;
            this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0);
            this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, i1);
            this.renderQuad(tessellator, par4 + 2, par5 + 13, j1, 1, l);
            GL11.glEnable(GL11.GL_ALPHA_TEST);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_DEPTH_TEST);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        }//from   www.  ja  v a  2 s. c  o  m

        if (is.stackSize == 0) {
            final String craftLabelText = AEConfig.instance.useTerminalUseLargeFont()
                    ? GuiText.LargeFontCraft.getLocal()
                    : GuiText.SmallFontCraft.getLocal();
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glPushMatrix();
            GL11.glScaled(scaleFactor, scaleFactor, scaleFactor);
            final int X = (int) (((float) par4 + offset + 16.0f
                    - fontRenderer.getStringWidth(craftLabelText) * scaleFactor) * inverseScaleFactor);
            final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor);
            fontRenderer.drawStringWithShadow(craftLabelText, X, Y, 16777215);
            GL11.glPopMatrix();
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_DEPTH_TEST);
        }

        final long amount = this.aeStack != null ? this.aeStack.getStackSize() : is.stackSize;
        if (amount != 0) {
            final String stackSize = this.getToBeRenderedStackSize(amount);

            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glPushMatrix();
            GL11.glScaled(scaleFactor, scaleFactor, scaleFactor);
            final int X = (int) (((float) par4 + offset + 16.0f
                    - fontRenderer.getStringWidth(stackSize) * scaleFactor) * inverseScaleFactor);
            final int Y = (int) (((float) par5 + offset + 16.0f - 7.0f * scaleFactor) * inverseScaleFactor);
            fontRenderer.drawStringWithShadow(stackSize, X, Y, 16777215);
            GL11.glPopMatrix();
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_DEPTH_TEST);
        }

        fontRenderer.setUnicodeFlag(unicodeFlag);
    }
}

From source file:appeng.client.render.BaseBlockRender.java

License:Open Source License

public void doRenderItem(final ItemStack itemstack, final TileEntity par1EntityItemFrame) {
    if (itemstack != null) {
        final EntityItem entityitem = new EntityItem(par1EntityItemFrame.getWorldObj(), 0.0D, 0.0D, 0.0D,
                itemstack);/*from  w  ww  .  ja  v a  2 s  . c o  m*/
        entityitem.getEntityItem().stackSize = 1;

        // set all this stuff and then do shit? meh?
        entityitem.hoverStart = 0;
        entityitem.age = 0;
        entityitem.rotationYaw = 0;

        GL11.glPushMatrix();
        GL11.glTranslatef(0, -0.14F, 0);

        RenderItem.renderInFrame = true;
        RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
        RenderItem.renderInFrame = false;

        GL11.glPopMatrix();
    }
}

From source file:appeng.client.render.blocks.RenderBlockCharger.java

License:Open Source License

@Override
public void renderTile(final BlockCharger block, final TileCharger tile, final Tessellator tess, final double x,
        final double y, final double z, final float f, final RenderBlocks renderer) {
    final ItemStack sis = tile.getStackInSlot(0);

    if (sis != null) {
        GL11.glPushMatrix();
        this.applyTESRRotation(x, y, z, tile.getForward(), tile.getUp());

        try {//from w ww .  j  a va  2 s  .c om
            GL11.glTranslatef(0.5f, 0.45f, 0.5f);
            GL11.glScalef(1.0f / 1.1f, 1.0f / 1.1f, 1.0f / 1.1f);
            GL11.glScalef(1.0f, 1.0f, 1.0f);

            final Block blk = Block.getBlockFromItem(sis.getItem());
            if (sis.getItemSpriteNumber() == 0 && block != null
                    && RenderBlocks.renderItemIn3d(blk.getRenderType())) {
                GL11.glRotatef(25.0f, 1.0f, 0.0f, 0.0f);
                GL11.glRotatef(15.0f, 0.0f, 1.0f, 0.0f);
                GL11.glRotatef(30.0f, 0.0f, 1.0f, 0.0f);
            }

            // << 20 | light << 4;
            final int br = tile.getWorldObj().getLightBrightnessForSkyBlocks(tile.xCoord, tile.yCoord,
                    tile.zCoord, 0);
            final int var11 = br % 65536;
            final int var12 = br / 65536;

            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11, var12);

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

            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            tess.setColorOpaque_F(1.0f, 1.0f, 1.0f);

            this.doRenderItem(sis, tile);
        } catch (final Exception err) {
            AELog.error(err);
        }

        GL11.glPopMatrix();
    }
}

From source file:appeng.client.render.blocks.RenderBlockCraftingCPUMonitor.java

License:Open Source License

@Override
public void renderTile(final BlockCraftingMonitor block, final TileCraftingMonitorTile tile,
        final Tessellator tess, final double x, final double y, final double z, final float f,
        final RenderBlocks renderer) {
    if (tile != null) {
        final IAEItemStack ais = tile.getJobProgress();

        if (tile.getDisplayList() == null) {
            tile.setUpdateList(true);//w ww  .j  a  v a 2  s .  c  o  m
            tile.setDisplayList(GLAllocation.generateDisplayLists(1));
        }

        if (ais != null) {
            GL11.glPushMatrix();
            GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);

            if (tile.isUpdateList()) {
                tile.setUpdateList(false);
                GL11.glNewList(tile.getDisplayList(), GL11.GL_COMPILE_AND_EXECUTE);
                this.tesrRenderScreen(tess, tile, ais);
                GL11.glEndList();
            } else {
                GL11.glCallList(tile.getDisplayList());
            }

            GL11.glPopMatrix();
        }
    }
}

From source file:appeng.client.render.blocks.RenderBlockCraftingCPUMonitor.java

License:Open Source License

private void tesrRenderScreen(final Tessellator tess, final TileCraftingMonitorTile cmt,
        final IAEItemStack ais) {
    final ForgeDirection side = cmt.getForward();

    ForgeDirection walrus = side.offsetY != 0 ? ForgeDirection.SOUTH : ForgeDirection.UP;
    int spin = 0;

    int max = 5;//from ww  w .  j  a  v a  2s  .  co m
    while (walrus != cmt.getUp() && max > 0) {
        max--;
        spin++;
        walrus = Platform.rotateAround(walrus, side);
    }
    max--;

    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glTranslated(side.offsetX * 0.69, side.offsetY * 0.69, side.offsetZ * 0.69);

    final float scale = 0.7f;
    GL11.glScalef(scale, scale, scale);

    if (side == ForgeDirection.UP) {
        GL11.glScalef(1.0f, -1.0f, 1.0f);
        GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
        GL11.glRotatef(spin * 90.0F, 0, 0, 1);
    }

    if (side == ForgeDirection.DOWN) {
        GL11.glScalef(1.0f, -1.0f, 1.0f);
        GL11.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
        GL11.glRotatef(spin * -90.0F, 0, 0, 1);
    }

    if (side == ForgeDirection.EAST) {
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
    }

    if (side == ForgeDirection.WEST) {
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
    }

    if (side == ForgeDirection.NORTH) {
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
    }

    if (side == ForgeDirection.SOUTH) {
        GL11.glScalef(-1.0f, -1.0f, -1.0f);
        GL11.glRotatef(180.0f, 0.0f, 1.0f, 0.0f);
    }

    GL11.glPushMatrix();
    try {
        final ItemStack sis = ais.getItemStack();
        sis.stackSize = 1;

        final int br = 16 << 20 | 16 << 4;
        final int var11 = br % 65536;
        final int var12 = br / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * 0.8F, var12 * 0.8F);

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

        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        // RenderHelper.enableGUIStandardItemLighting();
        tess.setColorOpaque_F(1.0f, 1.0f, 1.0f);

        ClientHelper.proxy.doRenderItem(sis, cmt.getWorldObj());
    } catch (final Exception e) {
        AELog.error(e);
    }

    GL11.glPopMatrix();

    GL11.glTranslatef(0.0f, 0.14f, -0.24f);
    GL11.glScalef(1.0f / 62.0f, 1.0f / 62.0f, 1.0f / 62.0f);

    final long stackSize = ais.getStackSize();
    final String renderedStackSize = NUMBER_CONVERTER.toWideReadableForm(stackSize);

    final FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
    final int width = fr.getStringWidth(renderedStackSize);
    GL11.glTranslatef(-0.5f * width, 0.0f, -1.0f);
    fr.drawString(renderedStackSize, 0, 0, 0);

    GL11.glPopAttrib();
}

From source file:appeng.client.render.blocks.RenderBlockInscriber.java

License:Open Source License

@Override
public void renderTile(final BlockInscriber block, final TileInscriber tile, final Tessellator tess,
        final double x, final double y, final double z, final float f, final RenderBlocks renderer) {
    GL11.glPushMatrix();
    this.applyTESRRotation(x, y, z, tile.getForward(), tile.getUp());

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_LIGHTING);/*from   w ww .  j ava  2 s .co m*/
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);

    // render sides of stamps
    GL11.glCullFace(GL11.GL_FRONT);

    final Minecraft mc = Minecraft.getMinecraft();
    mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);

    // << 20 | light << 4;
    final int br = tile.getWorldObj().getLightBrightnessForSkyBlocks(tile.xCoord, tile.yCoord, tile.zCoord, 0);
    final int var11 = br % 65536;
    final int var12 = br / 65536;

    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11, var12);

    long absoluteProgress = 0;

    if (tile.isSmash()) {
        final long currentTime = System.currentTimeMillis();
        absoluteProgress = currentTime - tile.getClientStart();
        if (absoluteProgress > 800) {
            tile.setSmash(false);
        }
    }

    final float relativeProgress = absoluteProgress % 800 / 400.0f;
    float progress = relativeProgress;

    if (progress > 1.0f) {
        progress = 1.0f - (progress - 1.0f);
    }
    float press = 0.2f;
    press -= progress / 5.0f;

    final IIcon ic = ExtraBlockTextures.BlockInscriberInside.getIcon();
    tess.startDrawingQuads();

    float middle = 0.5f;
    middle += 0.02f;
    final float TwoPx = 2.0f / 16.0f;
    tess.addVertexWithUV(TwoPx, middle + press, TwoPx, ic.getInterpolatedU(2), ic.getInterpolatedV(2));
    tess.addVertexWithUV(1.0 - TwoPx, middle + press, TwoPx, ic.getInterpolatedU(14), ic.getInterpolatedV(2));
    tess.addVertexWithUV(1.0 - TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU(14),
            ic.getInterpolatedV(13));
    tess.addVertexWithUV(TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU(2), ic.getInterpolatedV(13));

    tess.addVertexWithUV(TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU(2), ic.getInterpolatedV(3));
    tess.addVertexWithUV(1.0 - TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU(14),
            ic.getInterpolatedV(3));
    final float base = 0.4f;
    tess.addVertexWithUV(1.0 - TwoPx, middle + base, 1.0 - TwoPx, ic.getInterpolatedU(14),
            ic.getInterpolatedV(3 - 16 * (press - base)));
    tess.addVertexWithUV(TwoPx, middle + base, 1.0 - TwoPx, ic.getInterpolatedU(2),
            ic.getInterpolatedV(3 - 16 * (press - base)));

    middle -= 2.0f * 0.02f;
    tess.addVertexWithUV(1.0 - TwoPx, middle - press, TwoPx, ic.getInterpolatedU(2), ic.getInterpolatedV(2));
    tess.addVertexWithUV(TwoPx, middle - press, TwoPx, ic.getInterpolatedU(14), ic.getInterpolatedV(2));
    tess.addVertexWithUV(TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU(14), ic.getInterpolatedV(13));
    tess.addVertexWithUV(1.0 - TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU(2),
            ic.getInterpolatedV(13));

    tess.addVertexWithUV(1.0 - TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU(2),
            ic.getInterpolatedV(3));
    tess.addVertexWithUV(TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU(14), ic.getInterpolatedV(3));
    tess.addVertexWithUV(TwoPx, middle - base, 1.0 - TwoPx, ic.getInterpolatedU(14),
            ic.getInterpolatedV(3 - 16 * (press - base)));
    tess.addVertexWithUV(1.0 - TwoPx, middle + -base, 1.0 - TwoPx, ic.getInterpolatedU(2),
            ic.getInterpolatedV(3 - 16 * (press - base)));

    tess.draw();

    GL11.glCullFace(GL11.GL_BACK);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();

    int items = 0;
    if (tile.getStackInSlot(0) != null) {
        items++;
    }
    if (tile.getStackInSlot(1) != null) {
        items++;
    }
    if (tile.getStackInSlot(2) != null) {
        items++;
    }

    if (relativeProgress > 1.0f || items == 0) {
        ItemStack is = tile.getStackInSlot(3);

        if (is == null) {
            final IInscriberRecipe ir = tile.getTask();
            if (ir != null) {
                is = ir.getOutput().copy();
            }
        }

        this.renderItem(is, 0.0f, block, tile, tess, x, y, z, f, renderer);
    } else {
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);

        this.renderItem(tile.getStackInSlot(0), press, block, tile, tess, x, y, z, f, renderer);
        this.renderItem(tile.getStackInSlot(1), -press, block, tile, tess, x, y, z, f, renderer);
        this.renderItem(tile.getStackInSlot(2), 0.0f, block, tile, tess, x, y, z, f, renderer);

        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    }
}

From source file:appeng.client.render.blocks.RenderBlockInscriber.java

License:Open Source License

private void renderItem(ItemStack sis, final float o, final AEBaseBlock block, final AEBaseTile tile,
        final Tessellator tess, final double x, final double y, final double z, final float f,
        final RenderBlocks renderer) {
    if (sis != null) {
        sis = sis.copy();//w  w  w .jav  a 2  s  . c  o  m
        GL11.glPushMatrix();
        // fix to inscriber
        this.applyTESRRotation(x, y, z, tile.getForward(), tile.getUp());

        try {
            // move to center
            GL11.glTranslatef(0.5f, 0.5f + o, 0.5f);

            // set scale
            GL11.glScalef(ITEM_RENDER_SCALE, ITEM_RENDER_SCALE, ITEM_RENDER_SCALE);
            GL11.glScalef(1.0f, 1.0f, 1.0f);

            final Block blk = Block.getBlockFromItem(sis.getItem());

            // is a block
            if (sis.getItemSpriteNumber() == 0 && block != null
                    && RenderBlocks.renderItemIn3d(blk.getRenderType())) {
                // rotate block in angle to make it more plastic
                GL11.glRotatef(25.0f, 1.0f, 0.0f, 0.0f);
                GL11.glRotatef(15.0f, 0.0f, 1.0f, 0.0f);
                GL11.glRotatef(30.0f, 0.0f, 1.0f, 0.0f);
            }

            GL11.glRotatef(90.0f, 1, 0, 0);

            // << 20 | light << 4;
            final int br = tile.getWorldObj().getLightBrightnessForSkyBlocks(tile.xCoord, tile.yCoord,
                    tile.zCoord, 0);
            final int var11 = br % 65536;
            final int var12 = br / 65536;

            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11, var12);

            tess.setColorOpaque_F(1.0f, 1.0f, 1.0f);

            this.doRenderItem(sis, tile);
        } catch (final Exception err) {
            AELog.error(err);
        }

        GL11.glPopMatrix();
    }
}