List of usage examples for org.lwjgl.opengl GL11 glPopAttrib
public static native void glPopAttrib();
From source file:$.DrawSystem.java
License:Open Source License
@Override protected void processEntities(ImmutableBag<Entity> entities) { GL11.glClearColor(0.1f, 0, 0, 1f); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); List<Entity> entititesSortedByZ = new ArrayList<>(entities.size()); for (int i = 0, n = entities.size(); i < n; ++i) { final Entity e = entities.get(i); if (e.isEnabled()) { entititesSortedByZ.add(e); }// w w w .j a va 2s . c o m } Collections.sort(entititesSortedByZ, zComparator); GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_TRANSFORM_BIT | GL11.GL_HINT_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_SCISSOR_BIT | GL11.GL_LINE_BIT | GL11.GL_TEXTURE_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glLoadIdentity(); updateViewPort(); GL11.glViewport(viewPort.x, viewPort.y, viewPort.width, viewPort.height); GLU.gluOrtho2D(-toolkit.getVirtualResolutionWidth() / 2.0f, toolkit.getVirtualResolutionWidth() / 2.0f, toolkit.getVirtualResolutionHeight() / 2.0f, -toolkit.getVirtualResolutionHeight() / 2.0f); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); Game game = (Game) world; Entity hero = game.getHero(); if (null != hero) { Sprite heroSprite = spriteMapper.get(hero); Vector heroPos = spriteProjector.project(heroSprite.getPosition()); GL11.glTranslatef(-heroPos.x, -heroPos.y, 0.0f); } for (Entity e : entititesSortedByZ) { MainMenu mainMenu = mainMenuMapper.getSafe(e); if (null != mainMenu) { mainMenu.draw(); } DialogueComponent dialog = dialogMapper.getSafe(e); if (null != dialog) { dialog.draw(); } Level level = levelMapper.getSafe(e); if (null != level) { drawLevel(level); } Sprite sprite = spriteMapper.getSafe(e); if (null != sprite) { drawSprite(sprite); } } GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glPopAttrib(); }
From source file:appeng.client.gui.implementations.GuiCraftConfirm.java
License:Open Source License
@Override public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) { final long BytesUsed = this.ccc.getUsedBytes(); final String byteUsed = NumberFormat.getInstance().format(BytesUsed); final String Add = BytesUsed > 0 ? (byteUsed + ' ' + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal(); this.fontRendererObj.drawString(GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752); String dsp = null;//w ww . j a va2 s .c o m if (this.isSimulation()) { dsp = GuiText.Simulation.getLocal(); } else { dsp = this.ccc.getCpuAvailableBytes() > 0 ? (GuiText.Bytes.getLocal() + ": " + this.ccc.getCpuAvailableBytes() + " : " + GuiText.CoProcessors.getLocal() + ": " + this.ccc.getCpuCoProcessors()) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; } final int offset = (219 - this.fontRendererObj.getStringWidth(dsp)) / 2; this.fontRendererObj.drawString(dsp, offset, 165, 4210752); final int sectionLength = 67; int x = 0; int y = 0; final int xo = 9; final int yo = 22; final int viewStart = this.getScrollBar().getCurrentScroll() * 3; final int viewEnd = viewStart + 3 * this.rows; String dspToolTip = ""; final List<String> lineList = new LinkedList<String>(); int toolPosX = 0; int toolPosY = 0; final int offY = 23; 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 pendingStack = this.pending.findPrecise(refStack); final IAEItemStack missingStack = this.missing.findPrecise(refStack); int lines = 0; if (stored != null && stored.getStackSize() > 0) { lines++; } if (pendingStack != null && pendingStack.getStackSize() > 0) { lines++; } if (pendingStack != null && pendingStack.getStackSize() > 0) { lines++; } final int negY = ((lines - 1) * 5) / 2; int downY = 0; if (stored != null && stored.getStackSize() > 0) { String str = Long.toString(stored.getStackSize()); if (stored.getStackSize() >= 10000) { str = Long.toString(stored.getStackSize() / 1000) + 'k'; } if (stored.getStackSize() >= 10000000) { str = Long.toString(stored.getStackSize() / 1000000) + 'm'; } str = GuiText.FromStorage.getLocal() + ": " + str; final int w = 4 + this.fontRendererObj.getStringWidth(str); this.fontRendererObj.drawString(str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo + 6 - negY + downY) * 2, 4210752); if (this.tooltip == z - viewStart) { lineList.add(GuiText.FromStorage.getLocal() + ": " + Long.toString(stored.getStackSize())); } downY += 5; } boolean red = false; if (missingStack != null && missingStack.getStackSize() > 0) { String str = Long.toString(missingStack.getStackSize()); if (missingStack.getStackSize() >= 10000) { str = Long.toString(missingStack.getStackSize() / 1000) + 'k'; } if (missingStack.getStackSize() >= 10000000) { str = Long.toString(missingStack.getStackSize() / 1000000) + 'm'; } str = GuiText.Missing.getLocal() + ": " + str; final int w = 4 + this.fontRendererObj.getStringWidth(str); this.fontRendererObj.drawString(str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo + 6 - negY + downY) * 2, 4210752); if (this.tooltip == z - viewStart) { lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString(missingStack.getStackSize())); } red = true; downY += 5; } if (pendingStack != null && pendingStack.getStackSize() > 0) { String str = Long.toString(pendingStack.getStackSize()); if (pendingStack.getStackSize() >= 10000) { str = Long.toString(pendingStack.getStackSize() / 1000) + 'k'; } if (pendingStack.getStackSize() >= 10000000) { str = Long.toString(pendingStack.getStackSize() / 1000000) + 'm'; } str = GuiText.ToCraft.getLocal() + ": " + str; final int w = 4 + this.fontRendererObj.getStringWidth(str); this.fontRendererObj.drawString(str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - (w * 0.5)) * 2), (y * offY + yo + 6 - negY + downY) * 2, 4210752); if (this.tooltip == z - viewStart) { lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString(pendingStack.getStackSize())); } } GL11.glPopMatrix(); final int posX = x * (1 + sectionLength) + xo + sectionLength - 19; final int posY = y * offY + yo; 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 + sectionLength) + xo + sectionLength - 8; toolPosY = y * offY + yo; } this.drawItem(posX, posY, is); if (red) { final int startX = x * (1 + sectionLength) + xo; final int startY = posY - 4; drawRect(startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000); } 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.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; }/*from w w w . j a v a 2 s. c om*/ 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 av a 2 s .com*/ 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.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;//w w w. ja va 2 s.com 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.BusRenderer.java
License:Open Source License
@Override public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) { if (item == null) { return;// ww w. j a v a 2s . c o m } GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LIGHTING); if (AEConfig.instance.isFeatureEnabled(AEFeature.AlphaPass) && item.getItem() instanceof IAlphaPassItem && ((IAlphaPassItem) item.getItem()).useAlphaPass(item)) { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_BLEND); } else { GL11.glAlphaFunc(GL11.GL_GREATER, 0.4f); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); } if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(-0.2f, -0.1f, -0.3f); } if (type == ItemRenderType.ENTITY) { GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f); GL11.glScalef(0.8f, 0.8f, 0.8f); GL11.glTranslatef(-0.8f, -0.87f, -0.7f); } if (type == ItemRenderType.INVENTORY) { GL11.glTranslatef(0.0f, -0.1f, 0.0f); } GL11.glTranslated(0.2, 0.3, 0.1); GL11.glScaled(1.2, 1.2, 1.); GL11.glColor4f(1, 1, 1, 1); Tessellator.instance.setColorOpaque_F(1, 1, 1); Tessellator.instance.setBrightness(14 << 20 | 14 << 4); BusRenderHelper.INSTANCE.setBounds(0, 0, 0, 1, 1, 1); BusRenderHelper.INSTANCE.setTexture(null); BusRenderHelper.INSTANCE.setInvColor(0xffffff); this.getRenderer().blockAccess = ClientHelper.proxy.getWorld(); BusRenderHelper.INSTANCE.setOrientation(ForgeDirection.EAST, ForgeDirection.UP, ForgeDirection.SOUTH); this.getRenderer().uvRotateBottom = this.getRenderer().uvRotateEast = this .getRenderer().uvRotateNorth = this.getRenderer().uvRotateSouth = this .getRenderer().uvRotateTop = this.getRenderer().uvRotateWest = 0; this.getRenderer().useInventoryTint = false; this.getRenderer().overrideBlockTexture = null; if (item.getItem() instanceof IFacadeItem) { final IFacadeItem fi = (IFacadeItem) item.getItem(); final IFacadePart fp = fi.createPartFromItemStack(item, ForgeDirection.SOUTH); if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glRotatef(160.0f, 0.0f, 1.0f, 0.0f); GL11.glTranslated(-0.4, 0.1, -1.6); } if (fp != null) { fp.renderInventory(BusRenderHelper.INSTANCE, this.getRenderer()); } } else { final IPart ip = this.getRenderer(item, (IPartItem) item.getItem()); if (ip != null) { if (type == ItemRenderType.ENTITY) { final int depth = ip.cableConnectionRenderTo(); GL11.glTranslatef(0.0f, 0.0f, -0.04f * (8 - depth) - 0.06f); } ip.renderInventory(BusRenderHelper.INSTANCE, this.getRenderer()); } } this.getRenderer().uvRotateBottom = this.getRenderer().uvRotateEast = this .getRenderer().uvRotateNorth = this.getRenderer().uvRotateSouth = this .getRenderer().uvRotateTop = this.getRenderer().uvRotateWest = 0; GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:appeng.client.render.ItemRenderer.java
License:Open Source License
@Override public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) { GL11.glPushMatrix();/*from w ww. j a v a 2 s .c o m*/ GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); if (type == ItemRenderType.ENTITY) { GL11.glTranslatef(-0.5f, -0.5f, -0.5f); } if (type == ItemRenderType.INVENTORY) { GL11.glTranslatef(0.0f, -0.1f, 0.0f); } WorldRender.INSTANCE.renderItemBlock(item, type, data); GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:appeng.client.render.items.ItemEncodedPatternRenderer.java
License:Open Source License
@Override public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) { this.recursive = true; final ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem(); final ItemStack is = iep.getOutput(item); final Minecraft mc = Minecraft.getMinecraft(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); RenderHelper.enableGUIStandardItemLighting(); this.ri.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.getTextureManager(), is, 0, 0); RenderHelper.disableStandardItemLighting(); GL11.glPopAttrib(); this.recursive = false; }
From source file:appeng.client.render.items.PaintBallRender.java
License:Open Source License
@Override public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) { IIcon par2Icon = item.getIconIndex(); if (item.getItemDamage() >= 20) { par2Icon = ExtraItemTextures.ItemPaintBallShimmer.getIcon(); }// w ww .j ava 2 s.c o m final float f4 = par2Icon.getMinU(); final float f5 = par2Icon.getMaxU(); final float f6 = par2Icon.getMinV(); final float f7 = par2Icon.getMaxV(); final ItemPaintBall ipb = (ItemPaintBall) item.getItem(); final Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix(); GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); final AEColor col = ipb.getColor(item); final int colorValue = item.getItemDamage() >= 20 ? col.mediumVariant : col.mediumVariant; final int r = (colorValue >> 16) & 0xff; final int g = (colorValue >> 8) & 0xff; final int b = (colorValue) & 0xff; if (item.getItemDamage() >= 20) { final float fail = 0.7f; final int full = (int) (255 * 0.3); GL11.glColor4ub((byte) (full + r * fail), (byte) (full + g * fail), (byte) (full + b * fail), (byte) 255); } else { GL11.glColor4ub((byte) r, (byte) g, (byte) b, (byte) 255); } if (type == ItemRenderType.INVENTORY) { GL11.glScalef(16F, 16F, 10F); GL11.glTranslatef(0.0F, 1.0F, 0.0F); GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); tessellator.addVertexWithUV(0, 0, 0, f4, f7); tessellator.addVertexWithUV(1, 0, 0, f5, f7); tessellator.addVertexWithUV(1, 1, 0, f5, f6); tessellator.addVertexWithUV(0, 1, 0, f4, f6); tessellator.draw(); } else { if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.0F, 0.0F, 0.0F); } else { GL11.glTranslatef(-0.5F, -0.3F, 0.01F); } final float f12 = 0.0625F; ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(), par2Icon.getIconHeight(), f12); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glColor4f(1, 1, 1, 1.0F); GL11.glScalef(1F, 1.1F, 1F); GL11.glTranslatef(0.0F, 1.07F, f12 / -2.0f); GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); } GL11.glColor4f(1, 1, 1, 1.0F); GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:appeng.client.render.items.ToolBiometricCardRender.java
License:Open Source License
@Override public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) { final IIcon par2Icon = item.getIconIndex(); final float f4 = par2Icon.getMinU(); final float f5 = par2Icon.getMaxU(); final float f6 = par2Icon.getMinV(); final float f7 = par2Icon.getMaxV(); final Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix();//from w w w . j a va2 s . c o m GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); if (type == ItemRenderType.INVENTORY) { GL11.glColor4f(1, 1, 1, 1.0F); GL11.glScalef(16F, 16F, 10F); GL11.glTranslatef(0.0F, 1.0F, 0.0F); GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); GL11.glEnable(GL11.GL_ALPHA_TEST); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); tessellator.addVertexWithUV(0, 0, 0, f4, f7); tessellator.addVertexWithUV(1, 0, 0, f5, f7); tessellator.addVertexWithUV(1, 1, 0, f5, f6); tessellator.addVertexWithUV(0, 1, 0, f4, f6); tessellator.draw(); } else { GL11.glTranslatef(-0.5F, -0.3F, 0.01F); final float f12 = 0.0625F; ItemRenderer.renderItemIn2D(tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(), par2Icon.getIconHeight(), f12); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glColor4f(1, 1, 1, 1.0F); GL11.glScalef(1F, 1.1F, 1F); GL11.glTranslatef(0.0F, 1.07F, f12 / -2.0f); GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); } final float u = ExtraItemTextures.White.getIcon().getInterpolatedU(8.1); final float v = ExtraItemTextures.White.getIcon().getInterpolatedV(8.1); String username = ""; if (item.getItem() instanceof IBiometricCard) { final GameProfile gp = ((IBiometricCard) item.getItem()).getProfile(item); if (gp != null) { username = gp.getName(); } } final int hash = username.length() > 0 ? username.hashCode() : 0; GL11.glScalef(1F / 16F, 1F / 16F, 1F); GL11.glTranslatef(4, 6, 0); GL11.glDisable(GL11.GL_LIGHTING); tessellator.startDrawingQuads(); AEColor col = AEColor.values()[Math.abs(3 + hash) % AEColor.values().length]; if (hash == 0) { col = AEColor.Black; } final float z = 0; for (int x = 0; x < 8; x++)// 8 { for (int y = 0; y < 6; y++)// 6 { boolean isLit = false; if (x == 0 || y == 0 || x == 7 || y == 5) { isLit = false; } else { isLit = (hash & (1 << x)) != 0 || (hash & (1 << y)) != 0; } if (isLit) { tessellator.setColorOpaque_I(col.mediumVariant); } else { final float scale = 0.3f / 255.0f; tessellator.setColorOpaque_F(((col.blackVariant >> 16) & 0xff) * scale, ((col.blackVariant >> 8) & 0xff) * scale, (col.blackVariant & 0xff) * scale); } tessellator.addVertexWithUV(x, y, z, u, v); tessellator.addVertexWithUV(x + 1, y, z, u, v); tessellator.addVertexWithUV(x + 1, y + 1, z, u, v); tessellator.addVertexWithUV(x, y + 1, z, u, v); } } tessellator.draw(); GL11.glPopAttrib(); GL11.glPopMatrix(); }