List of usage examples for org.lwjgl.opengl GL11 glLineWidth
public static void glLineWidth(@NativeType("GLfloat") float width)
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 ww .java 2s . com // 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.TemplateToolMod.java
License:Open Source License
@Override public void onRender() { // scale and offset double scale = 7D / 8D; double offset = (1D - scale) / 2D; // GL settings GL11.glEnable(GL11.GL_BLEND);/*w w w. j a v a2 s .co m*/ 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.glDisable(GL11.GL_DEPTH_TEST); GL11.glPushMatrix(); GL11.glTranslated(-mc.getRenderManager().renderPosX, -mc.getRenderManager().renderPosY, -mc.getRenderManager().renderPosZ); // area if (area != null) { GL11.glEnable(GL11.GL_DEPTH_TEST); // recently scanned blocks if (step == Step.SCAN_AREA && area.progress < 1) for (int i = Math.max(0, area.blocksFound.size() - area.scanSpeed); i < area.blocksFound .size(); i++) { BlockPos pos = area.blocksFound.get(i); GL11.glPushMatrix(); GL11.glTranslated(pos.getX(), pos.getY(), pos.getZ()); GL11.glTranslated(-0.005, -0.005, -0.005); GL11.glScaled(1.01, 1.01, 1.01); GL11.glColor4f(0F, 1F, 0F, 0.15F); RenderUtils.drawSolidBox(); GL11.glColor4f(0F, 0F, 0F, 0.5F); RenderUtils.drawOutlinedBox(); GL11.glPopMatrix(); } GL11.glPushMatrix(); GL11.glTranslated(area.minX + offset, area.minY + offset, area.minZ + offset); GL11.glScaled(area.sizeX + scale, area.sizeY + scale, area.sizeZ + scale); // area scanner if (area.progress < 1) { GL11.glPushMatrix(); GL11.glTranslated(0, 0, area.progress); GL11.glScaled(1, 1, 0); GL11.glColor4f(0F, 1F, 0F, 0.3F); RenderUtils.drawSolidBox(); GL11.glColor4f(0F, 0F, 0F, 0.5F); RenderUtils.drawOutlinedBox(); GL11.glPopMatrix(); // template scanner } else if (template != null && template.progress > 0) { GL11.glPushMatrix(); GL11.glTranslated(0, 0, template.progress); GL11.glScaled(1, 1, 0); GL11.glColor4f(0F, 1F, 0F, 0.3F); RenderUtils.drawSolidBox(); GL11.glColor4f(0F, 0F, 0F, 0.5F); RenderUtils.drawOutlinedBox(); GL11.glPopMatrix(); } // area box GL11.glColor4f(0F, 0F, 0F, 0.5F); RenderUtils.drawOutlinedBox(); GL11.glPopMatrix(); GL11.glDisable(GL11.GL_DEPTH_TEST); } // sorted blocks if (template != null) { for (BlockPos pos : template.sortedBlocks) { GL11.glPushMatrix(); GL11.glTranslated(pos.getX(), pos.getY(), pos.getZ()); GL11.glTranslated(offset, offset, offset); GL11.glScaled(scale, scale, scale); GL11.glColor4f(0F, 0F, 0F, 0.5F); RenderUtils.drawOutlinedBox(); GL11.glPopMatrix(); } } // selected positions for (Step step : Step.SELECT_POSITION_STEPS) { BlockPos pos = step.pos; if (pos == null) continue; GL11.glPushMatrix(); GL11.glTranslated(pos.getX(), pos.getY(), pos.getZ()); GL11.glTranslated(offset, offset, offset); GL11.glScaled(scale, scale, scale); GL11.glColor4f(0F, 1F, 0F, 0.15F); RenderUtils.drawSolidBox(); GL11.glColor4f(0F, 0F, 0F, 0.5F); RenderUtils.drawOutlinedBox(); GL11.glPopMatrix(); } // posLookingAt if (posLookingAt != null) { GL11.glPushMatrix(); GL11.glTranslated(posLookingAt.getX(), posLookingAt.getY(), posLookingAt.getZ()); GL11.glTranslated(offset, offset, offset); GL11.glScaled(scale, scale, scale); GL11.glColor4f(0.25F, 0.25F, 0.25F, 0.15F); RenderUtils.drawSolidBox(); GL11.glColor4f(0F, 0F, 0F, 0.5F); RenderUtils.drawOutlinedBox(); GL11.glPopMatrix(); } GL11.glPopMatrix(); // GL resets GL11.glEnable(GL11.GL_DEPTH_TEST); 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 . j a va 2s. 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.utils.RenderUtils.java
License:Open Source License
/** * Renders an ESP box with the size of a normal block at the specified * BlockPos./*from w w w . ja va2s. 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);/*from ww w .j av a 2 s . 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:uk.co.hexeption.darkforge.utils.RenderUtils.java
License:Open Source License
public static void drawTri(double x1, double y1, double x2, double y2, double x3, double y3, double width, Color c) {//w w w . j a va 2 s .c om GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GLUtils.glColor(c); GL11.glLineWidth((float) width); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glVertex2d(x1, y1); GL11.glVertex2d(x2, y2); GL11.glVertex2d(x3, y3); GL11.glEnd(); GL11.glDisable(GL11.GL_LINE_SMOOTH); GL11.glEnable(GL11.GL_TEXTURE_2D); }
From source file:vazkii.botania.client.core.handler.BoundTileRenderer.java
License:Open Source License
private static void renderBlockOutlineAt(BlockPos pos, int color, float thickness) { double renderPosX, renderPosY, renderPosZ; try {//from w w w.j a v a 2 s . com renderPosX = (double) ClientMethodHandles.renderPosX_getter .invokeExact(Minecraft.getMinecraft().getRenderManager()); renderPosY = (double) ClientMethodHandles.renderPosY_getter .invokeExact(Minecraft.getMinecraft().getRenderManager()); renderPosZ = (double) ClientMethodHandles.renderPosZ_getter .invokeExact(Minecraft.getMinecraft().getRenderManager()); } catch (Throwable t) { return; } GlStateManager.pushMatrix(); GlStateManager.translate(pos.getX() - renderPosX, pos.getY() - renderPosY, pos.getZ() - renderPosZ + 1); Color colorRGB = new Color(color); GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 255); World world = Minecraft.getMinecraft().theWorld; IBlockState state = world.getBlockState(pos); Block block = state.getBlock(); drawWireframe: { if (block != null) { AxisAlignedBB axis; if (block instanceof IWireframeAABBProvider) axis = ((IWireframeAABBProvider) block).getWireframeAABB(world, pos); else axis = state.getSelectedBoundingBox(world, pos); if (axis == null) break drawWireframe; axis = axis.offset(-pos.getX(), -pos.getY(), -(pos.getZ() + 1)); GlStateManager.scale(1F, 1F, 1F); GL11.glLineWidth(thickness); renderBlockOutline(axis); GL11.glLineWidth(thickness + 3F); GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) 64); renderBlockOutline(axis); } } GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) 255); GlStateManager.popMatrix(); }
From source file:vazkii.botania.client.core.handler.RedStringRenderer.java
License:Open Source License
private static void renderTile(TileRedString tile) { double renderPosX, renderPosY, renderPosZ; try {//from ww w . ja va 2s. c o m renderPosX = (double) ClientMethodHandles.renderPosX_getter .invokeExact(Minecraft.getMinecraft().getRenderManager()); renderPosY = (double) ClientMethodHandles.renderPosY_getter .invokeExact(Minecraft.getMinecraft().getRenderManager()); renderPosZ = (double) ClientMethodHandles.renderPosZ_getter .invokeExact(Minecraft.getMinecraft().getRenderManager()); } catch (Throwable t) { return; } EnumFacing dir = tile.getOrientation(); BlockPos bind = tile.getBinding(); if (bind != null) { GlStateManager.pushMatrix(); GlStateManager.translate(tile.getPos().getX() + 0.5 - renderPosX, tile.getPos().getY() + 0.5 - renderPosY, tile.getPos().getZ() + 0.5 - renderPosZ); Vector3 vecOrig = new Vector3(bind.getX() - tile.getPos().getX(), bind.getY() - tile.getPos().getY(), bind.getZ() - tile.getPos().getZ()); Vector3 vecNorm = vecOrig.normalize(); Vector3 vecMag = vecNorm.multiply(0.025); Vector3 vecApply = vecMag; int stages = (int) (vecOrig.mag() / vecMag.mag()); Tessellator tessellator = Tessellator.getInstance(); GL11.glLineWidth(1F); tessellator.getBuffer().begin(GL11.GL_LINES, DefaultVertexFormats.POSITION); double len = (double) -ClientTickHandler.ticksInGame / 100F + new Random(dir.ordinal() ^ tile.getPos().hashCode()).nextInt(10000); double add = vecMag.mag(); double rand = Math.random() - 0.5; for (int i = 0; i < stages; i++) { addVertexAtWithTranslation(tessellator, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); rand = Math.random() - 0.5; vecApply = vecApply.add(vecMag); len += add; addVertexAtWithTranslation(tessellator, dir, vecApply.x, vecApply.y, vecApply.z, rand, len); } tessellator.draw(); GlStateManager.popMatrix(); } }
From source file:vazkii.botania.common.item.ItemSextant.java
License:Open Source License
@SideOnly(Side.CLIENT) public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { ItemStack onUse = player.getActiveItemStack(); int time = player.getItemInUseCount(); if (onUse == stack && stack.getItem().getMaxItemUseDuration(stack) - time >= 10) { double radius = calculateRadius(stack, player); FontRenderer font = Minecraft.getMinecraft().fontRendererObj; int x = resolution.getScaledWidth() / 2 + 30; int y = resolution.getScaledHeight() / 2; String s = "" + (int) radius; font.drawStringWithShadow(s, x - font.getStringWidth(s) / 2, y - 4, 0xFFFFFF); if (radius > 0) { radius += 4;// ww w .j av a 2 s.com GlStateManager.disableTexture2D(); GL11.glLineWidth(3F); GL11.glBegin(GL11.GL_LINE_STRIP); GlStateManager.color(0F, 1F, 1F, 1F); for (int i = 0; i < 361; i++) { float radian = (float) (i * Math.PI / 180); double xp = x + Math.cos(radian) * radius; double yp = y + Math.sin(radian) * radius; GL11.glVertex2d(xp, yp); } GL11.glEnd(); GlStateManager.enableTexture2D(); } } }
From source file:vazkii.b_baubles.common.item.ItemSextant.java
License:Open Source License
@SideOnly(Side.CLIENT) public static void renderHUD(ScaledResolution resolution, EntityPlayer player, ItemStack stack) { ItemStack onUse = player.getItemInUse(); int time = player.getItemInUseCount(); if (onUse == stack && stack.getItem().getMaxItemUseDuration(stack) - time >= 10) { double radius = calculateRadius(stack, player); FontRenderer font = Minecraft.getMinecraft().fontRenderer; int x = resolution.getScaledWidth() / 2 + 30; int y = resolution.getScaledHeight() / 2; String s = "" + (int) radius; font.drawStringWithShadow(s, x - font.getStringWidth(s) / 2, y - 4, 0xFFFFFF); if (radius > 0) { radius += 4;/*www.j a va 2s . c o m*/ GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glLineWidth(3F); GL11.glBegin(GL11.GL_LINE_STRIP); GL11.glColor4f(0F, 1F, 1F, 1F); for (int i = 0; i < 361; i++) { float radian = (float) ((double) i * Math.PI / 180); double xp = x + Math.cos(radian) * radius; double yp = y + Math.sin(radian) * radius; GL11.glVertex2d(xp, yp); } GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); } } }