List of usage examples for org.lwjgl.opengl GL11 glDepthMask
public static void glDepthMask(@NativeType("GLboolean") boolean flag)
From source file:tk.wurst_client.features.mods.AutoBuildMod.java
License:Open Source License
@Override public void onRender() { if (!building || blockIndex >= positions.size()) return;/*from w w w.j a v a 2 s . c o m*/ // scale and offset double scale = 1D * 7D / 8D; double offset = (1D - scale) / 2D; // GL settings GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glLineWidth(2F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glPushMatrix(); GL11.glTranslated(-mc.getRenderManager().renderPosX, -mc.getRenderManager().renderPosY, -mc.getRenderManager().renderPosZ); // green box { GL11.glDepthMask(false); GL11.glColor4f(0F, 1F, 0F, 0.15F); BlockPos pos = positions.get(blockIndex); GL11.glPushMatrix(); GL11.glTranslated(pos.getX(), pos.getY(), pos.getZ()); GL11.glTranslated(offset, offset, offset); GL11.glScaled(scale, scale, scale); RenderUtils.drawSolidBox(); GL11.glPopMatrix(); GL11.glDepthMask(true); } // black outlines GL11.glColor4f(0F, 0F, 0F, 0.5F); for (int i = blockIndex; i < positions.size(); i++) { BlockPos pos = positions.get(i); GL11.glPushMatrix(); GL11.glTranslated(pos.getX(), pos.getY(), pos.getZ()); GL11.glTranslated(offset, offset, offset); GL11.glScaled(scale, scale, scale); RenderUtils.drawOutlinedBox(); GL11.glPopMatrix(); } GL11.glPopMatrix(); // GL resets GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); }
From source file:tk.wurst_client.features.mods.TrajectoriesMod.java
License:Open Source License
@Override public void onRender() { EntityPlayerSP player = mc.player;/* w w w. jav a 2 s. co m*/ // check if player is holding item ItemStack stack = player.inventory.getCurrentItem(); if (stack == null) return; // check if item is throwable Item item = stack.getItem(); if (!(item instanceof ItemBow || item instanceof ItemSnowball || item instanceof ItemEgg || item instanceof ItemEnderPearl || item instanceof ItemSplashPotion || item instanceof ItemLingeringPotion || item instanceof ItemFishingRod)) return; boolean usingBow = player.inventory.getCurrentItem().getItem() instanceof ItemBow; // calculate starting position double arrowPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * mc.timer.renderPartialTicks - MathHelper.cos((float) Math.toRadians(player.rotationYaw)) * 0.16F; double arrowPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().timer.renderPartialTicks + player.getEyeHeight() - 0.1; double arrowPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().timer.renderPartialTicks - MathHelper.sin((float) Math.toRadians(player.rotationYaw)) * 0.16F; // calculate starting motion float arrowMotionFactor = usingBow ? 1F : 0.4F; float yaw = (float) Math.toRadians(player.rotationYaw); float pitch = (float) Math.toRadians(player.rotationPitch); float arrowMotionX = -MathHelper.sin(yaw) * MathHelper.cos(pitch) * arrowMotionFactor; float arrowMotionY = -MathHelper.sin(pitch) * arrowMotionFactor; float arrowMotionZ = MathHelper.cos(yaw) * MathHelper.cos(pitch) * arrowMotionFactor; double arrowMotion = Math .sqrt(arrowMotionX * arrowMotionX + arrowMotionY * arrowMotionY + arrowMotionZ * arrowMotionZ); arrowMotionX /= arrowMotion; arrowMotionY /= arrowMotion; arrowMotionZ /= arrowMotion; if (usingBow) { float bowPower = (72000 - player.getItemInUseCount()) / 20F; bowPower = (bowPower * bowPower + bowPower * 2F) / 3F; if (bowPower > 1F) bowPower = 1F; if (bowPower <= 0.1F) bowPower = 1F; bowPower *= 3F; arrowMotionX *= bowPower; arrowMotionY *= bowPower; arrowMotionZ *= bowPower; } else { arrowMotionX *= 1.5D; arrowMotionY *= 1.5D; arrowMotionZ *= 1.5D; } // GL settings GL11.glPushMatrix(); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glBlendFunc(770, 771); GL11.glEnable(3042); GL11.glDisable(3553); GL11.glDisable(2929); GL11.glEnable(GL13.GL_MULTISAMPLE); GL11.glDepthMask(false); GL11.glLineWidth(1.8F); RenderManager renderManager = mc.getRenderManager(); // draw trajectory line double gravity = usingBow ? 0.05D : item instanceof ItemPotion ? 0.4D : item instanceof ItemFishingRod ? 0.15D : 0.03D; Vec3d playerVector = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ); GL11.glColor3d(0, 1, 0); GL11.glBegin(GL11.GL_LINE_STRIP); for (int i = 0; i < 1000; i++) { GL11.glVertex3d(arrowPosX - renderManager.renderPosX, arrowPosY - renderManager.renderPosY, arrowPosZ - renderManager.renderPosZ); arrowPosX += arrowMotionX * 0.1; arrowPosY += arrowMotionY * 0.1; arrowPosZ += arrowMotionZ * 0.1; arrowMotionX *= 0.999D; arrowMotionY *= 0.999D; arrowMotionZ *= 0.999D; arrowMotionY -= gravity * 0.1; if (mc.world.rayTraceBlocks(playerVector, new Vec3d(arrowPosX, arrowPosY, arrowPosZ)) != null) break; } GL11.glEnd(); // draw end of trajectory line double renderX = arrowPosX - renderManager.renderPosX; double renderY = arrowPosY - renderManager.renderPosY; double renderZ = arrowPosZ - renderManager.renderPosZ; AxisAlignedBB bb = new AxisAlignedBB(renderX - 0.5, renderY - 0.5, renderZ - 0.5, renderX + 0.5, renderY + 0.5, renderZ + 0.5); GL11.glColor4f(0F, 1F, 0F, 0.15F); RenderUtils.drawColorBox(bb, 0F, 1F, 0F, 0.15F); GL11.glColor4d(0, 0, 0, 0.5F); RenderUtils.drawSelectionBoundingBox(bb); // GL resets GL11.glDisable(3042); GL11.glEnable(3553); GL11.glEnable(2929); GL11.glDisable(GL13.GL_MULTISAMPLE); GL11.glDepthMask(true); GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glPopMatrix(); }
From source file:tk.wurst_client.gui.UIRenderer.java
License:Open Source License
public static void renderUI(float zLevel) { if (!WurstClient.INSTANCE.isEnabled()) return;/*from w ww .j a v a2 s. com*/ // GL settings glEnable(GL_BLEND); glDisable(GL_CULL_FACE); glDisable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); RenderUtils.setColor(new Color(255, 255, 255, 128)); // get version string String version = "v" + WurstClient.VERSION + (WurstClient.INSTANCE.updater.isOutdated() ? " (outdated)" : ""); // draw version background glBegin(GL_QUADS); { glVertex2d(0, 6); glVertex2d(Fonts.segoe22.getStringWidth(version) + 78, 6); glVertex2d(Fonts.segoe22.getStringWidth(version) + 78, 18); glVertex2d(0, 18); } glEnd(); // draw version string glEnable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); Fonts.segoe22.drawString(version, 74, 4, 0xFF000000); // mod list renderModList(); // Wurst logo OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(wurstLogo); int x = 0; int y = 3; int w = 72; int h = 18; float fw = 72; float fh = 18; float u = 0; float v = 0; Gui.drawModalRectWithCustomSizedTexture(x, y, u, v, w, h, fw, fh); // GUI render event WurstClient.INSTANCE.events.fire(GUIRenderEvent.INSTANCE); // GL resets GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); // is this needed? GL11.glPushMatrix(); GL11.glPopMatrix(); }
From source file:tk.wurst_client.utils.RenderUtils.java
License:Open Source License
/** * Renders an ESP box with the size of a normal block at the specified * BlockPos./*from ww w. ja v a2 s. c o m*/ */ public static void blockEsp(BlockPos blockPos, double red, double green, double blue) { double x = blockPos.getX() - Minecraft.getMinecraft().getRenderManager().renderPosX; double y = blockPos.getY() - Minecraft.getMinecraft().getRenderManager().renderPosY; double z = blockPos.getZ() - Minecraft.getMinecraft().getRenderManager().renderPosZ; GL11.glBlendFunc(770, 771); GL11.glEnable(GL_BLEND); GL11.glLineWidth(1.0F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glColor4d(red, green, blue, 0.15); drawColorBox(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0), 0F, 0F, 0F, 0F); GL11.glColor4d(0, 0, 0, 0.5); drawSelectionBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0)); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL_DEPTH_TEST); GL11.glDepthMask(true); GL11.glDisable(GL_BLEND); }
From source file:tk.wurst_client.utils.RenderUtils.java
License:Open Source License
public static void entityESPBox(Entity entity, int mode) { GL11.glBlendFunc(770, 771);// w w w .ja va2s . c o m GL11.glEnable(GL_BLEND); GL11.glLineWidth(2.0F); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL_DEPTH_TEST); GL11.glDepthMask(false); if (mode == 0)// Enemy GL11.glColor4d(1 - Minecraft.getMinecraft().player.getDistanceToEntity(entity) / 40, Minecraft.getMinecraft().player.getDistanceToEntity(entity) / 40, 0, 0.5F); else if (mode == 1)// Friend GL11.glColor4d(0, 0, 1, 0.5F); else if (mode == 2)// Other GL11.glColor4d(1, 1, 0, 0.5F); else if (mode == 3)// Target GL11.glColor4d(1, 0, 0, 0.5F); else if (mode == 4)// Team GL11.glColor4d(0, 1, 0, 0.5F); RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); drawSelectionBoundingBox(new AxisAlignedBB( entity.boundingBox.minX - 0.05 - entity.posX + (entity.posX - renderManager.renderPosX), entity.boundingBox.minY - entity.posY + (entity.posY - renderManager.renderPosY), entity.boundingBox.minZ - 0.05 - entity.posZ + (entity.posZ - renderManager.renderPosZ), entity.boundingBox.maxX + 0.05 - entity.posX + (entity.posX - renderManager.renderPosX), entity.boundingBox.maxY + 0.1 - entity.posY + (entity.posY - renderManager.renderPosY), entity.boundingBox.maxZ + 0.05 - entity.posZ + (entity.posZ - renderManager.renderPosZ))); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL_DEPTH_TEST); GL11.glDepthMask(true); GL11.glDisable(GL_BLEND); }
From source file:totemic_commons.pokefenn.client.RenderHelper.java
License:MIT License
public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) { Tessellator tessellator = Tessellator.instance; int ticks = (int) (Minecraft.getMinecraft().theWorld.getTotalWorldTime() % 200); if (ticks >= 100) ticks = 200 - ticks - 1;//from w w w .jav a2s . c o m float f1 = ticks / 200F; float f2 = 0F; if (f1 > 0.7F) f2 = (f1 - 0.7F) / 0.2F; Random random = new Random(seed); GL11.glPushMatrix(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(770, 1); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); GL11.glTranslatef(0F, -1F, -2F); GL11.glScalef(xScale, yScale, zScale); for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) { GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); GL11.glRotatef(random.nextFloat() * 360F, 0F, 0F, 1F); GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); GL11.glRotatef(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F); tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); float f3 = random.nextFloat() * 20F + 5F + f2 * 10F; float f4 = random.nextFloat() * 2F + 1F + f2 * 2F; tessellator.setColorRGBA_I(color, (int) (255F * (1F - f2))); tessellator.addVertex(0, 0, 0); tessellator.setColorRGBA_F(0F, 0F, 0F, 0); tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); tessellator.addVertex(0.866D * f4, f3, -0.5F * f4); tessellator.addVertex(0, f3, 1F * f4); tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); tessellator.draw(); } GL11.glDepthMask(true); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glShadeModel(GL11.GL_FLAT); GL11.glColor4f(1F, 1F, 1F, 1F); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPopMatrix(); }
From source file:uk.co.hexeption.darkforge.utils.render.GLUtils.java
License:Open Source License
public static void enableGL2D() { GL11.glDisable(GL11.GL_DEPTH_TEST);// w w w . j av a 2 s .c om GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); }
From source file:vazkii.botania.client.render.tile.RenderTileTinyPotato.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity var1, double d0, double d1, double d2, float var8) { TileTinyPotato potato = (TileTinyPotato) var1; GL11.glPushMatrix();// ww w.j av a2s.c o m GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glColor4f(1F, 1F, 1F, 1F); GL11.glTranslated(d0, d1, d2); Minecraft mc = Minecraft.getMinecraft(); mc.renderEngine.bindTexture(texture); GL11.glTranslatef(0.5F, 1.5F, 0.5F); GL11.glScalef(1F, -1F, -1F); int meta = potato.getWorldObj() == null ? 3 : potato.getBlockMetadata(); float rotY = meta * 90F - 180F; GL11.glRotatef(rotY, 0F, 1F, 0F); float jump = potato.jumpTicks; if (jump > 0) jump += var8; float up = (float) -Math.abs(Math.sin(jump / 10 * Math.PI)) * 0.2F; float rotZ = (float) Math.sin(jump / 10 * Math.PI) * 2; GL11.glTranslatef(0F, up, 0F); GL11.glRotatef(rotZ, 0F, 0F, 1F); model.render(); GL11.glRotatef(-rotZ, 0F, 0F, 1F); GL11.glRotatef(-rotY, 0F, 1F, 0F); GL11.glColor3f(1F, 1F, 1F); GL11.glScalef(1F, -1F, -1F); if (!potato.name.isEmpty()) { GL11.glPushMatrix(); GL11.glTranslatef(0F, -0.6F, 0F); GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F); float f = 1.6F; float f1 = 0.016666668F * f; GL11.glScalef(-f1, -f1, f1); GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslatef(0.0F, 0F / f1, 0.0F); GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); int i = mc.fontRenderer.getStringWidth(potato.name) / 2; tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.addVertex(-i - 1, -1.0D, 0.0D); tessellator.addVertex(-i - 1, 8.0D, 0.0D); tessellator.addVertex(i + 1, 8.0D, 0.0D); tessellator.addVertex(i + 1, -1.0D, 0.0D); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDepthMask(true); mc.fontRenderer.drawString(potato.name, -mc.fontRenderer.getStringWidth(potato.name) / 2, 0, 0xFFFFFF); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_BLEND); GL11.glColor4f(1F, 1F, 1F, 1F); GL11.glScalef(1F / -f1, 1F / -f1, 1F / f1); GL11.glPopMatrix(); } GL11.glPopMatrix(); }
From source file:vazkii.b_baubles.client.core.handler.LightningHandler.java
License:Open Source License
@SubscribeEvent public void onRenderWorldLast(RenderWorldLastEvent event) { Profiler profiler = Minecraft.getMinecraft().mcProfiler; profiler.startSection("botania-particles"); ParticleRenderDispatcher.dispatch(); profiler.startSection("redString"); profiler.endStartSection("lightning"); float frame = event.partialTicks; Entity entity = Minecraft.getMinecraft().thePlayer; TextureManager render = Minecraft.getMinecraft().renderEngine; interpPosX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * frame; interpPosY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * frame; interpPosZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * frame; GL11.glPushMatrix();// w w w . j a v a2s. c o m GL11.glTranslated(-interpPosX, -interpPosY, -interpPosZ); Tessellator tessellator = Tessellator.instance; GL11.glDepthMask(false); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); ParticleRenderDispatcher.lightningCount = 0; render.bindTexture(outsideResource); tessellator.startDrawingQuads(); tessellator.setBrightness(0xF000F0); for (LightningBolt bolt : LightningBolt.boltlist) renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 0, false); tessellator.draw(); render.bindTexture(insideResource); tessellator.startDrawingQuads(); tessellator.setBrightness(0xF000F0); for (LightningBolt bolt : LightningBolt.boltlist) renderBolt(bolt, tessellator, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 1, true); tessellator.draw(); GL11.glDisable(GL11.GL_BLEND); GL11.glDepthMask(true); GL11.glTranslated(interpPosX, interpPosY, interpPosZ); GL11.glPopMatrix(); profiler.endSection(); profiler.endSection(); }
From source file:vazkii.b_baubles.client.core.helper.RenderHelper.java
License:Open Source License
public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) { Tessellator tessellator = Tessellator.instance; int ticks = ClientTickHandler.ticksInGame % 200; if (ticks >= 100) ticks = 200 - ticks - 1;/* w w w.jav a2s . c o m*/ float f1 = ticks / 200F; float f2 = 0F; if (f1 > 0.7F) f2 = (f1 - 0.7F) / 0.2F; Random random = new Random(seed); GL11.glPushMatrix(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glShadeModel(GL11.GL_SMOOTH); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(770, 1); GL11.glDisable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); GL11.glScalef(xScale, yScale, zScale); for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) { GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); GL11.glRotatef(random.nextFloat() * 360F, 0F, 0F, 1F); GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F); GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F); GL11.glRotatef(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F); tessellator.startDrawing(GL11.GL_TRIANGLE_FAN); float f3 = random.nextFloat() * 20F + 5F + f2 * 10F; float f4 = random.nextFloat() * 2F + 1F + f2 * 2F; tessellator.setColorRGBA_I(color, (int) (255F * (1F - f2))); tessellator.addVertex(0, 0, 0); tessellator.setColorRGBA_F(0F, 0F, 0F, 0); tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); tessellator.addVertex(0.866D * f4, f3, -0.5F * f4); tessellator.addVertex(0, f3, 1F * f4); tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4); tessellator.draw(); } GL11.glDepthMask(true); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDisable(GL11.GL_BLEND); GL11.glShadeModel(GL11.GL_FLAT); GL11.glColor4f(1F, 1F, 1F, 1F); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPopMatrix(); }