Java Code Examples for net.minecraft.client.renderer.GlStateManager#enableCull()
The following examples show how to use
net.minecraft.client.renderer.GlStateManager#enableCull() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiButton.java From WearableBackpacks with MIT License | 6 votes |
@Override public void draw(int mouseX, int mouseY, float partialTicks) { if (!isVisible()) return; boolean isHighlighted = isHighlighted(mouseX, mouseY); if (isSwitchOn()) { GlStateManager.disableCull(); GlStateManager.pushMatrix(); GlStateManager.translate(0, getHeight(), 0); GlStateManager.scale(1, -1, 1); drawButtonBackground(isHighlighted, partialTicks); GlStateManager.popMatrix(); GlStateManager.enableCull(); GlStateManager.pushMatrix(); GlStateManager.translate(0, 1, 0); drawButtonForeground(isHighlighted, partialTicks); GlStateManager.popMatrix(); } else { drawButtonBackground(isHighlighted, partialTicks); drawButtonForeground(isHighlighted, partialTicks); } }
Example 2
Source File: OptionScrollPane.java From NotEnoughItems with MIT License | 6 votes |
public static void drawOverlayGrad(int x1, int x2, int y1, int y2, float zLevel) { GlStateManager.disableTexture2D(); GlStateManager.disableCull(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.shadeModel(GL11.GL_SMOOTH); CCRenderState ccrs = CCRenderState.instance(); BufferBuilder buffer = ccrs.startDrawing(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); buffer.pos(x2, y1, zLevel).color(0, 0, 0, 255).endVertex(); buffer.pos(x1, y1, zLevel).color(0, 0, 0, 255).endVertex(); buffer.pos(x1, y2, zLevel).color(0, 0, 0, 0).endVertex(); buffer.pos(x2, y2, zLevel).color(0, 0, 0, 0).endVertex(); ccrs.draw(); GlStateManager.disableBlend(); GlStateManager.enableCull(); GlStateManager.enableTexture2D(); }
Example 3
Source File: RenderUtils.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
public static void renderAreaSides(BlockPos pos1, BlockPos pos2, Color4f color, Entity renderViewEntity, float partialTicks) { GlStateManager.enableBlend(); GlStateManager.disableCull(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); renderAreaSidesBatched(pos1, pos2, color, 0.002, renderViewEntity, partialTicks, buffer); tessellator.draw(); GlStateManager.enableCull(); GlStateManager.disableBlend(); }
Example 4
Source File: PhasedBlockRenderer.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public static BufferBuilder beginRender() { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); GlStateManager.disableTexture2D(); GlStateManager.enableCull(); GlStateManager.cullFace(GlStateManager.CullFace.BACK); GlStateManager.depthMask(false); GlStateManager.enablePolygonOffset(); GlStateManager.doPolygonOffset(-0.1f, -1000f); GlStateManager.enableColorMaterial(); GlStateManager.color(1, 1, 1, 1); GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE); GL14.glBlendEquation(GL14.GL_FUNC_SUBTRACT); BufferBuilder buffer = Tessellator.getInstance().getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL); buffer.setTranslation(-TileEntityRendererDispatcher.staticPlayerX, -TileEntityRendererDispatcher.staticPlayerY, -TileEntityRendererDispatcher.staticPlayerZ); return buffer; }
Example 5
Source File: UIModel.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public void setupGL() { GlStateManager.enableBlend(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.enableCull(); GlStateManager.disableLighting(); }
Example 6
Source File: RenderEventService.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onRenderWorld(RenderWorldLastEvent event) { GlStateManager.pushMatrix(); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.disableDepth(); GlStateManager.glLineWidth(1.f); Vec3d renderPos = EntityUtils.getInterpolatedPos(getRenderEntity(), event.getPartialTicks()); RenderEvent e = new RenderEvent(TESSELLATOR, renderPos, event.getPartialTicks()); e.resetTranslation(); MinecraftForge.EVENT_BUS.post(e); GlStateManager.glLineWidth(1.f); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); GlStateManager.enableDepth(); GlStateManager.enableCull(); GlStateManager.popMatrix(); }
Example 7
Source File: RenderCyberlimbHand.java From Cyberware with MIT License | 5 votes |
private void renderArms() { if (!this.mc.thePlayer.isInvisible()) { GlStateManager.disableCull(); GlStateManager.pushMatrix(); GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); this.renderArm(EnumHandSide.RIGHT); this.renderArm(EnumHandSide.LEFT); GlStateManager.popMatrix(); GlStateManager.enableCull(); } }
Example 8
Source File: RenderCyberlimbHand.java From Cyberware with MIT License | 5 votes |
private void renderArmFirstPerson(float p_187456_1_, float p_187456_2_, EnumHandSide p_187456_3_) { boolean flag = p_187456_3_ != EnumHandSide.LEFT; float f = flag ? 1.0F : -1.0F; float f1 = MathHelper.sqrt_float(p_187456_2_); float f2 = -0.3F * MathHelper.sin(f1 * (float)Math.PI); float f3 = 0.4F * MathHelper.sin(f1 * ((float)Math.PI * 2F)); float f4 = -0.4F * MathHelper.sin(p_187456_2_ * (float)Math.PI); GlStateManager.translate(f * (f2 + 0.64000005F), f3 + -0.6F + p_187456_1_ * -0.6F, f4 + -0.71999997F); GlStateManager.rotate(f * 45.0F, 0.0F, 1.0F, 0.0F); float f5 = MathHelper.sin(p_187456_2_ * p_187456_2_ * (float)Math.PI); float f6 = MathHelper.sin(f1 * (float)Math.PI); GlStateManager.rotate(f * f6 * 70.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(f * f5 * -20.0F, 0.0F, 0.0F, 1.0F); AbstractClientPlayer abstractclientplayer = this.mc.thePlayer; this.mc.getTextureManager().bindTexture(abstractclientplayer.getLocationSkin()); GlStateManager.translate(f * -1.0F, 3.6F, 3.5F); GlStateManager.rotate(f * 120.0F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate(200.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(f * -135.0F, 0.0F, 1.0F, 0.0F); GlStateManager.translate(f * 5.6F, 0.0F, 0.0F); RenderPlayer renderplayer = getEntityRenderObject(this.mc.thePlayer, p_187456_3_); GlStateManager.disableCull(); if (flag) { renderplayer.renderRightArm(abstractclientplayer); } else { renderplayer.renderLeftArm(abstractclientplayer); } GlStateManager.enableCull(); }
Example 9
Source File: UnicornTrailRenderer.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public static void render(RenderWorldLastEvent event) { World world = Minecraft.getMinecraft().world; EntityPlayer player = Minecraft.getMinecraft().player; if (player == null || world == null) return; GlStateManager.pushMatrix(); double interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks(); double interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks(); double interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks(); GlStateManager.translate(-interpPosX, -interpPosY + 0.1, -interpPosZ); GlStateManager.disableCull(); GlStateManager.depthMask(false); GlStateManager.enableBlend(); GlStateManager.disableTexture2D(); GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.blendFunc(GL_SRC_ALPHA, GL_ONE); GlStateManager.enableColorMaterial(); GlStateManager.disableLighting(); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vb = tessellator.getBuffer(); Set<EntityUnicorn> corns = new HashSet<>(positions.keySet()); for (EntityUnicorn corn : corns) { if (corn.world.provider.getDimension() != world.provider.getDimension()) continue; List<Point> points = new ArrayList<>(positions.getOrDefault(corn, new ArrayList<>())); boolean q = false; vb.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_COLOR); for (Point pos : points) { if (pos == null) continue; float sub = (world.getTotalWorldTime() - pos.time); Color color = Color.getHSBColor(sub % 360.0f / 360.0f, 1f, 1f); int alpha; if (sub < 500) { alpha = (int) (MathHelper.clamp(Math.log(sub + 1) / 2.0, 0, 1) * 80.0); } else { alpha = (int) (MathHelper.clamp(1 - (Math.log(sub) / 2.0), 0, 1) * 80.0); } pos(vb, pos.origin.subtract(pos.normal.scale(1.5))).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex(); pos(vb, pos.origin.add(pos.normal.scale(1.5))).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex(); q = !q; } tessellator.draw(); } GlStateManager.enableCull(); GlStateManager.depthMask(true); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); GlStateManager.popMatrix(); }
Example 10
Source File: ParticleRenderer.java From Logistics-Pipes-2 with MIT License | 4 votes |
public void renderParticles(EntityPlayer aPlayer, float pTicks) { float f = ActiveRenderInfo.getRotationX(); float f1 = ActiveRenderInfo.getRotationZ(); float f2 = ActiveRenderInfo.getRotationYZ(); float f3 = ActiveRenderInfo.getRotationXY(); float f4 = ActiveRenderInfo.getRotationXZ(); EntityPlayer player = Minecraft.getMinecraft().player; if(player!=null) { Particle.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * pTicks; Particle.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * pTicks; Particle.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * pTicks; Particle.cameraViewDir = player.getLook(pTicks); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); GlStateManager.alphaFunc(516, 0.003921569F); GlStateManager.disableCull(); GlStateManager.depthMask(false); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Tessellator tess = Tessellator.getInstance(); VertexBuffer buffer = tess.getBuffer(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); for(int i = 0; i < particles.size(); i ++) { if(!((ILP2Particle) particles.get(i)).isAdditive()) { particles.get(i).renderParticle(buffer, player, pTicks, f, f4, f1, f2, f3); } } tess.draw(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP); for(int i = 0; i < particles.size(); i ++) { if(((ILP2Particle) particles.get(i)).isAdditive()) { particles.get(i).renderParticle(buffer, player, pTicks, f, f4, f1, f2, f3); } } tess.draw(); GlStateManager.enableCull(); GlStateManager.depthMask(true); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableBlend(); GlStateManager.alphaFunc(516, 0.1F); } }
Example 11
Source File: BasicNodeTileEntityRenderer.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
private void renderWire(double x, double y, double z, double entity1x, double entity1y, double entity1z, double entity2x, double entity2y, double entity2z) { GlStateManager.enableAlpha(); GlStateManager.enableBlend(); float wireR = .6f; float wireG = .25f; float wireB = .02f; float wireAlpha = 1.0f; // Vec3d vec = new Vec3d(x,y,z); // if (vec.lengthSquared() < .01D) { // System.out.println("REE"); // } // y = .5D; Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); double d0 = 0;// this.interpolateValue(entity.prevRotationYaw, entity.rotationYaw, // partialTicks * 0.5F) * 0.01745329238474369D; double d1 = 0;// this.interpolateValue(entity.prevRotationPitch, entity.rotationPitch, // partialTicks * 0.5F) * 0.01745329238474369D; double d2 = Math.cos(d0); double d3 = Math.sin(d0); double d4 = Math.sin(d1); // if (entity instanceof EntityHanging) // { d4 = -1.0D; // } double fakeYaw = 0;// Math.PI / 6D; double d6 = entity1x; double d7 = entity1y; double d8 = entity1z; double d9 = fakeYaw; d2 = 0;// fakeWidth;; d3 = 0;// fakeWidth; double d10 = entity2x + d2; double d11 = entity2y; double d12 = entity2z + d3; x = x + d2; z = z + d3; double d13 = ((float) (d6 - d10)); double d14 = ((float) (d7 - d11)); double d15 = ((float) (d8 - d12)); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); GlStateManager.disableCull(); int i = 24; double d16 = 0.025D; bufferbuilder.begin(5, DefaultVertexFormats.POSITION_COLOR); for (int j = 0; j <= 24; ++j) { float f3 = j / 24.0F; bufferbuilder.pos(x + d13 * f3 + 0.0D, y + d14 * (f3 * f3 + f3) * 0.5D + ((24.0F - j) / 18.0F + 0.125F), z + d15 * f3).color(wireR, wireG, wireB, wireAlpha).endVertex(); bufferbuilder .pos(x + d13 * f3 + 0.025D, y + d14 * (f3 * f3 + f3) * 0.5D + ((24.0F - j) / 18.0F + 0.125F) + 0.025D, z + d15 * f3) .color(wireR, wireG, wireB, wireAlpha).endVertex(); } tessellator.draw(); bufferbuilder.begin(5, DefaultVertexFormats.POSITION_COLOR); for (int k = 0; k <= 24; ++k) { float f4 = 204F / 255F;// .282F;//0.5F; float f5 = 122F / 255F;// .176F;//0.4F; float f6 = 0;// 0.078F;//0.3F; // f4 *= 2.2F; // f5 *= 2.2F; // f6 *= 2.2F; if (k % 2 == 0) { f4 *= 0.7F; f5 *= 0.7F; f6 *= 0.7F; } float f7 = k / 24.0F; bufferbuilder.pos(x + d13 * f7 + 0.0D, y + d14 * (f7 * f7 + f7) * 0.5D + ((24.0F - k) / 18.0F + 0.125F) + 0.025D, z + d15 * f7) .color(wireR, wireG, wireB, wireAlpha).endVertex(); bufferbuilder.pos(x + d13 * f7 + 0.025D, y + d14 * (f7 * f7 + f7) * 0.5D + ((24.0F - k) / 18.0F + 0.125F), z + d15 * f7 + 0.025D).color(wireR, wireG, wireB, wireAlpha).endVertex(); } tessellator.draw(); GlStateManager.enableLighting(); GlStateManager.enableTexture2D(); GlStateManager.enableCull(); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); }
Example 12
Source File: WorldProviderTorikki.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void render(float partialTicks, WorldClient world, Minecraft mc) { EntityPlayer p = Minecraft.getMinecraft().player; if (p != null) { if (p.getEntityWorld().provider instanceof WorldProviderTorikki) { ResourceLocation img = new ResourceLocation(Wizardry.MODID, "textures/misc/torikki_sky.png"); Minecraft.getMinecraft().renderEngine.bindTexture(img); GlStateManager.pushMatrix(); GlStateManager.disableCull(); GlStateManager.disableFog(); GlStateManager.disableLighting(); GlStateManager.depthMask(false); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexbuffer = tessellator.getBuffer(); for (int i = 0; i < 6; ++i) { GlStateManager.pushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(img); if (i == 3) { Minecraft.getMinecraft().renderEngine.bindTexture(img); GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); } if (i == 1) { Minecraft.getMinecraft().renderEngine.bindTexture(img); GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); } if (i == 2) { Minecraft.getMinecraft().renderEngine.bindTexture(img); GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); } if (i == 4) { Minecraft.getMinecraft().renderEngine.bindTexture(img); GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate(270.0F, 0.0F, 1.0F, 0.0F); } if (i == 5) { Minecraft.getMinecraft().renderEngine.bindTexture(img); GlStateManager.rotate(-90.0F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate(-270.0F, 0.0F, 1.0F, 0.0F); } vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); vertexbuffer.pos(-100.0D, -100.0D, -100.0D).tex(0.0D, 0.0D).endVertex(); vertexbuffer.pos(-100.0D, -100.0D, 100.0D).tex(0.0D, 1.0D).endVertex(); vertexbuffer.pos(100.0D, -100.0D, 100.0D).tex(1.0D, 1.0D).endVertex(); vertexbuffer.pos(100.0D, -100.0D, -100.0D).tex(1.0D, 0.0D).endVertex(); tessellator.draw(); GlStateManager.popMatrix(); } GlStateManager.depthMask(true); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.enableCull(); GlStateManager.enableLighting(); GlStateManager.disableAlpha(); GlStateManager.enableFog(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); } } }
Example 13
Source File: WorldProviderUnderWorld.java From Wizardry with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void render(float partialTicks, WorldClient world, Minecraft mc) { EntityPlayer p = Minecraft.getMinecraft().player; if (p != null) { if (p.getEntityWorld().provider instanceof WorldProviderUnderWorld) { ResourceLocation sides = new ResourceLocation(Wizardry.MODID, "textures/misc/underworld_sky.png"); ResourceLocation top = new ResourceLocation(Wizardry.MODID, "textures/misc/underworld_sky_top.png"); ResourceLocation bottom = new ResourceLocation(Wizardry.MODID, "textures/misc/underworld_sky_bottom.png"); Minecraft.getMinecraft().renderEngine.bindTexture(sides); GlStateManager.pushMatrix(); GlStateManager.disableCull(); GlStateManager.disableFog(); GlStateManager.disableLighting(); GlStateManager.depthMask(false); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexbuffer = tessellator.getBuffer(); for (int i = 0; i < 6; ++i) { GlStateManager.pushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(bottom); if (i == 3) { Minecraft.getMinecraft().renderEngine.bindTexture(top); GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); } if (i == 1) { Minecraft.getMinecraft().renderEngine.bindTexture(sides); GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); } if (i == 2) { Minecraft.getMinecraft().renderEngine.bindTexture(sides); GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); } if (i == 4) { Minecraft.getMinecraft().renderEngine.bindTexture(sides); GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate(270.0F, 0.0F, 1.0F, 0.0F); } if (i == 5) { Minecraft.getMinecraft().renderEngine.bindTexture(sides); GlStateManager.rotate(-90.0F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate(-270.0F, 0.0F, 1.0F, 0.0F); } vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX); vertexbuffer.pos(-100.0D, -100.0D, -100.0D).tex(0.0D, 0.0D).endVertex(); vertexbuffer.pos(-100.0D, -100.0D, 100.0D).tex(0.0D, 1.0D).endVertex(); vertexbuffer.pos(100.0D, -100.0D, 100.0D).tex(1.0D, 1.0D).endVertex(); vertexbuffer.pos(100.0D, -100.0D, -100.0D).tex(1.0D, 0.0D).endVertex(); tessellator.draw(); GlStateManager.popMatrix(); } GlStateManager.depthMask(true); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.enableCull(); GlStateManager.enableLighting(); GlStateManager.disableAlpha(); GlStateManager.enableFog(); GlStateManager.disableBlend(); GlStateManager.popMatrix(); } } }
Example 14
Source File: GuiDownloadTofuTerrain.java From TofuCraftReload with MIT License | 4 votes |
private void drawPanorama(float ticks) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.disableCull(); GlStateManager.depthMask(false); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); byte b0 = 8; for (int k = 0; k < b0 * b0; ++k) { GlStateManager.pushMatrix(); float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F; float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F; float f3 = 0.0F; GlStateManager.translate(f1, f2, f3); GlStateManager.rotate(MathHelper.sin((panoramaTimer + ticks) / 400.0F) * 15.0F + 10.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(-(panoramaTimer + ticks) * 0.08F, 0.0F, 1.0F, 0.0F); for (int l = 0; l < 6; ++l) { GlStateManager.pushMatrix(); switch (l) { case 1: GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); break; case 2: GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); break; case 3: GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); break; case 4: GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); break; case 5: GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); break; } mc.getTextureManager().bindTexture(getPanoramaPaths().getPath(l)); buffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); int i = 255 / (k + 1); buffer.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).color(255, 255, 255, i).endVertex(); buffer.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).color(255, 255, 255, i).endVertex(); buffer.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).color(255, 255, 255, i).endVertex(); buffer.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).color(255, 255, 255, i).endVertex(); tessellator.draw(); GlStateManager.popMatrix(); } GlStateManager.popMatrix(); GlStateManager.colorMask(true, true, true, false); } buffer.setTranslation(0.0D, 0.0D, 0.0D); GlStateManager.colorMask(true, true, true, true); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.popMatrix(); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.popMatrix(); GlStateManager.depthMask(true); GlStateManager.enableCull(); GlStateManager.enableDepth(); }
Example 15
Source File: TESRBarrel.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
protected void renderStack(ItemStack stack, double posX, double posY, double posZ, EnumFacing side, EnumFacing barrelFront) { GlStateManager.pushMatrix(); GlStateManager.translate(posX, posY, posZ); if (side == EnumFacing.UP || side == EnumFacing.DOWN) { GlStateManager.rotate(MODEL_ROT_SIDE_Y[barrelFront.getIndex()], 0, 1, 0); GlStateManager.rotate(-90f * side.getYOffset(), 1, 0, 0); } else { GlStateManager.rotate(MODEL_ROT_SIDE_Y[side.getIndex()], 0, 1, 0); } //GlStateManager.translate(-0.25, 0.2, 0); // This offset is currently added to the renderItemIntoGUI arguments GlStateManager.scale(0.55f, 0.55f, 1); if (this.renderItem.shouldRenderItemIn3D(stack)) { GlStateManager.scale(1 / 16f, -1 / 16f, 0.0001); } else { GlStateManager.scale(1 / 16f, -1 / 16f, 0.01); GlStateManager.translate(0, 0, -100); } // The following rendering stuff within this method has been taken from Storage Drawers by jaquadro, found here: // https://github.com/jaquadro/StorageDrawers/blob/e5719be6d64f757a1b58c25e8ca5bc64074c6b9e/src/com/jaquadro/minecraft/storagedrawers/client/renderer/TileEntityDrawersRenderer.java#L180 // At the time GL_LIGHT* are configured, the coordinates are transformed by the modelview // matrix. The transformations used in `RenderHelper.enableGUIStandardItemLighting` are // suitable for the orthographic projection used by GUI windows, but they are just a little // bit off when rendering a block in 3D and squishing it flat. An additional term is added // to account for slightly different shading on the half-size "icons" in 1x2 and 2x2 // drawers due to the extreme angles caused by flattening the block (as noted below). GlStateManager.pushMatrix(); GlStateManager.scale(2.6f, 2.6f, 1); GlStateManager.rotate(171.6f, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(84.9f, 1.0F, 0.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GlStateManager.popMatrix(); // TileEntitySkullRenderer alters both of these options on, but does not restore them. GlStateManager.enableCull(); // This extra enable toggle is to fix a render glitch with items in Item Frames on screen, // and then hovering over a stack in an inventory... Rendering... always lovely... GlStateManager.enableRescaleNormal(); GlStateManager.disableRescaleNormal(); // GL_POLYGON_OFFSET is used to offset flat icons toward the viewer (-Z) in screen space, // so they always appear on top of the drawer's front space. GlStateManager.enablePolygonOffset(); GlStateManager.doPolygonOffset(-1, -1); // DIRTY HACK: Fool GlStateManager into thinking GL_RESCALE_NORMAL is enabled, but disable // it using popAttrib This prevents RenderItem from enabling it again. // // Normals are transformed by the inverse of the modelview and projection matrices that // excludes the translate terms. When put through the extreme Z scale used to flatten the // block, this makes them point away from the drawer face at a very sharp angle. These // normals are no longer unit scale (normalized), and normalizing them via // GL_RESCALE_NORMAL causes a loss of precision that results in the normals pointing // directly away from the face, which is visible as the block faces having identical // (dark) shading. GlStateManager.pushAttrib(); GlStateManager.enableRescaleNormal(); GlStateManager.popAttrib(); this.renderItem.renderItemIntoGUI(stack, -8, -7); GlStateManager.disableBlend(); // Clean up after RenderItem GlStateManager.enableAlpha(); // Restore world render state after RenderItem GlStateManager.disablePolygonOffset(); GlStateManager.popMatrix(); }
Example 16
Source File: RenderUtils.java From ForgeHax with MIT License | 4 votes |
public static void drawLine( Vec3d startPos, Vec3d endPos, int color, boolean smooth, float width) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder BufferBuilder = tessellator.getBuffer(); Vec3d endVecPos = endPos.subtract(startPos); float r = (float) (color >> 16 & 255) / 255.0F; float g = (float) (color >> 8 & 255) / 255.0F; float b = (float) (color & 255) / 255.0F; float a = (float) (color >> 24 & 255) / 255.0F; if (smooth) { GL11.glEnable(GL11.GL_LINE_SMOOTH); } GL11.glLineWidth(width); GlStateManager.pushMatrix(); GlStateManager.translate(startPos.x, startPos.y, startPos.z); GlStateManager.disableTexture2D(); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); GlStateManager.shadeModel(GL11.GL_SMOOTH); BufferBuilder.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR); BufferBuilder.pos(0, 0, 0).color(r, g, b, a).endVertex(); BufferBuilder.pos(endVecPos.x, endVecPos.y, endVecPos.z).color(r, g, b, a).endVertex(); tessellator.draw(); if (smooth) { GL11.glDisable(GL11.GL_LINE_SMOOTH); } GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.disableBlend(); GlStateManager.enableAlpha(); GlStateManager.enableTexture2D(); GlStateManager.enableDepth(); GlStateManager.enableCull(); GlStateManager.popMatrix(); }
Example 17
Source File: GuiCustom.java From Custom-Main-Menu with MIT License | 4 votes |
private void drawPanorama(int p_73970_1_, int p_73970_2_, float p_73970_3_) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexBuffer = tessellator.getBuffer(); GlStateManager.matrixMode(5889); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F); GlStateManager.matrixMode(5888); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F); GlStateManager.enableBlend(); GlStateManager.disableAlpha(); GlStateManager.disableCull(); GlStateManager.depthMask(false); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); int i = 8; for (int j = 0; j < 64; ++j) { GlStateManager.pushMatrix(); float f = ((float) (j % i) / (float) i - 0.5F) / 64.0F; float f1 = ((float) (j / i) / (float) i - 0.5F) / 64.0F; float f2 = 0.0F; GlStateManager.translate(f, f1, 0.0F); GlStateManager.rotate(MathHelper.sin(this.panoramaTimer / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(-this.panoramaTimer * 0.1F, 0.0F, 1.0F, 0.0F); for (int k = 0; k < 6; ++k) { GlStateManager.pushMatrix(); if (k == 1) { GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F); } if (k == 2) { GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); } if (k == 3) { GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F); } if (k == 4) { GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); } if (k == 5) { GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); } titlePanoramaPaths[k].bind(); vertexBuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); int l = 255 / (j + 1); float f3 = 0.0F; vertexBuffer.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).color(255, 255, 255, l).endVertex(); vertexBuffer.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).color(255, 255, 255, l).endVertex(); vertexBuffer.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).color(255, 255, 255, l).endVertex(); vertexBuffer.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).color(255, 255, 255, l).endVertex(); tessellator.draw(); GlStateManager.popMatrix(); } GlStateManager.popMatrix(); GlStateManager.colorMask(true, true, true, false); } vertexBuffer.setTranslation(0.0D, 0.0D, 0.0D); GlStateManager.colorMask(true, true, true, true); GlStateManager.matrixMode(5889); GlStateManager.popMatrix(); GlStateManager.matrixMode(5888); GlStateManager.popMatrix(); GlStateManager.depthMask(true); GlStateManager.enableCull(); GlStateManager.enableDepth(); }
Example 18
Source File: AnvilHighlightHandler.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void drawBlockHighlightEvent(DrawBlockHighlightEvent evt) { if(evt.getTarget().typeOfHit != RayTraceResult.Type.BLOCK) return; if(evt.getTarget().sideHit != EnumFacing.UP) return; World world = evt.getPlayer().world; if(world.getBlockState(evt.getTarget().getBlockPos()).getBlock() != TFCBlocks.Anvil) return; double posX = evt.getPlayer().lastTickPosX + (evt.getPlayer().posX - evt.getPlayer().lastTickPosX) * evt.getPartialTicks(); double posY = evt.getPlayer().lastTickPosY + (evt.getPlayer().posY - evt.getPlayer().lastTickPosY) * evt.getPartialTicks(); double posZ = evt.getPlayer().lastTickPosZ + (evt.getPlayer().posZ - evt.getPlayer().lastTickPosZ) * evt.getPartialTicks(); double hitX = Math.round((evt.getTarget().hitVec.xCoord - evt.getTarget().getBlockPos().getX())*100)/100.0d; double hitY = Math.round((evt.getTarget().hitVec.yCoord - evt.getTarget().getBlockPos().getY())*100)/100.0d; double hitZ = Math.round((evt.getTarget().hitVec.zCoord - evt.getTarget().getBlockPos().getZ())*100)/100.0d; int divX = (int) Math.floor(hitX * 8); int divY = (int) Math.floor(hitY * 8); int divZ = (int) Math.floor(hitZ * 8); //get the targeted sub block coords double subX = divX/8D; double subY = divY/8D; double subZ = divZ/8D; TileAnvil te = (TileAnvil) world.getTileEntity(evt.getTarget().getBlockPos()); EnumFacing facing = world.getBlockState(evt.getTarget().getBlockPos()).getValue(BlockAnvil.FACING); if(facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) { if(divX == 0 || divX == 7 || divZ < 2 || divZ > 5) return; divX -= 1; divZ -= 2; if(te.getStrikePoint(divX, divZ) == null) return; } if(facing == EnumFacing.EAST || facing == EnumFacing.WEST) { if(divZ == 0 || divZ == 7 || divX < 2 || divX > 5) return; divX -= 2; divZ -= 1; if(te.getStrikePoint(divZ, divX) == null) return; } //create the box size double minX = evt.getTarget().getBlockPos().getX() + subX; double minY = evt.getTarget().getBlockPos().getY() + subY; double minZ = evt.getTarget().getBlockPos().getZ() + subZ; double maxX = minX + 0.125; double maxY = minY + 0.07; double maxZ = minZ + 0.125; GlStateManager.enableBlend(); GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA); GlStateManager.disableCull(); GlStateManager.disableTexture2D(); //Draw the mini Box drawBox(new AxisAlignedBB(minX,minY,minZ,maxX,maxY,maxZ).expand(0.002F, 0.002F, 0.002F).offset(-posX, -posY, -posZ), new float[]{1,0.5f,0, 0.5f}); GlStateManager.enableTexture2D(); GlStateManager.enableCull(); GlStateManager.disableBlend(); }
Example 19
Source File: RenderUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public static void renderEntityDebugBoundingBox(Entity entityIn, float partialTicks, boolean renderLook, boolean renderEyeHeight) { Entity renderViewEntity = Minecraft.getMinecraft().getRenderViewEntity(); double x = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks; double y = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks; double z = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks; x -= renderViewEntity.lastTickPosX + (renderViewEntity.posX - renderViewEntity.lastTickPosX) * (double)partialTicks; y -= renderViewEntity.lastTickPosY + (renderViewEntity.posY - renderViewEntity.lastTickPosY) * (double)partialTicks; z -= renderViewEntity.lastTickPosZ + (renderViewEntity.posZ - renderViewEntity.lastTickPosZ) * (double)partialTicks; GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.depthMask(false); GlStateManager.disableTexture2D(); GlStateManager.disableLighting(); GlStateManager.disableCull(); GlStateManager.disableBlend(); GlStateManager.glLineWidth(1.0F); double entityRadius = entityIn.width / 2.0D; AxisAlignedBB bb = entityIn.getEntityBoundingBox(); RenderGlobal.drawBoundingBox(bb.minX - entityIn.posX + x, bb.minY - entityIn.posY + y, bb.minZ - entityIn.posZ + z, bb.maxX - entityIn.posX + x, bb.maxY - entityIn.posY + y, bb.maxZ - entityIn.posZ + z, 1.0F, 1.0F, 1.0F, 1.0F); if (renderEyeHeight && entityIn instanceof EntityLivingBase) { RenderGlobal.drawBoundingBox(x - entityRadius, y + entityIn.getEyeHeight() - 0.01D, z - entityRadius, x + entityRadius, y + entityIn.getEyeHeight() + 0.01D, z + entityRadius, 1.0F, 0.0F, 0.0F, 1.0F); } if (renderLook) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexbuffer = tessellator.getBuffer(); Vec3d look = entityIn.getLook(partialTicks); vertexbuffer.begin(3, DefaultVertexFormats.POSITION_COLOR); vertexbuffer.pos(x, y + entityIn.getEyeHeight(), z).color(0, 0, 255, 255).endVertex(); vertexbuffer.pos(x + look.x * 2.0D, y + entityIn.getEyeHeight() + look.y * 2.0D, z + look.z * 2.0D).color(0, 0, 255, 255).endVertex(); tessellator.draw(); } GlStateManager.enableTexture2D(); GlStateManager.enableLighting(); GlStateManager.enableCull(); GlStateManager.disableBlend(); GlStateManager.depthMask(true); }
Example 20
Source File: RenderTileEntityStoneMortar.java From Sakura_mod with MIT License | 4 votes |
@Override public void render(TileEntityStoneMortar te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { GlStateManager.enableDepth(); GlStateManager.depthFunc(515); GlStateManager.depthMask(true); GlStateManager.disableCull(); if (destroyStage >= 0) { this.bindTexture(DESTROY_STAGES[destroyStage]); GlStateManager.matrixMode(5890); GlStateManager.pushMatrix(); GlStateManager.scale(4.0F, 4.0F, 1.0F); GlStateManager.translate(0.0625F, 0.0625F, 0.0625F); GlStateManager.matrixMode(5888); } else { this.bindTexture(TEXTURES); } GlStateManager.pushMatrix(); GlStateManager.enableRescaleNormal(); if (destroyStage < 0) { GlStateManager.color(1.0F, 1.0F, 1.0F, alpha); } GlStateManager.translate((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GlStateManager.scale(1.0F, -1.0F, -1.0F); GlStateManager.translate(0.0F, 1.0F, 0.0F); GlStateManager.scale(0.9995F, 0.9995F, 0.9995F); GlStateManager.translate(0.0F, -1.0F, 0.0F); this.model.block1.render(0.0625F); if(te.getUpdateTag().getInteger("processTimer")!=0){ float rot = te.getWorld().getTotalWorldTime() % 360; rot = rot * 2; GlStateManager.rotate(rot, 0.0F, 1.0F, 0.0F); } this.model.block2.render(0.0625F); this.model.handle.render(0.0625F); GlStateManager.enableCull(); GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); if (destroyStage >= 0) { GlStateManager.matrixMode(5890); GlStateManager.popMatrix(); GlStateManager.matrixMode(5888); } }