List of usage examples for org.lwjgl.opengl GL11 glVertex2i
public static native void glVertex2i(@NativeType("GLint") int x, @NativeType("GLint") int y);
From source file:tk.ivybits.engine.gl.GL.java
License:Open Source License
public static void glVertex2i(int a, int b) { GL11.glVertex2i(a, b); }
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 . j a v a 2 s .c om 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();/*from w w w .java 2 s . c o 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();// w ww . j a v a 2 s . c om 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 . j a va 2 s .com*/ 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
/** Draws a circumference **/ public static void drawCircumference(Point origin, int z, int color, int radius) { GL11.glBegin(GL11.GL_LINE_STRIP);/* w ww . ja v a2 s . com*/ Color colorRGB = new Color(color); GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) (0.2 * 255)); for (int i = 0; i < 360; i++) { Point point = MathHelper.getPointInCircle(origin, i, radius); GL11.glVertex2i(point.x, point.y); } GL11.glEnd(); }
From source file:vazkii.tinkerer.client.helper.RenderHelper.java
License:Creative Commons License
/** Draws a line in the plane from point A to point B **/ public static void drawSimpleLine(Point pointA, Point pointB, int z, int color) { GL11.glBegin(GL11.GL_LINES);/*w w w . ja v a 2 s.com*/ Color colorRGB = new Color(color); GL11.glColor4ub((byte) colorRGB.getRed(), (byte) colorRGB.getGreen(), (byte) colorRGB.getBlue(), (byte) (0.2 * 255)); GL11.glVertex2i(pointA.x, pointA.y); GL11.glVertex2i(pointB.x, pointB.y); GL11.glEnd(); }
From source file:yk.myengine.optiseq.states.LWJGLFont.java
/** * <code>buildDisplayList</code> sets up the 256 display lists that are used * to render each font character. Each list quad is 16x16, as defined by the * font image size./* ww w .j a v a 2 s . c om*/ */ public void buildDisplayList() { final int displacement = 10; final int symbolWidth = 16; final int symbolHeight = 16; final int symbolNumX = 16; final int symbolNumY = 16; final int symbolNumber = 256; float cx; float cy; final float texSymSizeX = (float) 1 / symbolNumX; final float texSymSizeY = (float) 1 / symbolNumY; base = GL11.glGenLists(symbolNumber); final float addDisY = texSymSizeY / 100; for (int loop = 0; loop < symbolNumber; loop++) { cx = (loop % symbolNumX) * texSymSizeX; cy = (loop / symbolNumY) * texSymSizeX; GL11.glNewList(base + loop, GL11.GL_COMPILE); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(cx, 1 - cy - addDisY); GL11.glVertex2i(0, symbolHeight); GL11.glTexCoord2f(cx, 1 - cy - texSymSizeY + addDisY); GL11.glVertex2i(0, 0); GL11.glTexCoord2f(cx + texSymSizeX, 1 - cy - texSymSizeY + addDisY); GL11.glVertex2i(symbolWidth, 0); GL11.glTexCoord2f(cx + texSymSizeX, 1 - cy - addDisY); GL11.glVertex2i(symbolWidth, symbolHeight); GL11.glEnd(); GL11.glTranslatef(displacement, 0, 0); GL11.glEndList(); } }
From source file:zildo.fwk.gfx.Ortho.java
License:Open Source License
public void drawChar(int x, int y, char a) { int aa = a;/*from ww w .ja v a2s .co m*/ if (aa != 32) { if (a == '.') { aa = 26; } else if (a == '\'') { aa = 62; } else if (a == '-') { aa = 63; } else if (aa >= 48 && aa <= 57) { aa -= 48 - 28; } else { if (aa >= 'a' && aa <= 'z') { aa -= 'a'; // -1; } else if (aa > 199) { aa -= 161; } else { aa -= 64; } } if (aa >= 0 && aa < fonts.length) { GL11.glBegin(GL11.GL_POINTS); for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { char pixel = fonts[aa][j][i]; if (pixel == 1) { GL11.glVertex2i(x + i, y + j); GL11.glVertex2f(x + i + 0.5f, y + j); // GL11.glVertex2f(x+i+0.5f, y+j+0.5f); // GL11.glVertex2f(x+i, y+j+0.5f); } } } GL11.glEnd(); } } }
From source file:zildo.platform.opengl.LwjglOrtho.java
License:Open Source License
@Override public void drawOneChar(int x, int y, int aa) { GL11.glBegin(GL11.GL_POINTS);//from w ww . j av a2s .c o m for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { char pixel = fonts[aa][j][i]; if (pixel == 1) { GL11.glVertex2i(x + i, y + j); GL11.glVertex2f(x + i + 0.5f, y + j); // GL11.glVertex2f(x+i+0.5f, y+j+0.5f); // GL11.glVertex2f(x+i, y+j+0.5f); } } } GL11.glEnd(); }