List of usage examples for org.lwjgl.opengl GL11 glEnable
public static void glEnable(@NativeType("GLenum") int target)
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();/*w ww .jav a 2 s . c o m*/ this.applyTESRRotation(x, y, z, tile.getForward(), tile.getUp()); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); 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.RenderBlockSkyChest.java
License:Open Source License
@Override public void renderInventory(final BlockSkyChest blk, final ItemStack is, final RenderBlocks renderer, final ItemRenderType type, final Object[] obj) { GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); final int metaData = is.getItemDamage(); final ResourceLocation loc = METADATA_TO_TEXTURE[metaData]; Minecraft.getMinecraft().getTextureManager().bindTexture(loc); GL11.glScalef(1.0F, -1F, -1F);//ww w . java 2 s . c o m GL11.glTranslatef(-0.0F, -1.0F, -1.0F); this.model.chestLid.offsetY = -(0.9f / 16.0f); final float lidAngle = 0.0f; this.model.chestLid.rotateAngleX = -((lidAngle * 3.141593F) / 2.0F); this.model.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }
From source file:appeng.client.render.blocks.RenderBlockSkyChest.java
License:Open Source License
@Override public void renderTile(final BlockSkyChest block, final TileSkyChest skyChest, final Tessellator tess, final double x, final double y, final double z, final float partialTick, final RenderBlocks renderer) { if (skyChest == null) { return;/* ww w . j a v a 2 s . co m*/ } if (!skyChest.hasWorldObj()) { return; } GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); final int metaData = skyChest.getWorldObj().getBlockMetadata(skyChest.xCoord, skyChest.yCoord, skyChest.zCoord); final ResourceLocation loc = METADATA_TO_TEXTURE[metaData]; Minecraft.getMinecraft().getTextureManager().bindTexture(loc); this.applyTESRRotation(x, y, z, skyChest.getForward(), skyChest.getUp()); GL11.glScalef(1.0F, -1F, -1F); GL11.glTranslatef(-0.0F, -1.0F, -1.0F); final long now = System.currentTimeMillis(); final long distance = now - skyChest.getLastEvent(); if (skyChest.getPlayerOpen() > 0) { skyChest.setLidAngle(skyChest.getLidAngle() + distance * 0.0001f); } else { skyChest.setLidAngle(skyChest.getLidAngle() - distance * 0.0001f); } if (skyChest.getLidAngle() > 0.5f) { skyChest.setLidAngle(0.5f); } if (skyChest.getLidAngle() < 0.0f) { skyChest.setLidAngle(0.0f); } float lidAngle = skyChest.getLidAngle(); lidAngle = 1.0F - lidAngle; lidAngle = 1.0F - lidAngle * lidAngle * lidAngle; this.model.chestLid.offsetY = -(1.01f / 16.0f); this.model.chestLid.rotateAngleX = -((lidAngle * 3.141593F) / 2.0F); // The vanilla chests wants culling reversed... GL11.glCullFace(GL11.GL_FRONT); this.model.renderAll(); GL11.glCullFace(GL11.GL_BACK); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }
From source file:appeng.client.render.blocks.RenderBlockSkyCompass.java
License:Open Source License
@Override public void renderInventory(final BlockSkyCompass blk, final ItemStack is, final RenderBlocks renderer, ItemRenderType type, final Object[] obj) { if (type == ItemRenderType.INVENTORY) { boolean isGood = false; final IInventory inv = Minecraft.getMinecraft().thePlayer.inventory; for (int x = 0; x < inv.getSizeInventory(); x++) { if (inv.getStackInSlot(x) == is) { isGood = true;/* w w w. j a va 2 s. c o m*/ } } if (!isGood) { type = ItemRenderType.FIRST_PERSON_MAP; } } GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); final ResourceLocation loc = new ResourceLocation("appliedenergistics2", "textures/models/compass.png"); Minecraft.getMinecraft().getTextureManager().bindTexture(loc); if (type == ItemRenderType.ENTITY) { GL11.glRotatef(-90.0f, 0.0f, 0.0f, 1.0f); GL11.glScalef(1.0F, -1F, -1F); GL11.glScalef(2.5f, 2.5f, 2.5f); GL11.glTranslatef(-0.25F, -1.65F, -0.19F); } else { if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glRotatef(15.3f, 0.0f, 0.0f, 1.0f); } GL11.glScalef(1.0F, -1F, -1F); GL11.glScalef(2.5f, 2.5f, 2.5f); if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.3F, -1.65F, -0.19F); } else { GL11.glTranslatef(0.2F, -1.65F, -0.19F); } } long now = System.currentTimeMillis(); if (type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.INVENTORY || type == ItemRenderType.EQUIPPED) { EntityPlayer p = Minecraft.getMinecraft().thePlayer; float rYaw = p.rotationYaw; if (type == ItemRenderType.EQUIPPED) { p = (EntityPlayer) obj[1]; rYaw = p.renderYawOffset; } final int x = (int) p.posX; final int y = (int) p.posY; final int z = (int) p.posZ; final CompassResult cr = CompassManager.INSTANCE.getCompassDirection(0, x, y, z); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { CompassManager.INSTANCE.getCompassDirection(0, x + i - 1, y, z + j - 1); } } if (cr.isValidResult()) { if (cr.isSpin()) { now %= 100000; this.model.renderAll((now / 50000.0f) * (float) Math.PI * 500.0f); } else { if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { final float offRads = rYaw / 180.0f * (float) Math.PI; final float adjustment = (float) Math.PI * 0.74f; this.model.renderAll((float) this.flipidiy(cr.getRad() + offRads + adjustment)); } else { final float offRads = rYaw / 180.0f * (float) Math.PI; final float adjustment = (float) Math.PI * -0.74f; this.model.renderAll((float) this.flipidiy(cr.getRad() + offRads + adjustment)); } } } else { now %= 1000000; this.model.renderAll((now / 500000.0f) * (float) Math.PI * 500.0f); } } else { now %= 100000; this.model.renderAll((now / 50000.0f) * (float) Math.PI * 500.0f); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }
From source file:appeng.client.render.blocks.RenderBlockSkyCompass.java
License:Open Source License
@Override public void renderTile(final BlockSkyCompass block, final TileSkyCompass skyCompass, final Tessellator tess, final double x, final double y, final double z, final float partialTick, final RenderBlocks renderer) { if (skyCompass == null) { return;//w ww. j a va2 s . c o m } if (!skyCompass.hasWorldObj()) { return; } GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glCullFace(GL11.GL_FRONT); final ResourceLocation loc = new ResourceLocation("appliedenergistics2", "textures/models/compass.png"); Minecraft.getMinecraft().getTextureManager().bindTexture(loc); this.applyTESRRotation(x, y, z, skyCompass.getUp(), skyCompass.getForward()); GL11.glScalef(1.0F, -1F, -1F); GL11.glTranslatef(0.5F, -1.5F, -0.5F); long now = System.currentTimeMillis(); CompassResult cr = null; if (skyCompass.getForward() == ForgeDirection.UP || skyCompass.getForward() == ForgeDirection.DOWN) { cr = CompassManager.INSTANCE.getCompassDirection(0, skyCompass.xCoord, skyCompass.yCoord, skyCompass.zCoord); } else { cr = new CompassResult(false, true, 0); } if (cr.isValidResult()) { if (cr.isSpin()) { now %= 100000; this.model.renderAll((now / 50000.0f) * (float) Math.PI * 500.0f); } else { this.model.renderAll( (float) (skyCompass.getForward() == ForgeDirection.DOWN ? this.flipidiy(cr.getRad()) : cr.getRad())); } } else { now %= 1000000; this.model.renderAll((now / 500000.0f) * (float) Math.PI * 500.0f); } GL11.glCullFace(GL11.GL_BACK); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }
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;/* w ww .jav a 2 s . 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();// www . jav a 2 s .c om 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.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(); }//ww w .j a v a 2s . co 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();// ww w . j av a2 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(); }
From source file:appeng.client.render.items.ToolColorApplicatorRender.java
License:Open Source License
@Override public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) { final IIcon par2Icon = item.getIconIndex(); float f4 = par2Icon.getMinU(); float f5 = par2Icon.getMaxU(); float f6 = par2Icon.getMinV(); float f7 = par2Icon.getMaxV(); final Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix();//www . j av a 2 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 { if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(0.0F, 0.0F, 0.0F); } else if (type == ItemRenderType.EQUIPPED) { 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, -1F, 1F); GL11.glTranslatef(-1.125F, 0.0f, f12 / -2.0f); GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); } final IIcon dark = ExtraItemTextures.ToolColorApplicatorTip_Dark.getIcon(); final IIcon med = ExtraItemTextures.ToolColorApplicatorTip_Medium.getIcon(); final IIcon light = ExtraItemTextures.ToolColorApplicatorTip_Light.getIcon(); GL11.glScalef(1F / 16F, 1F / 16F, 1F); if (type != ItemRenderType.INVENTORY) { GL11.glTranslatef(2, 0, 0); } GL11.glDisable(GL11.GL_LIGHTING); final AEColor col = ((ToolColorApplicator) item.getItem()).getActiveColor(item); if (col != null) { tessellator.startDrawingQuads(); f4 = dark.getMinU(); f5 = dark.getMaxU(); f6 = dark.getMinV(); f7 = dark.getMaxV(); tessellator.setColorOpaque_I(col.blackVariant); tessellator.addVertexWithUV(0, 0, 0, f4, f7); tessellator.addVertexWithUV(16, 0, 0, f5, f7); tessellator.addVertexWithUV(16, 16, 0, f5, f6); tessellator.addVertexWithUV(0, 16, 0, f4, f6); f4 = light.getMinU(); f5 = light.getMaxU(); f6 = light.getMinV(); f7 = light.getMaxV(); tessellator.setColorOpaque_I(col.whiteVariant); tessellator.addVertexWithUV(0, 0, 0, f4, f7); tessellator.addVertexWithUV(16, 0, 0, f5, f7); tessellator.addVertexWithUV(16, 16, 0, f5, f6); tessellator.addVertexWithUV(0, 16, 0, f4, f6); f4 = med.getMinU(); f5 = med.getMaxU(); f6 = med.getMinV(); f7 = med.getMaxV(); tessellator.setColorOpaque_I(col.mediumVariant); tessellator.addVertexWithUV(0, 0, 0, f4, f7); tessellator.addVertexWithUV(16, 0, 0, f5, f7); tessellator.addVertexWithUV(16, 16, 0, f5, f6); tessellator.addVertexWithUV(0, 16, 0, f4, f6); tessellator.draw(); } GL11.glPopAttrib(); GL11.glPopMatrix(); }