List of usage examples for org.lwjgl.opengl GL11 glLineWidth
public static void glLineWidth(@NativeType("GLfloat") float width)
From source file:vazkii.recubed.client.renders.PieChartRender.java
License:Creative Commons License
public Entry renderChart(int radius, int x, int y, int mx, int my) { GL11.glPushMatrix();/*from w w w. j a va2 s. c o m*/ GL11.glDisable(GL11.GL_TEXTURE_2D); Entry tooltip = null; float tooltipDeg = 0; boolean mouseIn = (x - mx) * (x - mx) + (y - my) * (y - my) <= radius * radius; float angle = mouseAngle(x, y, mx, my); int highlight = 5; GL11.glShadeModel(GL11.GL_SMOOTH); float totalDeg = 0; for (Entry entry : entries) { boolean mouseInSector = mouseIn && angle > totalDeg && angle < totalDeg + entry.angle; Color color = new Color(entry.color).brighter(); Color color1 = ClientCacheHandler.useGradients ? new Color(entry.color).darker().darker() : color; if (mouseInSector) { tooltip = entry; tooltipDeg = totalDeg; radius += highlight; } GL11.glBegin(GL11.GL_TRIANGLE_FAN); GL11.glColor4ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue(), (byte) 255); GL11.glVertex2i(x, y); GL11.glColor4ub((byte) color1.getRed(), (byte) color1.getGreen(), (byte) color1.getBlue(), (byte) 255); for (float i = entry.angle; i >= 0; i -= 0.01) { float rad = (float) ((i + totalDeg) / 180F * Math.PI); GL11.glVertex2d(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius); } totalDeg += entry.angle; GL11.glColor4ub((byte) 0, (byte) 0, (byte) 0, (byte) 255); GL11.glVertex2i(x, y); GL11.glEnd(); if (mouseInSector) radius -= highlight; } GL11.glShadeModel(GL11.GL_FLAT); totalDeg = 0; GL11.glLineWidth(2F); GL11.glColor4f(0F, 0F, 0F, 1F); for (Entry entry : entries) { if (Math.round(entry.angle) == 360) break; boolean mouseInSector = mouseIn && angle > totalDeg && angle < totalDeg + entry.angle; if (mouseInSector) radius += highlight; float rad = (float) (totalDeg / 180F * Math.PI); GL11.glBegin(GL11.GL_LINES); GL11.glVertex2i(x, y); GL11.glVertex2d(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius); GL11.glEnd(); if (mouseInSector) radius -= highlight; totalDeg += entry.angle; } GL11.glLineWidth(3F); GL11.glColor4f(0F, 0F, 0F, 1F); GL11.glBegin(GL11.GL_LINE_LOOP); for (float i = 0; i < 360; i++) { boolean sectorHighlighted = tooltip != null && i >= tooltipDeg && i < tooltip.angle + tooltipDeg; boolean first = tooltip != null && tooltip.angle != 360 && i - tooltipDeg == 0; boolean last = tooltip != null && tooltip.angle != 360 && i - (tooltipDeg + tooltip.angle) == -1; if (first) addVertexForAngle(x, y, i, radius); if (sectorHighlighted) radius += highlight; addVertexForAngle(x, y, i, radius); if (last) addVertexForAngle(x, y, i + 1, radius); if (sectorHighlighted) radius -= highlight; } GL11.glEnd(); if (tooltip != null) { List<String> tooltipList = new ArrayList( Arrays.asList(StatCollector.translateToLocal(tooltip.name), EnumChatFormatting.GRAY + "" + tooltip.val + " (" + Math.round(tooltip.angle / 3.6F * 100D) / 100D + "%)")); if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips) tooltipList.add(EnumChatFormatting.GRAY + "" + EnumChatFormatting.ITALIC + tooltip.name); RenderHelper.renderTooltip(mx, my, tooltipList); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glPopMatrix(); return tooltip; }
From source file:vazkii.tinkerer.client.gui.kami.GuiWarpGateDestinations.java
License:Creative Commons License
@Override public void drawScreen(int par1, int par2, float par3) { drawDefaultBackground();//from w w w . ja v a 2 s .c om super.drawScreen(par1, par2, par3); tooltip.clear(); int gateX = warpGate.xCoord - x; int gateY = warpGate.zCoord - y; mc.renderEngine.bindTexture(TextureMap.locationItemsTexture); List<Object[]> coords = new ArrayList(); for (int i = 0; i < warpGate.getSizeInventory(); i++) { ItemStack stack = warpGate.getStackInSlot(i); if (stack != null && ItemSkyPearl.isAttuned(stack)) { int dim = ItemSkyPearl.getDim(stack); if (warpGate.worldObj.provider.dimensionId != dim) continue; int x = ItemSkyPearl.getX(stack); int y = ItemSkyPearl.getY(stack); int z = ItemSkyPearl.getZ(stack); if (y != -1) coords.add(new Object[] { x - this.x, z - this.y, stack, i }); } } GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1F, 1F, 1F, (float) ((Math.sin(ticks / 10D) + 1F) / 4F + 0.25F)); GL11.glLineWidth(2F); GL11.glDisable(GL11.GL_TEXTURE_2D); for (Object[] coords_ : coords) { int x = (Integer) coords_[0]; int y = (Integer) coords_[1]; GL11.glBegin(GL11.GL_LINES); GL11.glVertex2i(gateX, gateY); GL11.glVertex2i(x, y); GL11.glEnd(); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); fontRenderer.drawStringWithShadow( EnumChatFormatting.UNDERLINE + StatCollector.translateToLocal("ttmisc.destinations"), 3, 40, 0xFFFFFF); GL11.glColor4f(1F, 1F, 1F, 1F); drawPearlAt(0, null, gateX, gateY, par1, par2); for (Object[] coords_ : coords) drawPearlAt((Integer) coords_[3], (ItemStack) coords_[2], (Integer) coords_[0], (Integer) coords_[1], par1, par2); if (!tooltip.isEmpty()) ClientHelper.renderTooltip(par1, par2, tooltip); drawCenteredString(fontRenderer, StatCollector.translateToLocal("ttmisc.numberKeys"), width / 2, 5, 0xFFFFFF); drawCenteredString(fontRenderer, StatCollector.translateToLocal("ttmisc.spaceToReset"), width / 2, 16, 0xFFFFFF); }
From source file:vazkii.tinkerer.client.helper.RenderHelper.java
License:Creative Commons License
/** Sets the GL values to draw lines **/ public static void startDrawingLines() { GL11.glDisable(GL11.GL_TEXTURE_2D);//from ww w . j ava 2 s. c o m GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glLineWidth(3F); }