List of usage examples for org.lwjgl.opengl GL11 glTranslatef
public static native void glTranslatef(@NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);
From source file:de.sanandrew.mods.particledeco.client.render.block.RenderParticleBox.java
License:Creative Commons License
@Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; block.setBlockBoundsForItemRender(); renderer.setRenderBoundsFromBlock(block); GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); GL11.glScalef(1.5F, 1.0F, 1.5F);// ww w . j a v a 2 s . c o m GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glScalef(1.0F, 1.5F, 1.0F); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1.0F, 0.0F); renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 0, 1)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 1, 1)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1.0F); renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, 1)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, 1)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1.0F, 0.0F, 0.0F); renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, 1)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, 1)); tessellator.draw(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); }
From source file:de.sanandrew.mods.turretmod.client.gui.control.GuiIconTab.java
License:Creative Commons License
protected void drawIcon(IIcon icon, int posX, int posY, Minecraft mc) { GL11.glPushMatrix();//from w ww. ja v a2 s . c om GL11.glTranslatef(0.0F, 0.0F, 32.0F); this.zLevel = 200.0F; itemRenderer.zLevel = 200.0F; GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GL11.glEnable(GL11.GL_ALPHA_TEST); ResourceLocation resourcelocation = mc.getTextureManager().getResourceLocation(1); mc.getTextureManager().bindTexture(resourcelocation); if (icon == null) { icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)) .getAtlasSprite("missingno"); } itemRenderer.renderIcon(posX, posY, icon, 16, 16); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); this.zLevel = 0.0F; itemRenderer.zLevel = 0.0F; GL11.glPopMatrix(); }
From source file:de.sanandrew.mods.turretmod.client.gui.tcu.GuiTcuUpgrades.java
License:Creative Commons License
@Override public void drawScreenPostBkg(int mouseX, int mouseY, float partTicks) { boolean isLmbDown = Mouse.isButtonDown(0); this.mc.renderEngine.bindTexture(Textures.GUI_TCU_UPGRADES.getResource()); GL11.glColor3f(1.0F, 1.0F, 1.0F);/*from w w w. j a va2 s . c o m*/ this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); int col; int row; ItemStack currStack; int maxSlots = MathHelper .ceiling_double_int(TurretAttributes.MAX_UPGRADE_SLOTS.clampValue(Double.MAX_VALUE)); int maxActiveUpg = this.tempUpgradeList.size(); for (int i = 0; i < maxSlots; i++) { col = i % COL_COUNT; row = i / COL_COUNT; if (i < maxActiveUpg) { TurretUpgrade upgrade = this.tempUpgradeList.get(i); currStack = TmrItems.turretUpgrade.getStackWithUpgrade(upgrade, 1); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GuiUtils.drawGuiIcon(TmrItems.turretUpgrade.getIcon(currStack, 0), this.guiLeft + 7 + col * 18, this.guiTop + 25 + row * 26); GuiUtils.drawGuiIcon(TmrItems.turretUpgrade.getIcon(currStack, 1), this.guiLeft + 7 + col * 18, this.guiTop + 25 + row * 26); GL11.glEnable(GL11.GL_BLEND); this.mc.renderEngine.bindTexture(Textures.GUI_TCU_UPGRADES.getResource()); boolean isHoveringOverEject = GuiUtils.isMouseInRect(mouseX, mouseY, this.guiLeft + 6 + col * 18, this.guiTop + 18 + row * 26, 5, 6); this.drawTexturedModalRect(this.guiLeft + 6 + col * 18, this.guiTop + 18 + row * 26, 176, (isHoveringOverEject ? 0 : 6), 5, 6); if (isHoveringOverEject && isLmbDown && !this.prevIsLmbDown) { this.ejectUpgrade(this.tempUpgradeList.get(i)); } if (GuiUtils.isMouseInRect(mouseX, mouseY, this.guiLeft + 6 + col * 18, this.guiTop + 24 + row * 26, 18, 18)) { GL11.glTranslatef(0.0F, 0.0F, 300.0F); drawRect(this.guiLeft + 7 + col * 18, this.guiTop + 25 + row * 26, this.guiLeft + 23 + col * 18, this.guiTop + 41 + row * 16, 0x80FFFFFF); GL11.glTranslatef(0.0F, 0.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); drawHoveringText(currStack, this.guiLeft + 15 + col * 18, this.guiTop + 32 + row * 26, this.fontRendererObj, col / 5 > 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef(0.0F, 0.0F, -301.0F); } GL11.glDisable(GL11.GL_BLEND); } if (col == 0) { if (row >= this.rowsVisible) { GL11.glEnable(GL11.GL_BLEND); this.mc.renderEngine.bindTexture(Textures.GUI_TCU_UPGRADES.getResource()); this.drawTexturedModalRect(this.guiLeft + 6, this.guiTop + 18 + row * 26, 0, 222, 162, 24); GL11.glDisable(GL11.GL_BLEND); } } } this.prevIsLmbDown = isLmbDown; }
From source file:de.sanandrew.mods.turretmod.client.gui.tcu.tooltip.GuiIngameTcuInfos.java
License:Creative Commons License
@SubscribeEvent public void onRenderIngame(RenderGameOverlayEvent.Pre event) { if (this.mc == null) { this.mc = Minecraft.getMinecraft(); }/*from w w w.ja v a2 s. c om*/ if (this.mc.thePlayer == null || this.mc.thePlayer.getHeldItem() == null || this.mc.thePlayer.getHeldItem().getItem() != TmrItems.turretCtrlUnit) { return; } if (event.type == ElementType.CROSSHAIRS) { GL11.glPushMatrix(); GL11.glTranslatef(event.resolution.getScaledWidth() / 2.0F + 6.0F, event.resolution.getScaledHeight() / 2.0F + 6.0F, 0.0F); MovingObjectPosition objPos = this.mc.objectMouseOver; if (objPos.typeOfHit == MovingObjectType.BLOCK) { Block block = this.mc.theWorld.getBlock(objPos.blockX, objPos.blockY, objPos.blockZ); if (block == TmrBlocks.itemTransmitter) { TileEntityItemTransmitter transmitter = (TileEntityItemTransmitter) this.mc.theWorld .getTileEntity(objPos.blockX, objPos.blockY, objPos.blockZ); ItemStack stack = transmitter.getRequestItem(); Turret turret = transmitter.getRequestingTurret(); List<TooltipLine<TileEntityItemTransmitter>> lines = new ArrayList<>(); lines.add(new LineString<TileEntityItemTransmitter>( SAPUtils.translatePostFormat("Requesting: %s", transmitter.getRequest().name()))); if (transmitter.getRequest() != Request.NONE && turret != null && stack != null) { lines.add(new LineString<TileEntityItemTransmitter>(SAPUtils .translatePostFormat("Item: %s x%d", stack.getDisplayName(), stack.stackSize))); lines.add(new LineString<TileEntityItemTransmitter>( SAPUtils.translatePostFormat("Turret: %s", turret.getTurretName()))); lines.add(new LineString<TileEntityItemTransmitter>( SAPUtils.translatePostFormat(" @ x:%.0f y:%.0f z:%.0f", turret.getEntity().posX, turret.getEntity().posY, turret.getEntity().posZ))); lines.add(new LineString<TileEntityItemTransmitter>( SAPUtils.translatePostFormat("Expiration time: %d", transmitter.requestTimeout))); } this.drawTooltip(lines, transmitter, -3, -3, 0xA085C96F); } } else if (objPos.typeOfHit == MovingObjectType.ENTITY) { Entity e = objPos.entityHit; if (e instanceof EntityTurretBase) { EntityTurretBase turret = (EntityTurretBase) e; RGBAValues clr; try { IResource res = Minecraft.getMinecraft().getResourceManager() .getResource(turret.getGlowTexture()); clr = AverageColorHelper.getAverageColor(res.getInputStream(), new RGBAValues(0xFF000000)); } catch (IOException ex) { clr = new RGBAValues(0, 0, 0, 255); } List<TooltipLine<EntityTurretBase>> lines = new ArrayList<>(); lines.add(new LineString<EntityTurretBase>("Turret: %s", turret.getTurretName())); lines.add(new LineString<EntityTurretBase>("Frequency: %s", turret.getFrequency())); lines.add(new LineHealthBar<EntityTurretBase>(turret.getHealth(), turret.getMaxHealth())); lines.add(new LineAmmoBar<EntityTurretBase>(turret.getAmmo(), turret.getMaxAmmo())); this.drawTooltip(lines, turret, -3, -3, (0xA0 << 24) | (clr.getRed() << 16) | (clr.getGreen() << 8) | clr.getBlue()); } } GL11.glPopMatrix(); } }
From source file:de.sanandrew.mods.turretmod.client.render.entity.RenderTurretArrow.java
License:Creative Commons License
public void doRender(EntityArrow arrow, double x, double y, double z, float yaw, float partTicks) { this.bindEntityTexture(arrow); GL11.glPushMatrix();//from w ww.j a v a 2 s.c o m GL11.glTranslatef((float) x, (float) y, (float) z); GL11.glRotatef(arrow.prevRotationYaw + (arrow.rotationYaw - arrow.prevRotationYaw) * partTicks - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(arrow.prevRotationPitch + (arrow.rotationPitch - arrow.prevRotationPitch) * partTicks, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.instance; GL11.glEnable(GL12.GL_RESCALE_NORMAL); float shake = arrow.arrowShake - partTicks; if (shake > 0.0F) { float shakeVal = -MathHelper.sin(shake * 3.0F) * shake; GL11.glRotatef(shakeVal, 0.0F, 0.0F, 1.0F); } float scale = 0.03625F; GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); GL11.glScalef(scale, scale, scale); GL11.glTranslatef(4.0F, 0.0F, 0.0F); GL11.glNormal3f(scale, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, 0.0F, 0.15625F); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, 0.15625F, 0.15625F); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, 0.15625F, 0.3125F); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, 0.0F, 0.3125F); tessellator.draw(); GL11.glNormal3f(-scale, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, 0.0F, 0.15625F); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, 0.15625F, 0.15625F); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, 0.15625F, 0.3125F); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, 0.0F, 0.3125F); tessellator.draw(); for (int i = 0; i < 4; ++i) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, scale); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, 0.0F, 0.0F); tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, 0.5F, 0.0F); tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, 0.5F, 0.15625F); tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, 0.0F, 0.15625F); tessellator.draw(); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
From source file:de.sanandrew.mods.turretmod.client.render.item.ItemRendererTile.java
License:Creative Commons License
@Override public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { GL11.glPushMatrix();/* w ww.j ava 2 s . com*/ GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(-1.0F, 0.0F, -0.0F); } else { GL11.glTranslatef(-0.5F, -0.5F, -0.5F); } GL11.glEnable(GL11.GL_ALPHA_TEST); TileEntityRendererDispatcher.instance.renderTileEntityAt(this.tile, 0.0D, 0.0D, 0.0D, 0.0F); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
From source file:de.sanandrew.mods.turretmod.client.render.tileentity.RenderItemTransmitter.java
License:Creative Commons License
@Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partTicks) { Minecraft mc = Minecraft.getMinecraft(); if (this.tooltipFR == null) { this.tooltipFR = new FontRenderer(mc.gameSettings, new ResourceLocation("textures/font/ascii.png"), mc.renderEngine, true);// ww w . j av a 2 s . c o m if (mc.gameSettings.language != null) { this.tooltipFR.setBidiFlag(mc.getLanguageManager().isCurrentLanguageBidirectional()); } } TileEntityItemTransmitter te = ((TileEntityItemTransmitter) tile); GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F); if (te.renderPass == 0) { GL11.glPushMatrix(); this.bindTexture(Textures.TILE_ITEM_TRANSMITTER.getResource()); this.modelBlock.render(0.0625F); this.bindTexture(Textures.TILE_ITEM_TRANSMITTER_GLOW.getResource()); float prevBrightX = OpenGlHelper.lastBrightnessX; float prevBrightY = OpenGlHelper.lastBrightnessY; int bright = 0xF0; int brightX = bright % 65536; int brightY = bright / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX / 1.0F, brightY / 1.0F); this.modelBlock.render(0.0625F); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevBrightX, prevBrightY); GL11.glPopMatrix(); } // else { // MovingObjectPosition objPos = mc.objectMouseOver; // // float prevBrightX = OpenGlHelper.lastBrightnessX; // float prevBrightY = OpenGlHelper.lastBrightnessY; // int bright = 0xF0; // int brightX = bright % 65536; // int brightY = bright / 65536; // OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX / 1.0F, brightY / 1.0F); // // if( objPos.typeOfHit == MovingObjectType.BLOCK && mc.theWorld.getTileEntity(objPos.blockX, objPos.blockY, objPos.blockZ) == te // && mc.thePlayer.getHeldItem() != null && mc.thePlayer.getHeldItem().getItem() == TmrItems.turretCtrlUnit ) // { // GL11.glPushMatrix(); // setupTooltipRenderer(mc, te, partTicks); // // if( te.scaleTooltip < 1.0F ) { // te.scaleTooltip += 0.2F; // } else { // te.scaleTooltip = 1.01F; // } // renderTooltipBg(Tessellator.instance, te.scaleTooltip); // // if( te.scaleTooltip >= 1.0F ) { // if( te.lengthTooltipRod < 1.0F ) { // te.lengthTooltipRod += 0.1F; // } else { // te.lengthTooltipRod = 1.01F; // } // renderTooltipRod(Tessellator.instance, te.lengthTooltipRod); // } // finishTooltipRenderer(); // // if( te.scaleTooltip >= 1.0F ) { // renderTooltipText(this.tooltipFR, te, 0xFFFFFF, te.lengthTooltipRod); // } // // GL11.glPopMatrix(); // } else { // if( te.timestampLastRendered < mc.theWorld.getTotalWorldTime() - 2 ) { // te.scaleTooltip = 0.0F; // te.lengthTooltipRod = 0.0F; // } else if( te.scaleTooltip > 0.0F ) { // GL11.glPushMatrix(); // setupTooltipRenderer(mc, te, partTicks); // if( te.lengthTooltipRod > 0.0F ) { // te.lengthTooltipRod -= 0.1F; // renderTooltipRod(Tessellator.instance, te.lengthTooltipRod); // } else { // te.lengthTooltipRod = -0.01F; // } // // if( te.lengthTooltipRod <= 0.0F ) { // if( te.scaleTooltip > 0.0F ) { // te.scaleTooltip -= 0.2F; // } else { // te.scaleTooltip = -0.01F; // } // } // renderTooltipBg(Tessellator.instance, te.scaleTooltip); // // finishTooltipRenderer(); // // if( te.lengthTooltipRod > 0.0F ) { // renderTooltipText(this.tooltipFR, te, 0xFFFFFF, te.lengthTooltipRod); // } // GL11.glPopMatrix(); // } // } // // OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevBrightX, prevBrightY); // // te.timestampLastRendered = mc.theWorld.getTotalWorldTime(); // } GL11.glPopMatrix(); }
From source file:de.sanandrew.mods.turretmod.client.render.tileentity.RenderItemTransmitter.java
License:Creative Commons License
private static void renderTooltipText(FontRenderer fontRenderer, TileEntityItemTransmitter te, int color, float alpha) { GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, 0.0F, 0.0F); GL11.glScalef(0.01F, 0.01F, 0.01F);/*from www. j av a 2 s . c om*/ GL11.glTranslatef(8.0F, 8.0F, -1.0F); int max = 0xE0; int alphaInt = Math.min(Math.max(0x04, MathHelper.ceiling_float_int(max * alpha)), max); ItemStack stack = te.getRequestItem(); Turret turret = te.getRequestingTurret(); String s; s = SAPUtils.translatePostFormat("Requesting: %s", te.getRequest().name()); fontRenderer.drawString(s, 0, te.getRequest() == Request.NONE ? 18 : 0, color | (alphaInt << 24)); if (te.getRequest() != Request.NONE && turret != null && stack != null) { s = SAPUtils.translatePostFormat("Item: %s x%d", stack.getDisplayName(), stack.stackSize); fontRenderer.drawString(s, 0, 9, color | (alphaInt << 24)); s = SAPUtils.translatePostFormat("Turret: %s", turret.getTurretName()); fontRenderer.drawString(s, 0, 18, color | (alphaInt << 24)); s = SAPUtils.translatePostFormat(" @ x:%.0f y:%.0f z:%.0f", turret.getEntity().posX, turret.getEntity().posY, turret.getEntity().posZ); fontRenderer.drawString(s, 0, 27, color | (alphaInt << 24)); s = SAPUtils.translatePostFormat("Expiration time: %d", te.requestTimeout); fontRenderer.drawString(s, 0, 36, color | (alphaInt << 24)); } }
From source file:de.sanandrew.mods.varietychests.client.ItemRendererCustomChest.java
License:Creative Commons License
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GL11.glPushMatrix();//from ww w . j a va 2 s . c o m GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(-1.0F, 0.0F, -0.0F); } else { GL11.glTranslatef(-0.5F, -0.5F, -0.5F); } this.chest.chestType = ChestType.getTypeFromItemStack(item); TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chest, 0.0D, 0.0D, 0.0D, 0.0F); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
From source file:de.sanandrew.mods.varietychests.client.renderer.ItemRendererCustomChest.java
License:Creative Commons License
@Override public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { GL11.glPushMatrix();// www.ja v a2 s.c om GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); if (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { GL11.glTranslatef(-1.0F, 0.0F, -0.0F); } else { GL11.glTranslatef(-0.5F, -0.5F, -0.5F); } this.chest.blockType = Block.getBlockFromItem(stack.getItem()); this.chest.chestType = ChestType.getType(stack); GL11.glEnable(GL11.GL_ALPHA_TEST); TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chest, 0.0D, 0.0D, 0.0D, 0.0F); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }