List of usage examples for org.lwjgl.opengl GL11 glRotatef
public static native void glRotatef(@NativeType("GLfloat") float angle, @NativeType("GLfloat") float x, @NativeType("GLfloat") float y, @NativeType("GLfloat") float z);
From source file:mca.client.render.RenderHuman.java
License:Open Source License
/** * Renders a label above an entity's head. * /* ww w. ja v a 2 s . c o m*/ * @param human The entity that the label should be rendered on. * @param labelText The text that should appear on the label. */ private void renderLabel(EntityHuman human, double posX, double posY, double posZ, String labelText) { if (human.isSneaking()) { final Tessellator tessellator = Tessellator.instance; final FontRenderer fontRendererObj = getFontRendererFromRenderManager(); final int stringWidth = fontRendererObj.getStringWidth(labelText) / 2; GL11.glPushMatrix(); { GL11.glTranslatef((float) posX + 0.0F, (float) posY + 2.3F, (float) posZ); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glScalef(-LABEL_SCALE, -LABEL_SCALE, LABEL_SCALE); GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslatef(0.0F, 0.25F / LABEL_SCALE, 0.0F); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.addVertex(-stringWidth - 1, -1D, 0.0D); tessellator.addVertex(-stringWidth - 1, 8D, 0.0D); tessellator.addVertex(stringWidth + 1, 8D, 0.0D); tessellator.addVertex(stringWidth + 1, -1D, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(true); fontRendererObj.drawString(labelText, -fontRendererObj.getStringWidth(labelText) / 2, 0, 0x20ffffff); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } GL11.glPopMatrix(); } else { //RenderLivingLabel func_147906_a(human, labelText, posX, posY, posZ, 64); } }
From source file:mca.client.render.RenderTombstone.java
License:Open Source License
public void renderTombstoneAt(TileTombstone tombstoneEntity, double posX, double posY, double posZ, float partialTickTime) { final StringBuilder stringBuilder = new StringBuilder(); final FontRenderer fontRendererObj = func_147498_b(); final int meta = tombstoneEntity.getBlockMetadata(); final float rotation = setRotationByMeta(meta); GL11.glPushMatrix();// w ww .j a va 2 s. c o m GL11.glTranslated(posX + 0.50F, posY + 1.59F, posZ + 0.53F); GL11.glRotatef(-rotation, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0, 0.5F, 0); GL11.glScalef(1.4F, 1.4F, 1.4F); bindResource(TEXTURE); GL11.glPushMatrix(); { GL11.glScalef(1F, -1F, -1F); tombstoneModel.renderTombstone(); } GL11.glPopMatrix(); //Text size is 0.017F. GL11.glTranslatef(0.0F, -1.15F, 0.07F); GL11.glScalef(0.017F / 2, -0.017F / 2, 0.017F / 2); GL11.glNormal3f(0.0F, 0.0F, -1F * 0.017F); GL11.glDepthMask(false); for (int line = 0; line < tombstoneEntity.signText.length; line++) { String lineText = tombstoneEntity.signText[line]; if (line == tombstoneEntity.lineBeingEdited) { lineText = stringBuilder.append("> ").append(lineText).append(" <").toString(); } fontRendererObj.drawString(lineText, -fontRendererObj.getStringWidth(lineText) / 2, line * 10 - tombstoneEntity.signText.length * 5, 0x000000); } GL11.glDepthMask(true); GL11.glPopMatrix(); }
From source file:mcp.mobius.waila.gui.truetyper.FontHelper.java
License:Open Source License
public static void drawString(String s, float x, float y, TrueTypeFont font, float scaleX, float scaleY, float rotationZ, float... rgba) { Minecraft mc = Minecraft.getMinecraft(); ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); if (mc.gameSettings.hideGUI) { return;//from w ww. j a v a 2s . c o m } int amt = 1; if (sr.getScaleFactor() == 1) { amt = 2; } FloatBuffer matrixData = BufferUtils.createFloatBuffer(16); GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, matrixData); FontHelper.set2DMode(matrixData); GL11.glPushMatrix(); y = mc.displayHeight - (y * sr.getScaleFactor()) - (((font.getLineHeight() / amt))); float tx = (x * sr.getScaleFactor()) + (font.getWidth(s) / 2); float tranx = tx + 2; float trany = y + (font.getLineHeight() / 2); GL11.glTranslatef(tranx, trany, 0); GL11.glRotatef(rotationZ, 0f, 0f, 1f); GL11.glTranslatef(-tranx, -trany, 0); GL11.glEnable(GL11.GL_BLEND); if (s.contains(formatEscape)) { String[] pars = s.split(formatEscape); float totalOffset = 0; for (int i = 0; i < pars.length; i++) { String par = pars[i]; float[] c = rgba; if (i > 0) { c = Formatter.getFormatted(par.charAt(0)); par = par.substring(1, par.length()); } font.drawString((x * sr.getScaleFactor() + totalOffset), y, par, scaleX / amt, scaleY / amt, c); totalOffset += font.getWidth(par); } } else { font.drawString((x * sr.getScaleFactor()), y, s, scaleX / amt, scaleY / amt, rgba); } GL11.glPopMatrix(); GL11.glDisable(GL11.GL_BLEND); FontHelper.set3DMode(); }
From source file:me.twentyonez.guardianchest.render.tile_entity.GCChestRenderer.java
License:LGPL
public void renderTileEntityAt(TileEntityGCChest p_147502_1_, double p_147502_2_, double p_147502_4_, double p_147502_6_, float p_147502_8_) { int i;/*from w w w . j a v a 2 s. c om*/ if (!p_147502_1_.hasWorldObj()) { i = 0; } else { Block block = p_147502_1_.getBlockType(); i = p_147502_1_.getBlockMetadata(); if (block instanceof GCChest && i == 0) { try { ((GCChest) block).func_149954_e(p_147502_1_.getWorldObj(), p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord); } catch (ClassCastException e) { FMLLog.severe("Attempted to render a chest at %d, %d, %d that was not a chest", p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord); } i = p_147502_1_.getBlockMetadata(); } p_147502_1_.checkForAdjacentChests(); } if (p_147502_1_.adjacentChestZNeg == null && p_147502_1_.adjacentChestXNeg == null) { ModelChest modelchest; modelchest = this.field_147510_h; this.bindTexture(field_147505_d); GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) p_147502_2_, (float) p_147502_4_ + 1.0F, (float) p_147502_6_ + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short short1 = 0; if (i == 2) { short1 = 180; } if (i == 3) { short1 = 0; } if (i == 4) { short1 = 90; } if (i == 5) { short1 = -90; } if (i == 2 && p_147502_1_.adjacentChestXPos != null) { GL11.glTranslatef(1.0F, 0.0F, 0.0F); } if (i == 5 && p_147502_1_.adjacentChestZPos != null) { GL11.glTranslatef(0.0F, 0.0F, -1.0F); } GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float f1 = p_147502_1_.prevLidAngle + (p_147502_1_.lidAngle - p_147502_1_.prevLidAngle) * p_147502_8_; float f2; if (p_147502_1_.adjacentChestZNeg != null) { f2 = p_147502_1_.adjacentChestZNeg.prevLidAngle + (p_147502_1_.adjacentChestZNeg.lidAngle - p_147502_1_.adjacentChestZNeg.prevLidAngle) * p_147502_8_; if (f2 > f1) { f1 = f2; } } if (p_147502_1_.adjacentChestXNeg != null) { f2 = p_147502_1_.adjacentChestXNeg.prevLidAngle + (p_147502_1_.adjacentChestXNeg.lidAngle - p_147502_1_.adjacentChestXNeg.prevLidAngle) * p_147502_8_; if (f2 > f1) { f1 = f2; } } f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F); modelchest.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } }
From source file:me.twentyonez.guardianchest.render.tile_entity.ItemGuardianTier0Renderer.java
License:LGPL
public void renderTileEntityAt(TileEntityItemGuardianTier0 p_147502_1_, double p_147502_2_, double p_147502_4_, double p_147502_6_, float p_147502_8_) { int i;//from w w w. j ava2 s . c o m if (!p_147502_1_.hasWorldObj()) { i = 0; } else { Block block = p_147502_1_.getBlockType(); i = p_147502_1_.getBlockMetadata(); if (block instanceof GCChest && i == 0) { try { ((GCChest) block).func_149954_e(p_147502_1_.getWorldObj(), p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord); } catch (ClassCastException e) { FMLLog.severe("Attempted to render a chest at %d, %d, %d that was not a chest", p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord); } i = p_147502_1_.getBlockMetadata(); } p_147502_1_.checkForAdjacentChests(); } if (p_147502_1_.adjacentChestZNeg == null && p_147502_1_.adjacentChestXNeg == null) { ModelChest modelchest; if (p_147502_1_.adjacentChestXPos == null && p_147502_1_.adjacentChestZPos == null) { modelchest = this.field_147510_h; this.bindTexture(field_147504_g); } else { modelchest = this.field_147511_i; this.bindTexture(field_147505_d); } GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) p_147502_2_, (float) p_147502_4_ + 1.0F, (float) p_147502_6_ + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short short1 = 0; if (i == 2) { short1 = 180; } if (i == 3) { short1 = 0; } if (i == 4) { short1 = 90; } if (i == 5) { short1 = -90; } if (i == 2 && p_147502_1_.adjacentChestXPos != null) { GL11.glTranslatef(1.0F, 0.0F, 0.0F); } if (i == 5 && p_147502_1_.adjacentChestZPos != null) { GL11.glTranslatef(0.0F, 0.0F, -1.0F); } GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float f1 = p_147502_1_.prevLidAngle + (p_147502_1_.lidAngle - p_147502_1_.prevLidAngle) * p_147502_8_; float f2; if (p_147502_1_.adjacentChestZNeg != null) { f2 = p_147502_1_.adjacentChestZNeg.prevLidAngle + (p_147502_1_.adjacentChestZNeg.lidAngle - p_147502_1_.adjacentChestZNeg.prevLidAngle) * p_147502_8_; if (f2 > f1) { f1 = f2; } } if (p_147502_1_.adjacentChestXNeg != null) { f2 = p_147502_1_.adjacentChestXNeg.prevLidAngle + (p_147502_1_.adjacentChestXNeg.lidAngle - p_147502_1_.adjacentChestXNeg.prevLidAngle) * p_147502_8_; if (f2 > f1) { f1 = f2; } } f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F); modelchest.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } }
From source file:me.twentyonez.guardianchest.render.tile_entity.ItemGuardianTier1Renderer.java
License:LGPL
public void renderTileEntityAt(TileEntityItemGuardianTier1 p_147502_1_, double p_147502_2_, double p_147502_4_, double p_147502_6_, float p_147502_8_) { int i;//w w w . ja v a2s. c o m if (!p_147502_1_.hasWorldObj()) { i = 0; } else { Block block = p_147502_1_.getBlockType(); i = p_147502_1_.getBlockMetadata(); if (block instanceof GCChest && i == 0) { try { ((GCChest) block).func_149954_e(p_147502_1_.getWorldObj(), p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord); } catch (ClassCastException e) { FMLLog.severe("Attempted to render a chest at %d, %d, %d that was not a chest", p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord); } i = p_147502_1_.getBlockMetadata(); } p_147502_1_.checkForAdjacentChests(); } if (p_147502_1_.adjacentChestZNeg == null && p_147502_1_.adjacentChestXNeg == null) { ModelChest modelchest; if (p_147502_1_.adjacentChestXPos == null && p_147502_1_.adjacentChestZPos == null) { modelchest = this.field_147510_h; this.bindTexture(field_147504_g); } else { modelchest = this.field_147511_i; this.bindTexture(field_147505_d); } GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) p_147502_2_, (float) p_147502_4_ + 1.0F, (float) p_147502_6_ + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short short1 = 0; if (i == 2) { short1 = 180; } if (i == 3) { short1 = 0; } if (i == 4) { short1 = 90; } if (i == 5) { short1 = -90; } if (i == 2 && p_147502_1_.adjacentChestXPos != null) { GL11.glTranslatef(1.0F, 0.0F, 0.0F); } if (i == 5 && p_147502_1_.adjacentChestZPos != null) { GL11.glTranslatef(0.0F, 0.0F, -1.0F); } GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float f1 = p_147502_1_.prevLidAngle + (p_147502_1_.lidAngle - p_147502_1_.prevLidAngle) * p_147502_8_; float f2; if (p_147502_1_.adjacentChestZNeg != null) { f2 = p_147502_1_.adjacentChestZNeg.prevLidAngle + (p_147502_1_.adjacentChestZNeg.lidAngle - p_147502_1_.adjacentChestZNeg.prevLidAngle) * p_147502_8_; if (f2 > f1) { f1 = f2; } } if (p_147502_1_.adjacentChestXNeg != null) { f2 = p_147502_1_.adjacentChestXNeg.prevLidAngle + (p_147502_1_.adjacentChestXNeg.lidAngle - p_147502_1_.adjacentChestXNeg.prevLidAngle) * p_147502_8_; if (f2 > f1) { f1 = f2; } } f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F); modelchest.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } }
From source file:me.twentyonez.guardianchest.render.tile_entity.ItemGuardianTier2Renderer.java
License:LGPL
public void renderTileEntityAt(TileEntityItemGuardianTier2 p_147502_1_, double p_147502_2_, double p_147502_4_, double p_147502_6_, float p_147502_8_) { int i;/* w w w. j a v a 2s. c om*/ if (!p_147502_1_.hasWorldObj()) { i = 0; } else { Block block = p_147502_1_.getBlockType(); i = p_147502_1_.getBlockMetadata(); if (block instanceof GCChest && i == 0) { try { ((GCChest) block).func_149954_e(p_147502_1_.getWorldObj(), p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord); } catch (ClassCastException e) { FMLLog.severe("Attempted to render a chest at %d, %d, %d that was not a chest", p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord); } i = p_147502_1_.getBlockMetadata(); } p_147502_1_.checkForAdjacentChests(); } if (p_147502_1_.adjacentChestZNeg == null && p_147502_1_.adjacentChestXNeg == null) { ModelChest modelchest; if (p_147502_1_.adjacentChestXPos == null && p_147502_1_.adjacentChestZPos == null) { modelchest = this.field_147510_h; this.bindTexture(field_147504_g); } else { modelchest = this.field_147511_i; this.bindTexture(field_147505_d); } GL11.glPushMatrix(); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) p_147502_2_, (float) p_147502_4_ + 1.0F, (float) p_147502_6_ + 1.0F); GL11.glScalef(1.0F, -1.0F, -1.0F); GL11.glTranslatef(0.5F, 0.5F, 0.5F); short short1 = 0; if (i == 2) { short1 = 180; } if (i == 3) { short1 = 0; } if (i == 4) { short1 = 90; } if (i == 5) { short1 = -90; } if (i == 2 && p_147502_1_.adjacentChestXPos != null) { GL11.glTranslatef(1.0F, 0.0F, 0.0F); } if (i == 5 && p_147502_1_.adjacentChestZPos != null) { GL11.glTranslatef(0.0F, 0.0F, -1.0F); } GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); float f1 = p_147502_1_.prevLidAngle + (p_147502_1_.lidAngle - p_147502_1_.prevLidAngle) * p_147502_8_; float f2; if (p_147502_1_.adjacentChestZNeg != null) { f2 = p_147502_1_.adjacentChestZNeg.prevLidAngle + (p_147502_1_.adjacentChestZNeg.lidAngle - p_147502_1_.adjacentChestZNeg.prevLidAngle) * p_147502_8_; if (f2 > f1) { f1 = f2; } } if (p_147502_1_.adjacentChestXNeg != null) { f2 = p_147502_1_.adjacentChestXNeg.prevLidAngle + (p_147502_1_.adjacentChestXNeg.lidAngle - p_147502_1_.adjacentChestXNeg.prevLidAngle) * p_147502_8_; if (f2 > f1) { f1 = f2; } } f1 = 1.0F - f1; f1 = 1.0F - f1 * f1 * f1; modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F); modelchest.renderAll(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } }
From source file:me.ukl.api.gui.component.CheckBox.java
License:MIT License
@Override public void render() { this.drawBackground(); Color checkColor = isChecked() ? getCheckedColor() : getUncheckedColor(); float checkScale = getHeight() - 4; GL11.glPushMatrix();/*from w w w . j a v a 2 s . c o m*/ GL11.glTranslatef(getX() + getWidth() / 2, getY() + getHeight() / 2, 0); GL11.glScalef(checkScale, checkScale, checkScale); GL11.glTranslatef(0.05F, 0F, 0F); GL11.glRotatef(-45, 0, 0, 1); RenderUtil.drawRect(-0.5F, 0, 1F, 0.2F, checkColor); GL11.glTranslatef(-0.5F, 0F, 0F); GL11.glRotatef(-90, 0, 0, 1); RenderUtil.drawRect(-0.2F, 0F, 1 / 3F + 0.2F, 0.2F, checkColor); GL11.glPopMatrix(); }
From source file:me.undergroundminer3.uee4.pipesModded.AdvPipeRenderer.java
License:Minecraft Mod Public
@Deprecated //please copy this instead public void renderPower(Pipe<PipeTransportPower> pipe, double x, double y, double z) { initializeDisplayPowerList(pipe.container.getWorldObj()); PipeTransportPower pow = pipe.transport; GL11.glPushMatrix();/* w w w .j a v a 2s . com*/ GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glDisable(GL11.GL_LIGHTING); // GL11.glEnable(GL11.GL_BLEND); GL11.glTranslatef((float) x, (float) y, (float) z); bindTexture(TextureMap.locationBlocksTexture); int[] displayList = pow.overload > 0 ? displayPowerListOverload : displayPowerList; for (int side = 0; side < 6; ++side) { GL11.glPushMatrix(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); GL11.glRotatef(angleY[side], 0, 1, 0); GL11.glRotatef(angleZ[side], 0, 0, 1); float scale = 1.0F - side * 0.0001F; GL11.glScalef(scale, scale, scale); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); short stage = pow.clientDisplayPower[side]; if (stage >= 1) { if (stage < displayList.length) { GL11.glCallList(displayList[stage]); } else { GL11.glCallList(displayList[displayList.length - 1]); } } GL11.glPopMatrix(); } GL11.glPopAttrib(); GL11.glPopMatrix(); }