List of usage examples for org.lwjgl.opengl GL11 GL_FLAT
int GL_FLAT
To view the source code for org.lwjgl.opengl GL11 GL_FLAT.
Click Source Link
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();// www . j a v a 2 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.helper.RenderHelper.java
License:Creative Commons License
/** Renders a star, similar to the dragon death animation, must be * translated previously **///from w w w. j a va 2 s .co m public static void renderStar(int color, float xScale, float yScale, float zScale) { Tessellator tessellator = Tessellator.instance; net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); int ticks = (int) (ClientTickHandler.elapsedClientTicks % 200); if (ticks >= 100) ticks = 200 - ticks - 1; float f1 = ticks / 200F; float f2 = 0.0F; if (f1 > 0.7F) f2 = (f1 - 0.7F) / 0.2F; Random random = new Random(432L); 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(0.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, 1.0F, 0.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(random.nextFloat() * 360F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(random.nextFloat() * 360F + f1 * 90F, 0.0F, 0.0F, 1.0F); tessellator.startDrawing(6); float f3 = random.nextFloat() * 20F + 5F + f2 * 10F; float f4 = random.nextFloat() * 2.0F + 1.0F + f2 * 2.0F; tessellator.setColorRGBA_I(color, (int) (255F * (1.0F - f2))); tessellator.addVertex(0.0D, 0.0D, 0.0D); tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0); tessellator.addVertex(-0.86599999999999999D * f4, f3, -0.5F * f4); tessellator.addVertex(0.86599999999999999D * f4, f3, -0.5F * f4); tessellator.addVertex(0.0D, f3, 1.0F * f4); tessellator.addVertex(-0.86599999999999999D * 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(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glPopMatrix(); }