List of usage examples for org.lwjgl.opengl GL11 glPopMatrix
public static native void glPopMatrix();
From source file:ccm.placeableTools.client.ToolRenderer.java
License:Open Source License
private void renderSign(double x, double y, double z, float tickTime, int facing, String[] signText, int meta) { GL11.glPushMatrix();/*w w w . ja va 2 s.c o m*/ float f1 = 0.6666667F; float f2 = 0.0F; switch (facing) { case 0: case 8: f2 = -90f; break; case 1: case 7: f2 = 90f; break; case 2: case 5: f2 = 180f; } if (meta >= 2) { GL11.glTranslated(0, -1.2, 0); } GL11.glTranslatef((float) x + 0.5F, (float) y + 0.75F * f1, (float) z + 0.5F); GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, -0.3125F, -0.4375F); GL11.glTranslatef(0f, 0.8F, 0.5f); MODEL_SIGN.signStick.showModel = false; if (facing > 4) { if (meta >= 2) GL11.glTranslated(-0.6, 0, 0); //GL11.glTranslated(b ? -0.4 : -0.6, 0, 0); if (meta == 2 && facing == 7) GL11.glTranslated(1.2, 0, 0); else if (meta == 3 && facing == 8) GL11.glTranslated(1.2, 0, 0); else if (meta == 4 && facing == 6) GL11.glTranslated(1.2, 0, 0); else if (meta == 5 && facing == 5) GL11.glTranslated(1.2, 0, 0); } this.bindTexture(SIGN_TEXTURE); GL11.glPushMatrix(); GL11.glScalef(f1, -f1, -f1); MODEL_SIGN.renderSign(); GL11.glPopMatrix(); FontRenderer fontrenderer = this.getFontRenderer(); f2 = 0.016666668F * f1; GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1); GL11.glScalef(f2, -f2, f2); GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2); GL11.glDepthMask(false); byte b0 = 0; for (int j = 0; j < signText.length; ++j) { GL11.glPushMatrix(); String s = signText[j]; int width = fontrenderer.getStringWidth(s); if (width > 95) { float f = 1f - ((width) * 0.0015f); GL11.glScalef(f, f, f); } fontrenderer.drawString(s, -width / 2, j * 10 - signText.length * 5, b0); GL11.glPopMatrix(); } GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); }
From source file:ccm.placeableTools.client.ToolRenderer.java
License:Open Source License
public static void doRenderPass(int i, int meta, ItemStack stack, double x, double y, double z) { Icon icon = stack.getItem().getIcon(stack, i); if (icon == null) return;//from w ww.ja v a 2 s.co m GL11.glPushMatrix(); TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); texturemanager.bindTexture(texturemanager.getResourceLocation(stack.getItemSpriteNumber())); Tessellator tessellator = Tessellator.instance; GL11.glTranslated(x, y, z); //Center to block GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef(-0.5f, .5f, 0.5f); // Center on block if (stack.getItem() instanceof ItemSpade || stack.getItem() instanceof ItemHoe) { float shift = 0.3f; switch (ForgeDirection.values()[meta]) { case NORTH: GL11.glTranslatef(0, 0, -shift); GL11.glRotatef(15f, -0.5f, 0, 0); break; case SOUTH: GL11.glTranslatef(0, 0, shift); GL11.glRotatef(-15f, -0.5f, 0, 0); break; case EAST: GL11.glRotatef(90f, 0, 1, 0); GL11.glTranslatef(-1, 0, 1); GL11.glTranslatef(0, 0, shift); GL11.glRotatef(-15f, -0.5f, 0, 0); break; case WEST: GL11.glRotatef(90f, 0, 1, 0); GL11.glTranslatef(-1, 0, 1); GL11.glTranslatef(0, 0, -shift); GL11.glRotatef(15f, -0.5f, 0, 0); break; case DOWN: GL11.glRotatef(90f, 0, 1, 0); GL11.glTranslatef(-1, 0, 1); break; } GL11.glTranslatef(0, 0, -0.03f); //Icon depth of the shovel GL11.glRotatef(180f, 1, 0, 0); } else if (stack.getItem() instanceof ItemAxe || stack.getItem() instanceof ItemPickaxe) { float shift = 0.15f; switch (ForgeDirection.values()[meta]) { case NORTH: GL11.glRotatef(90f, 0, 1, 0); GL11.glTranslatef(-1, 0, 1); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-10f, 0, 0, 1); break; case SOUTH: GL11.glRotatef(-90f, 0, 1, 0); GL11.glTranslatef(-1, 0, -1); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-10f, 0, 0, 1); break; case EAST: GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-10f, 0, 0, 1); break; case WEST: GL11.glRotatef(180f, 0, 1, 0); GL11.glTranslatef(-2, 0, 0); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-10f, 0, 0, 1); break; } GL11.glTranslatef(0, 0, 0.03F); } else if (stack.getItem() instanceof ItemSword) { float shift = 0.15f; switch (ForgeDirection.values()[meta]) { case NORTH: GL11.glRotatef(90f, 0, 1, 0); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-90f, 0, 0, 1); GL11.glTranslatef(-1, 0, 1); break; case SOUTH: GL11.glRotatef(-90f, 0, 1, 0); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-90f, 0, 0, 1); GL11.glTranslatef(-1, 0, -1); break; case EAST: GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-90f, 0, 0, 1); GL11.glTranslatef(-1, 1, 0); break; case WEST: GL11.glRotatef(180f, 0, 1, 0); GL11.glTranslatef(-1, 1, 0); GL11.glTranslatef(shift, 0, 0); GL11.glRotatef(-90f, 0, 0, 1); break; case UP: GL11.glRotatef(180f, 1, 0, 0); GL11.glTranslatef(1, 0, 1); GL11.glRotatef(90f, 0, 1, 0); break; case DOWN: GL11.glRotatef(180f, 1, 0, 0); break; } GL11.glTranslatef(-0.05f, 0, 0.03F); } GL11.glRotatef(-45f, 0, 0, 1); GL11.glScalef(1.5f, 1.5f, 1.5f); ItemRenderer.renderItemIn2D(tessellator, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.06F / 1.5f); if (stack.hasEffect(i)) { GL11.glDepthFunc(GL11.GL_EQUAL); GL11.glDisable(GL11.GL_LIGHTING); texturemanager.bindTexture(RES_ITEM_GLINT); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); float f7 = 0.76F; GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); float f8 = 0.125F; GL11.glScalef(f8, f8, f8); float f9 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F; GL11.glTranslatef(f9, 0.0F, 0.0F); GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.06F / 1.5f); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glScalef(f8, f8, f8); f9 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F; GL11.glTranslatef(-f9, 0.0F, 0.0F); GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.06F / 1.5f); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthFunc(GL11.GL_LEQUAL); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); }
From source file:cd4017be.automation.render.TileEntityAntimatterBombRenderer.java
public void render(AntimatterBomb amBomb, double x, double y, double z, float par8) { GL11.glPushMatrix();//from w w w .j a v a 2s. c o m GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); int r = amBomb.getWorldObj().getBlockMetadata(amBomb.xCoord, amBomb.yCoord, amBomb.zCoord); float rotationYaw = r == 2 ? 0F : r == 5 ? 90F : r == 3 ? 180F : 270F; GL11.glRotatef(rotationYaw, 0F, -1F, 0F); FontRenderer txtR = manager.getFontRenderer(); GL11.glTranslatef(0F, 0F, -0.51F); float f = 0.03125F; GL11.glScalef(-f, -f, f); String s; if (amBomb.timer >= 0) { s = (amBomb.timer) + "t"; } else { s = Utils.formatNumber(amBomb.antimatter * 0.000000001D, 3, 0) + "g"; } txtR.drawString(s, -txtR.getStringWidth(s) / 2, -4, 0xff0000); GL11.glPopMatrix(); }
From source file:chb.mods.mffs.client.TECapacitorRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityCapacitor) { TileEntityCapacitor topview = (TileEntityCapacitor) tileEntity; GL11.glPushMatrix();/*from ww w .ja v a 2 s . c o m*/ GL11.glPolygonOffset(-10, -10); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); int side = topview.getSide(); float dx = 1F / 16; float dz = 1F / 16; float displayWidth = 1 - 2F / 16; float displayHeight = 1 - 2F / 16; GL11.glTranslatef((float) x, (float) y, (float) z); switch (side) { case 1: break; case 0: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 1, 0); break; case 3: GL11.glTranslatef(0, 1, 0); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 2: GL11.glTranslatef(1, 1, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 5: GL11.glTranslatef(0, 1, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 4: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; } GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); GL11.glRotatef(-90, 1, 0, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FontRenderer fontRenderer = this.getFontRenderer(); int maxWidth = 1; String header = "MFFS Capacitor"; maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth); maxWidth += 4; int lineHeight = fontRenderer.FONT_HEIGHT + 2; int requiredHeight = lineHeight * 1; float scaleX = displayWidth / maxWidth; float scaleY = displayHeight / requiredHeight; float scale = Math.min(scaleX, scaleY); GL11.glScalef(scale, -scale, scale); GL11.glDepthMask(false); int offsetX; int offsetY; int realHeight = (int) Math.floor(displayHeight / scale); int realWidth = (int) Math.floor(displayWidth / scale); if (scaleX < scaleY) { offsetX = 2; offsetY = (realHeight - requiredHeight) / 2; } else { offsetX = (realWidth - maxWidth) / 2 + 2; offsetY = 0; } GL11.glDisable(GL11.GL_LIGHTING); fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight, 1); fontRenderer.drawString("capacity: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getCapacity()).concat(" % "), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getCapacity()).concat(" % ")), offsetY - realHeight / 2 - 0 * lineHeight, 1); fontRenderer.drawString("range: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getTransmitRange()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getTransmitRange())), offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString("linked device: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 2 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getLinketProjektor()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getLinketProjektor())), offsetY - realHeight / 2 + 2 * lineHeight, 1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPopMatrix(); } }
From source file:chb.mods.mffs.client.TEExtractorRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityExtractor) { TileEntityExtractor topview = (TileEntityExtractor) tileEntity; GL11.glPushMatrix();/*from ww w . ja va 2 s. c o m*/ GL11.glPolygonOffset(-10, -10); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); int side = topview.getSide(); float dx = 1F / 16; float dz = 1F / 16; float displayWidth = 1 - 2F / 16; float displayHeight = 1 - 2F / 16; GL11.glTranslatef((float) x, (float) y, (float) z); switch (side) { case 1: break; case 0: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 1, 0); break; case 3: GL11.glTranslatef(0, 1, 0); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 2: GL11.glTranslatef(1, 1, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 5: GL11.glTranslatef(0, 1, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 4: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; } GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); GL11.glRotatef(-90, 1, 0, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FontRenderer fontRenderer = this.getFontRenderer(); int maxWidth = 1; String header = "MFFS Extractor"; maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth); maxWidth += 4; int lineHeight = fontRenderer.FONT_HEIGHT + 2; int requiredHeight = lineHeight * 1; float scaleX = displayWidth / maxWidth; float scaleY = displayHeight / requiredHeight; float scale = Math.min(scaleX, scaleY); GL11.glScalef(scale, -scale, scale); GL11.glDepthMask(false); int offsetX; int offsetY; int realHeight = (int) Math.floor(displayHeight / scale); int realWidth = (int) Math.floor(displayWidth / scale); if (scaleX < scaleY) { offsetX = 2; offsetY = (realHeight - requiredHeight) / 2; } else { offsetX = (realWidth - maxWidth) / 2 + 2; offsetY = 0; } GL11.glDisable(GL11.GL_LIGHTING); fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight, 1); fontRenderer.drawString("WE:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -0 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getWorkdone()).concat(" % "), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getWorkdone()).concat(" % ")), offsetY - realHeight / 2 - 0 * lineHeight, 1); fontRenderer.drawString("WC left:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getWorkCylce()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getWorkCylce())), offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString("FE Cap:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 2 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getForceEnergybuffer() / 1000).concat("k"), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth( String.valueOf(topview.getForceEnergybuffer() / 1000).concat("k")), offsetY - realHeight / 2 + 2 * lineHeight, 1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPopMatrix(); } }
From source file:chemistry.electrolysm.client.itemRenderers.ItemRendererBunsenBurner.java
License:Open Source License
@Override public void render(float x, float y, float z) { GL11.glPushMatrix();/*from w ww .j av a 2s .co m*/ GL11.glTranslatef(x, y, z); GL11.glTranslatef(0.2F, 1F, 0F); if (meta == 0) { FMLClientHandler.instance().getClient().renderEngine.bindTexture(CommonProxy.MODEL_BB_GAS); } else if (meta == 1) { FMLClientHandler.instance().getClient().renderEngine.bindTexture(CommonProxy.MODEL_BB_ELECTRIC); } else { FMLClientHandler.instance().getClient().renderEngine.bindTexture(CommonProxy.MODEL_BUNSEN_BURNER); } GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); // Render model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //model.renderStand(0.0625F); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); GL11.glPopMatrix(); }
From source file:chemistry.electrolysm.client.itemRenderers.ItemRendererTripod.java
License:Open Source License
@Override public void render(float x, float y, float z) { GL11.glPushMatrix();/* ww w. ja v a 2 s . c om*/ GL11.glTranslatef(x, y, z); GL11.glTranslatef(0.2F, 1F, 0F); FMLClientHandler.instance().getClient().renderEngine.bindTexture(CommonProxy.MODEL_BUNSEN_BURNER); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); // Render //model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); model.renderStand(0.0625F); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); GL11.glPopMatrix(); }
From source file:chemistry.electrolysm.client.RenderTileBunsenBurner.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float v4) { renderTripod = ((TileEntityBunsenBurner) tileEntity).hasStand(); renderTestTube = ((TileEntityBunsenBurner) tileEntity).hasTestTube(); //System.out.println("render"); GL11.glPushMatrix();/*from w w w .jav a2 s . co m*/ GL11.glEnable(GL11.GL_LIGHTING); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); rotateByMeta(tileEntity.getBlockMetadata()); Block block = tileEntity.getWorldObj().getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); if (block instanceof BlockBBElectric) { bindTexture(CommonProxy.MODEL_BB_ELECTRIC); } else if (block instanceof BlockBBGas) { bindTexture(CommonProxy.MODEL_BB_GAS); } else { bindTexture(CommonProxy.MODEL_BUNSEN_BURNER); } GL11.glScalef(1.0F, -1.0F, -1.0F); model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); if (renderTripod) { model.renderStand(0.0625F); if (renderTestTube) { model.renderTestTube(0.0625F); } } GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); }
From source file:chemistry.electrolysm.client.RenderTileCleaner.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float v4) { GL11.glPushMatrix();//from w ww. jav a 2s .co m GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); bindTexture(CommonProxy.MODEL_CLEANER); GL11.glScalef(1.0F, -1.0F, -1.0F); rotateByMeta(tileEntity.getBlockMetadata()); model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); if (((TileEntityCleaner) tileEntity).tankWater .getFluidAmount() >= (((TileEntityCleaner) tileEntity).tankWater.getCapacity() / 2)) { model.renderLiquid(0.0625F); } GL11.glPopMatrix(); }
From source file:chemistry.electrolysm.client.RenderTileMassSpec.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float v4) { GL11.glPushMatrix();/*from ww w . jav a 2 s. c o m*/ GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); bindTexture(CommonProxy.MODEL_MASS_SPEC); GL11.glScalef(1.0F, -1.0F, -1.0F); rotateByMeta(tileEntity.getBlockMetadata()); model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); }