List of usage examples for org.lwjgl.opengl GL11 glVertex2d
public static native void glVertex2d(@NativeType("GLdouble") double x, @NativeType("GLdouble") double y);
From source file:tk.wurst_client.gui.alts.GuiAlts.java
License:Open Source License
/** * Draws the screen and all the components in it. */// ww w. j a v a 2s .c o m @Override public void drawScreen(int par1, int par2, float par3) { drawDefaultBackground(); altList.drawScreen(par1, par2, par3); if (altList.getSelectedSlot() != -1 && altList.getSelectedSlot() < GuiAltList.alts.size()) { Alt alt = altList.getSelectedAlt(); AltRenderer.drawAltBack(alt.getNameOrEmail(), (width / 2 - 125) / 2 - 32, height / 2 - 64 - 9, 64, 128); AltRenderer.drawAltBody(alt.getNameOrEmail(), width - (width / 2 - 140) / 2 - 32, height / 2 - 64 - 9, 64, 128); } drawCenteredString(fontRendererObj, "Alt Manager", width / 2, 4, 16777215); drawCenteredString(fontRendererObj, "Alts: " + GuiAltList.alts.size(), width / 2, 14, 10526880); drawCenteredString(fontRendererObj, "premium: " + GuiAltList.premiumAlts + ", cracked: " + GuiAltList.crackedAlts, width / 2, 24, 10526880); if (errorTimer > 0) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL_CULL_FACE); GL11.glEnable(GL_BLEND); GL11.glColor4f(1.0F, 0.0F, 0.0F, (float) errorTimer / 16); GL11.glBegin(GL11.GL_QUADS); { GL11.glVertex2d(0, 0); GL11.glVertex2d(width, 0); GL11.glVertex2d(width, height); GL11.glVertex2d(0, height); } GL11.glEnd(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL_CULL_FACE); GL11.glDisable(GL_BLEND); errorTimer--; } super.drawScreen(par1, par2, par3); }
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) {//from ww w . j a v a 2s . co m 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:uk.co.hexeption.darkforge.utils.RenderUtils.java
License:Open Source License
public static void drawRect(float left, float top, float right, float bottom, Color color) { float var5; if (left < right) { var5 = left; left = right;//w ww.ja v a 2 s .co m right = var5; } if (top < bottom) { var5 = top; top = bottom; bottom = var5; } GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glPushMatrix(); GLUtils.glColor(color); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2d(left, bottom); GL11.glVertex2d(right, bottom); GL11.glVertex2d(right, top); GL11.glVertex2d(left, top); GL11.glEnd(); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
From source file:uk.co.hexeption.darkforge.utils.RenderUtils.java
License:Open Source License
public static void drawRect(float left, float top, float right, float bottom, int color) { float var5; if (left < right) { var5 = left; left = right;/*from w ww .j a v a2s .c om*/ right = var5; } if (top < bottom) { var5 = top; top = bottom; bottom = var5; } GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_LINE_SMOOTH); GL11.glPushMatrix(); GLUtils.glColor(color); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2d(left, bottom); GL11.glVertex2d(right, bottom); GL11.glVertex2d(right, top); GL11.glVertex2d(left, top); GL11.glEnd(); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LINE_SMOOTH); }
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;//from ww w.j av a 2s . c o m 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;//from ww w. j av a2 s. 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); } } }
From source file:vazkii.psi.client.core.helper.PsiRenderHelper.java
public static void renderProgressPie(int x, int y, float progress, ItemStack stack) { Minecraft mc = Minecraft.getMinecraft(); mc.getRenderItem().renderItemAndEffectIntoGUI(stack, x, y); GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT); GL11.glEnable(GL11.GL_STENCIL_TEST); GlStateManager.colorMask(false, false, false, false); GlStateManager.depthMask(false);//from w ww. ja v a2 s. com GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF); GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP); GL11.glStencilMask(0xFF); mc.getRenderItem().renderItemAndEffectIntoGUI(stack, x, y); int r = 10; int centerX = x + 8; int centerY = y + 8; int degs = (int) (360 * progress); float a = 0.5F + 0.2F * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10) * 0.5F + 0.5F); GlStateManager.disableLighting(); GlStateManager.disableTexture2D(); GlStateManager.shadeModel(GL11.GL_SMOOTH); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.colorMask(true, true, true, true); GlStateManager.depthMask(true); GL11.glStencilMask(0x00); GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF); GL11.glBegin(GL11.GL_TRIANGLE_FAN); GlStateManager.color(0F, 0.5F, 0.5F, a); GL11.glVertex2i(centerX, centerY); GlStateManager.color(0F, 1F, 0.5F, a); for (int i = degs; i > 0; i--) { double rad = (i - 90) / 180F * Math.PI; GL11.glVertex2d(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r); } GL11.glVertex2i(centerX, centerY); GL11.glEnd(); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); GlStateManager.shadeModel(GL11.GL_FLAT); GL11.glDisable(GL11.GL_STENCIL_TEST); }
From source file:vazkii.psi.client.gui.GuiSocketSelect.java
@Override public void drawScreen(int mx, int my, float partialTicks) { super.drawScreen(mx, my, partialTicks); GlStateManager.pushMatrix();//w ww . j ava 2s.co m GlStateManager.disableTexture2D(); int x = width / 2; int y = height / 2; int maxRadius = 80; boolean mouseIn = true; float angle = mouseAngle(x, y, mx, my); int highlight = 5; GlStateManager.enableBlend(); GlStateManager.shadeModel(GL11.GL_SMOOTH); int segments = slots.size(); float totalDeg = 0; float degPer = 360F / segments; List<int[]> stringPositions = new ArrayList(); ItemStack cadStack = PsiAPI.getPlayerCAD(Minecraft.getMinecraft().thePlayer); slotSelected = -1; for (int seg = 0; seg < segments; seg++) { boolean mouseInSector = mouseIn && angle > totalDeg && angle < totalDeg + degPer; float radius = Math.max(0F, Math.min((timeIn + partialTicks - seg * 6F / segments) * 40F, maxRadius)); GL11.glBegin(GL11.GL_TRIANGLE_FAN); float gs = 0.25F; if (seg % 2 == 0) gs += 0.1F; float r = gs; float g = gs; float b = gs; float a = 0.4F; if (mouseInSector) { slotSelected = seg; if (cadStack != null) { ICAD cad = (ICAD) cadStack.getItem(); Color color = new Color(cad.getSpellColor(cadStack)); r = color.getRed() / 255F; g = color.getGreen() / 255F; b = color.getBlue() / 255F; } } GlStateManager.color(r, g, b, a); GL11.glVertex2i(x, y); for (float i = degPer; i >= 0; i--) { float rad = (float) ((i + totalDeg) / 180F * Math.PI); double xp = x + Math.cos(rad) * radius; double yp = y + Math.sin(rad) * radius; if (i == (int) (degPer / 2)) stringPositions.add(new int[] { seg, (int) xp, (int) yp, mouseInSector ? 'n' : 'r' }); GL11.glVertex2d(xp, yp); } totalDeg += degPer; GL11.glVertex2i(x, y); GL11.glEnd(); if (mouseInSector) radius -= highlight; } GlStateManager.shadeModel(GL11.GL_FLAT); GlStateManager.enableTexture2D(); for (int[] pos : stringPositions) { int slot = slots.get(pos[0]); int xp = pos[1]; int yp = pos[2]; char c = (char) pos[3]; ItemStack stack = socketable.getBulletInSocket(socketableStack, slot); if (stack != null) { int xsp = xp - 4; int ysp = yp; String name = "\u00a7" + c + stack.getDisplayName(); int width = fontRendererObj.getStringWidth(name); double mod = 0.6; int xdp = (int) ((xp - x) * mod + x); int ydp = (int) ((yp - y) * mod + y); mc.getRenderItem().renderItemIntoGUI(stack, xdp - 8, ydp - 8); if (xsp < x) xsp -= width - 8; if (ysp < y) ysp -= 9; fontRendererObj.drawStringWithShadow(name, xsp, ysp, 0xFFFFFF); mod = 0.8; xdp = (int) ((xp - x) * mod + x); ydp = (int) ((yp - y) * mod + y); mc.renderEngine.bindTexture(signs[slot]); drawModalRectWithCustomSizedTexture(xdp - 8, ydp - 8, 0, 0, 16, 16, 16, 16); } } float stime = 5F; float fract = Math.min(stime, timeIn + partialTicks) / stime; float s = 3F * fract; GlStateManager.enableRescaleNormal(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); RenderHelper.enableGUIStandardItemLighting(); if (controlledStacks != null && controlledStacks.length > 0) { int xs = width / 2 - 18 * controlledStacks.length / 2; int ys = height / 2; for (int i = 0; i < controlledStacks.length; i++) { float yoff = 25F + maxRadius; if (i == controlSlot) yoff += 5F; GlStateManager.translate(0, -yoff * fract, 0F); mc.getRenderItem().renderItemAndEffectIntoGUI(controlledStacks[i], xs + i * 18, ys); GlStateManager.translate(0, yoff * fract, 0F); } } if (socketableStack != null) { GlStateManager.scale(s, s, s); GlStateManager.translate(x / s - 8, y / s - 8, 0); mc.getRenderItem().renderItemAndEffectIntoGUI(socketableStack, 0, 0); } RenderHelper.disableStandardItemLighting(); GlStateManager.disableBlend(); GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); }
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 av a 2 s.co 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.recubed.client.renders.PieChartRender.java
License:Creative Commons License
private static void addVertexForAngle(int x, int y, float i, int radius) { double rad = i / 180F * Math.PI; GL11.glVertex2d(x + Math.cos(rad) * radius, y + Math.sin(rad) * radius); }