List of usage examples for org.lwjgl.opengl GL11 glEnable
public static void glEnable(@NativeType("GLenum") int target)
From source file:cellularautomata.CellularAutomata.java
public static void drawPath(TrueTypeFont trueTypeTitleFont, TrueTypeFont trueTypeDimensionsFont) { updateColour(7);/* w w w . j av a2 s . co m*/ GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(0, 0); GL11.glVertex2f(712, 0); GL11.glVertex2f(712, 600); GL11.glVertex2f(0, 600); GL11.glEnd(); for (int yi = 0; yi < 7; yi++) { updateColour(7); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(712, yi * 86); GL11.glVertex2f(800, yi * 86); GL11.glVertex2f(800, yi * 86 + 85); GL11.glVertex2f(712, yi * 86 + 85); GL11.glEnd(); } for (int yi = 0; yi < 7; yi++) { for (int xi = 0; xi < 10; xi++) { if (yi == 0) { updateColour(0); } else { updateColour(path[yi - 1][xi]); } GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(xi * 62 + 90, yi * 86); GL11.glVertex2f(xi * 62 + 61 + 90, yi * 86); GL11.glVertex2f(xi * 62 + 61 + 90, yi * 86 + 85); GL11.glVertex2f(xi * 62 + 90, yi * 86 + 85); GL11.glEnd(); } } for (int yi = 0; yi < 7; yi++) { for (int xi = 0; xi < 9; xi = xi + 8) { updateColour(yi); if (xi == 0) { GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(0, yi * 86); GL11.glVertex2f(89, yi * 86); GL11.glVertex2f(89, yi * 86 + 85); GL11.glVertex2f(0, yi * 86 + 85); GL11.glEnd(); } } } GL11.glEnable(GL11.GL_TEXTURE_2D); //Enables textures. for (int i = 0; i < 9; i++) { trueTypeTitleFont.drawString(110 + 62 * i, 20, i + 1 + "", Color.black); } trueTypeTitleFont.drawString(668, 20, "0", Color.black); String dimensions = ""; boolean dimensionsSelected = false; for (int yi = 0; yi < 7; yi++) { if (yi == 0) { dimensions = "800 x 600"; if (pixel == 1) { dimensionsSelected = true; borderSize = 0; } else { dimensionsSelected = false; } } if (yi == 1) { dimensions = "400 x 300"; if (pixel == 2) { dimensionsSelected = true; borderSize = 0; } else { dimensionsSelected = false; } } if (yi == 2) { dimensions = "200 x 150"; if (pixel == 4) { dimensionsSelected = true; borderSize = 0; } else { dimensionsSelected = false; } } if (yi == 3) { dimensions = " 80 x 60"; if (pixel == 10) { dimensionsSelected = true; } else { dimensionsSelected = false; } } if (yi == 4) { dimensions = " 32 x 24"; if (pixel == 25) { dimensionsSelected = true; } else { dimensionsSelected = false; } } if (yi == 5) { dimensions = " 16 x 12"; if (pixel == 50) { dimensionsSelected = true; } else { dimensionsSelected = false; } } if (yi == 6) { dimensions = " 8 x 6"; if (pixel == 100) { dimensionsSelected = true; } else { dimensionsSelected = false; } } if (dimensionsSelected) { trueTypeDimensionsFont.drawString(713, 28 + 86 * yi, dimensions, Color.yellow); } else { trueTypeDimensionsFont.drawString(713, 28 + 86 * yi, dimensions, Color.white); } } GL11.glDisable(GL11.GL_TEXTURE_2D); }
From source file:cellularautomata.CellularAutomata.java
public static void drawWeight(int background, int squares, TrueTypeFont trueTypeTitleFont, TrueTypeFont trueTypePaintBrushFont) { updateColour(background);/*w w w. jav a 2s . c o m*/ GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(0, 0); GL11.glVertex2f(711, 0); GL11.glVertex2f(711, 600); GL11.glVertex2f(0, 600); GL11.glEnd(); Color.black.bind(); for (int yi = 0; yi < 7; yi++) { for (int xi = 0; xi < 9; xi++) { updateColour(squares); if (xi == 0) { updateColour(yi); } if (xi == 8) { updateColour(0); } GL11.glBegin(GL11.GL_QUADS); GL11.glVertex2f(xi * 89, yi * 86); GL11.glVertex2f(xi * 89 + 88, yi * 86); GL11.glVertex2f(xi * 89 + 88, yi * 86 + 85); GL11.glVertex2f(xi * 89, yi * 86 + 85); GL11.glEnd(); } } GL11.glEnable(GL11.GL_TEXTURE_2D); //Enables textures. for (int yi = 0; yi < 7; yi++) { for (int xi = 0; xi < 7; xi++) { if (xi != 3 || yi != 3) { if (squares == 1 || squares == 6) { trueTypeTitleFont.drawString(120 + 89 * xi, 20 + 86 * yi, neighbourhood[yi][xi][menuState] + "", Color.white); } else { trueTypeTitleFont.drawString(120 + 89 * xi, 20 + 86 * yi, neighbourhood[yi][xi][menuState] + "", Color.black); } } } } String stateString = ""; for (int yi = 1; yi < 7; yi++) { if (yi == 1) { if (black == 1) { stateString = " Left"; } else if (black == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 25 + 86 * yi, stateString, Color.black); } if (yi == 2) { if (white == 1) { stateString = " Left"; } else if (white == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 25 + 86 * yi, stateString, Color.white); } if (yi == 3) { if (red == 1) { stateString = " Left"; } else if (red == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 25 + 86 * yi, stateString, Color.red); } if (yi == 4) { if (blue == 1) { stateString = " Left"; } else if (blue == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 25 + 86 * yi, stateString, Color.blue); } if (yi == 5) { if (green == 1) { stateString = " Left"; } else if (green == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 25 + 86 * yi, stateString, Color.green.darker(.7f)); } if (yi == 6) { if (purple == 1) { stateString = " Left"; } else if (purple == 2) stateString = "Right"; else { stateString = " Off"; } trueTypePaintBrushFont.drawString(720, 20 + 86 * yi, stateString, Color.magenta.darker(.7f)); } } if (screenState == 1 && menuState != 6) { trueTypeTitleFont.drawString(745, 20, brushRadius + "", Color.black); } GL11.glDisable(GL11.GL_TEXTURE_2D); }
From source file:chb.mods.mffs.client.TECapacitorRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityCapacitor) { TileEntityCapacitor topview = (TileEntityCapacitor) tileEntity; GL11.glPushMatrix();/*from w w w. j a v a 2s . co m*/ GL11.glPolygonOffset(-10, -10); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); int side = topview.getSide(); float dx = 1F / 16; float dz = 1F / 16; float displayWidth = 1 - 2F / 16; float displayHeight = 1 - 2F / 16; GL11.glTranslatef((float) x, (float) y, (float) z); switch (side) { case 1: break; case 0: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 1, 0); break; case 3: GL11.glTranslatef(0, 1, 0); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 2: GL11.glTranslatef(1, 1, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 5: GL11.glTranslatef(0, 1, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 4: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; } GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); GL11.glRotatef(-90, 1, 0, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FontRenderer fontRenderer = this.getFontRenderer(); int maxWidth = 1; String header = "MFFS Capacitor"; maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth); maxWidth += 4; int lineHeight = fontRenderer.FONT_HEIGHT + 2; int requiredHeight = lineHeight * 1; float scaleX = displayWidth / maxWidth; float scaleY = displayHeight / requiredHeight; float scale = Math.min(scaleX, scaleY); GL11.glScalef(scale, -scale, scale); GL11.glDepthMask(false); int offsetX; int offsetY; int realHeight = (int) Math.floor(displayHeight / scale); int realWidth = (int) Math.floor(displayWidth / scale); if (scaleX < scaleY) { offsetX = 2; offsetY = (realHeight - requiredHeight) / 2; } else { offsetX = (realWidth - maxWidth) / 2 + 2; offsetY = 0; } GL11.glDisable(GL11.GL_LIGHTING); fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight, 1); fontRenderer.drawString("capacity: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getCapacity()).concat(" % "), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getCapacity()).concat(" % ")), offsetY - realHeight / 2 - 0 * lineHeight, 1); fontRenderer.drawString("range: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getTransmitRange()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getTransmitRange())), offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString("linked device: ", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 2 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getLinketProjektor()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getLinketProjektor())), offsetY - realHeight / 2 + 2 * lineHeight, 1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPopMatrix(); } }
From source file:chb.mods.mffs.client.TEExtractorRenderer.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) { if (tileEntity instanceof TileEntityExtractor) { TileEntityExtractor topview = (TileEntityExtractor) tileEntity; GL11.glPushMatrix();//from ww w .ja va2s .co m GL11.glPolygonOffset(-10, -10); GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); int side = topview.getSide(); float dx = 1F / 16; float dz = 1F / 16; float displayWidth = 1 - 2F / 16; float displayHeight = 1 - 2F / 16; GL11.glTranslatef((float) x, (float) y, (float) z); switch (side) { case 1: break; case 0: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(180, 0, 1, 0); break; case 3: GL11.glTranslatef(0, 1, 0); GL11.glRotatef(0, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 2: GL11.glTranslatef(1, 1, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 5: GL11.glTranslatef(0, 1, 1); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; case 4: GL11.glTranslatef(1, 1, 0); GL11.glRotatef(-90, 0, 1, 0); GL11.glRotatef(90, 1, 0, 0); break; } GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); GL11.glRotatef(-90, 1, 0, 0); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FontRenderer fontRenderer = this.getFontRenderer(); int maxWidth = 1; String header = "MFFS Extractor"; maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth); maxWidth += 4; int lineHeight = fontRenderer.FONT_HEIGHT + 2; int requiredHeight = lineHeight * 1; float scaleX = displayWidth / maxWidth; float scaleY = displayHeight / requiredHeight; float scale = Math.min(scaleX, scaleY); GL11.glScalef(scale, -scale, scale); GL11.glDepthMask(false); int offsetX; int offsetY; int realHeight = (int) Math.floor(displayHeight / scale); int realWidth = (int) Math.floor(displayWidth / scale); if (scaleX < scaleY) { offsetX = 2; offsetY = (realHeight - requiredHeight) / 2; } else { offsetX = (realWidth - maxWidth) / 2 + 2; offsetY = 0; } GL11.glDisable(GL11.GL_LIGHTING); fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight, 1); fontRenderer.drawString("WE:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -0 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getWorkdone()).concat(" % "), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getWorkdone()).concat(" % ")), offsetY - realHeight / 2 - 0 * lineHeight, 1); fontRenderer.drawString("WC left:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getWorkCylce()), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth(String.valueOf(topview.getWorkCylce())), offsetY - realHeight / 2 + 1 * lineHeight, 1); fontRenderer.drawString("FE Cap:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 2 * lineHeight, 1); fontRenderer.drawString(String.valueOf(topview.getForceEnergybuffer() / 1000).concat("k"), offsetX + realWidth / 2 - offsetX - fontRenderer.getStringWidth( String.valueOf(topview.getForceEnergybuffer() / 1000).concat("k")), offsetY - realHeight / 2 + 2 * lineHeight, 1); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); GL11.glPopMatrix(); } }
From source file:cheatingessentials.mod.internal.ttf.StringCache.java
License:Open Source License
/** * Render a single-line string to the screen using the current OpenGL color. * The (x, y) coordinates are of the uppet-left corner of the string's * bounding box, rather than the baseline position as is typical with fonts. * This function will also add the string to the cache so the next * renderString() call with the same string is faster. * /*from w w w. j a v a 2s . c om*/ * @param str * the string being rendered; it can contain color codes * @param startX * the x coordinate to draw at * @param startY * the y coordinate to draw at * @param initialColor * the initial RGBA color to use when drawing the string; * embedded color codes can override the RGB component * @param shadowFlag * if true, color codes are replaces by a darker version used for * drop shadows * @return the total advance (horizontal distance) of this string * @todo Add optional NumericShaper to replace ASCII digits with locale * specific ones * @todo Add support for the "k" code which randomly replaces letters on * each render (used only by splash screen) * @todo Pre-sort by texture to minimize binds; can store colors per glyph * in string cache * @todo Optimize the underline/strikethrough drawing to draw a single line * for each run */ public int renderString(final String str, final float startX, float startY, final int initialColor, final boolean shadowFlag) { /* Check for invalid arguments */ if ((str == null) || str.isEmpty()) { return 0; } /* * Make sure the entire string is cached before rendering and return its * glyph representation */ final Entry entry = cacheString(str); /* * Adjust the baseline of the string because the startY coordinate in * Minecraft is for the top of the string */ startY += BASELINE_OFFSET; /* * Color currently selected by color code; reapplied to Tessellator * instance after glBindTexture() */ int color = initialColor; /* * Track which texture is currently bound to minimize the number of * glBindTexture() and Tessellator.draw() calls needed */ int boundTextureName = 0; /* * This color change will have no effect on the actual text (since * colors are included in the Tessellator vertex array), however * GuiEditSign of all things depends on having the current color set to * white when it renders its "Edit sign message:" text. Otherwise, the * sign which is rendered underneath would look too dark. */ GL11.glColor3f((color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff); /* * Enable GL_BLEND in case the font is drawn anti-aliased because * Minecraft itself only enables blending for chat text (so it can fade * out), but not GUI text or signs. Minecraft uses multiple blend * functions so it has to be specified here as well for consistent * blending. To reduce the overhead of OpenGL state changes and making * native LWJGL calls, this function doesn't try to save/restore the * blending state. Hopefully everything else that depends on blending in * Minecraft will set its own state as needed. */ if (antiAliasEnabled) { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } /* * Using the Tessellator to queue up data in a vertex array and then * draw all at once should be faster than immediate mode */ final Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.setColorRGBA((color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff, (color >> 24) & 0xff); /* * The currently active font syle is needed to select the proper ASCII * digit style for fast replacement */ int fontStyle = Font.PLAIN; for (int glyphIndex = 0, colorIndex = 0; glyphIndex < entry.glyphs.length; glyphIndex++) { /* * If the original string had a color code at this glyph's position, * then change the current GL color that gets added to the vertex * array. Note that only the RGB component of the color is replaced * by a color code; the alpha component of the original color passed * into this function will remain. The while loop handles multiple * consecutive color codes, in which case only the last such color * code takes effect. */ while ((colorIndex < entry.colors.length) && (entry.glyphs[glyphIndex].stringIndex >= entry.colors[colorIndex].stringIndex)) { color = applyColorCode(entry.colors[colorIndex].colorCode, initialColor, shadowFlag); fontStyle = entry.colors[colorIndex].fontStyle; colorIndex++; } /* * Select the current glyph's texture information and horizontal * layout position within this string */ final Glyph glyph = entry.glyphs[glyphIndex]; GlyphCache.Entry texture = glyph.texture; int glyphX = glyph.x; /* * Replace ASCII digits in the string with their respective glyphs; * strings differing by digits are only cached once. If the new * replacement glyph has a different width than the original * placeholder glyph (e.g. the '1' glyph is often narrower than * other digits), re-center the new glyph over the placeholder's * position to minimize the visual impact of the width mismatch. */ final char c = str.charAt(glyph.stringIndex); if ((c >= '0') && (c <= '9')) { final int oldWidth = texture.width; texture = digitGlyphs[fontStyle][c - '0'].texture; final int newWidth = texture.width; glyphX += (oldWidth - newWidth) >> 1; } /* * Make sure the OpenGL texture storing this glyph's image is bound * (if not already bound). All pending glyphs in the Tessellator's * vertex array must be drawn before switching textures, otherwise * they would erroneously use the new texture as well. */ if (boundTextureName != texture.textureName) { tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setColorRGBA((color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff, (color >> 24) & 0xff); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.textureName); boundTextureName = texture.textureName; } /* * The divide by 2.0F is needed to align with the scaled GUI * coordinate system; startX/startY are already scaled */ final float x1 = startX + ((glyphX) / 2.0F); final float x2 = startX + ((glyphX + texture.width) / 2.0F); final float y1 = startY + ((glyph.y) / 2.0F); final float y2 = startY + ((glyph.y + texture.height) / 2.0F); tessellator.addVertexWithUV(x1, y1, 0, texture.u1, texture.v1); tessellator.addVertexWithUV(x1, y2, 0, texture.u1, texture.v2); tessellator.addVertexWithUV(x2, y2, 0, texture.u2, texture.v2); tessellator.addVertexWithUV(x2, y1, 0, texture.u2, texture.v1); } /* * Draw any remaining glyphs in the Tessellator's vertex array (there * should be at least one glyph pending) */ tessellator.draw(); /* Draw strikethrough and underlines if the string uses them anywhere */ if (entry.specialRender) { int renderStyle = 0; /* * Use initial color passed to renderString(); disable texturing to * draw solid color lines */ color = initialColor; GL11.glDisable(GL11.GL_TEXTURE_2D); tessellator.startDrawingQuads(); tessellator.setColorRGBA((color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff, (color >> 24) & 0xff); for (int glyphIndex = 0, colorIndex = 0; glyphIndex < entry.glyphs.length; glyphIndex++) { /* * If the original string had a color code at this glyph's * position, then change the current GL color that gets added to * the vertex array. The while loop handles multiple consecutive * color codes, in which case only the last such color code * takes effect. */ while ((colorIndex < entry.colors.length) && (entry.glyphs[glyphIndex].stringIndex >= entry.colors[colorIndex].stringIndex)) { color = applyColorCode(entry.colors[colorIndex].colorCode, initialColor, shadowFlag); renderStyle = entry.colors[colorIndex].renderStyle; colorIndex++; } /* * Select the current glyph within this string for its layout * position */ final Glyph glyph = entry.glyphs[glyphIndex]; /* * The strike/underlines are drawn beyond the glyph's width to * include the extra space between glyphs */ final int glyphSpace = glyph.advance - glyph.texture.width; /* Draw underline under glyph if the style is enabled */ if ((renderStyle & ColorCode.UNDERLINE) != 0) { /* * The divide by 2.0F is needed to align with the scaled GUI * coordinate system; startX/startY are already scaled */ final float x1 = startX + ((glyph.x - glyphSpace) / 2.0F); final float x2 = startX + ((glyph.x + glyph.advance) / 2.0F); final float y1 = startY + ((UNDERLINE_OFFSET) / 2.0F); final float y2 = startY + ((UNDERLINE_OFFSET + UNDERLINE_THICKNESS) / 2.0F); tessellator.addVertex(x1, y1, 0); tessellator.addVertex(x1, y2, 0); tessellator.addVertex(x2, y2, 0); tessellator.addVertex(x2, y1, 0); } /* * Draw strikethrough in the middle of glyph if the style is * enabled */ if ((renderStyle & ColorCode.STRIKETHROUGH) != 0) { /* * The divide by 2.0F is needed to align with the scaled GUI * coordinate system; startX/startY are already scaled */ final float x1 = startX + ((glyph.x - glyphSpace) / 2.0F); final float x2 = startX + ((glyph.x + glyph.advance) / 2.0F); final float y1 = startY + ((STRIKETHROUGH_OFFSET) / 2.0F); final float y2 = startY + ((STRIKETHROUGH_OFFSET + STRIKETHROUGH_THICKNESS) / 2.0F); tessellator.addVertex(x1, y1, 0); tessellator.addVertex(x1, y2, 0); tessellator.addVertex(x2, y2, 0); tessellator.addVertex(x2, y1, 0); } } /* Finish drawing the last strikethrough/underline segments */ tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); } if (antiAliasEnabled) { GL11.glDisable(GL11.GL_BLEND); } /* * Return total horizontal advance (slightly wider than the bounding * box, but close enough for centering strings) */ return entry.advance / 2; }
From source file:chemistry.electrolysm.client.itemRenderers.ItemRendererBunsenBurner.java
License:Open Source License
@Override public void render(float x, float y, float z) { GL11.glPushMatrix();//from www . j a v a 2s . c o m GL11.glTranslatef(x, y, z); GL11.glTranslatef(0.2F, 1F, 0F); if (meta == 0) { FMLClientHandler.instance().getClient().renderEngine.bindTexture(CommonProxy.MODEL_BB_GAS); } else if (meta == 1) { FMLClientHandler.instance().getClient().renderEngine.bindTexture(CommonProxy.MODEL_BB_ELECTRIC); } else { FMLClientHandler.instance().getClient().renderEngine.bindTexture(CommonProxy.MODEL_BUNSEN_BURNER); } GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); // Render model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //model.renderStand(0.0625F); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); GL11.glPopMatrix(); }
From source file:chemistry.electrolysm.client.itemRenderers.ItemRendererTripod.java
License:Open Source License
@Override public void render(float x, float y, float z) { GL11.glPushMatrix();//from ww w . j a va 2s.c om GL11.glTranslatef(x, y, z); GL11.glTranslatef(0.2F, 1F, 0F); FMLClientHandler.instance().getClient().renderEngine.bindTexture(CommonProxy.MODEL_BUNSEN_BURNER); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); // Render //model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); model.renderStand(0.0625F); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); GL11.glPopMatrix(); }
From source file:chemistry.electrolysm.client.RenderTileBunsenBurner.java
License:Open Source License
@Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float v4) { renderTripod = ((TileEntityBunsenBurner) tileEntity).hasStand(); renderTestTube = ((TileEntityBunsenBurner) tileEntity).hasTestTube(); //System.out.println("render"); GL11.glPushMatrix();//from www . java2 s . c o m GL11.glEnable(GL11.GL_LIGHTING); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); rotateByMeta(tileEntity.getBlockMetadata()); Block block = tileEntity.getWorldObj().getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); if (block instanceof BlockBBElectric) { bindTexture(CommonProxy.MODEL_BB_ELECTRIC); } else if (block instanceof BlockBBGas) { bindTexture(CommonProxy.MODEL_BB_GAS); } else { bindTexture(CommonProxy.MODEL_BUNSEN_BURNER); } GL11.glScalef(1.0F, -1.0F, -1.0F); model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); if (renderTripod) { model.renderStand(0.0625F); if (renderTestTube) { model.renderTestTube(0.0625F); } } GL11.glDisable(GL11.GL_LIGHTING); GL11.glPopMatrix(); }
From source file:chessMod.client.ChessModDrawBlockHighlightHandler.java
License:LGPL
public static void highlightTile(EntityPlayer player, double x, double y, double z, float partialTicks) { x += 0.5D;//w w w .jav a 2 s . c o m y += 0.5D; z += 0.5D; double iPX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; double iPY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; double iPZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; float xScale = 1.0F; float yScale = 1; float zScale = 1.0F; float xShift = 0.0F; float yShift = 0.01F; float zShift = 0.0F; GL11.glDepthMask(false); GL11.glDisable(GL11.GL_CULL_FACE); for (int i = 4; i < 5; i++) { ForgeDirection forgeDir = ForgeDirection.getOrientation(i); int zCorrection = i == 2 ? -1 : 1; GL11.glPushMatrix(); GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift); GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale); GL11.glRotatef(90, forgeDir.offsetX, forgeDir.offsetY, forgeDir.offsetZ); GL11.glTranslated(0, 0, 0.5f * zCorrection); GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT); drawQuad(-0.5F, -0.5F, 1F, 1F, 0F); GL11.glPopMatrix(); } GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(true); }
From source file:chessMod.client.ChessModDrawBlockHighlightHandler.java
License:LGPL
public static void drawQuad(float x, float y, float width, float height, double zLevel) { GL11.glDisable(GL11.GL_LIGHTING);/*from w w w. j ava2 s .com*/ GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glLineWidth(5.0F); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(0F, 1F, 0F, pulseTransparency); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertex(x + 0F, y + height, zLevel); tessellator.addVertex(x + width, y + height, zLevel); tessellator.addVertex(x + width, y + 0F, zLevel); tessellator.addVertex(x + 0F, y + 0F, zLevel); tessellator.draw(); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LIGHTING); }