List of usage examples for org.lwjgl.opengl GL11 glBlendFunc
public static void glBlendFunc(@NativeType("GLenum") int sfactor, @NativeType("GLenum") int dfactor)
From source file:appeng.client.render.ItemRenderer.java
License:Open Source License
@Override public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) { GL11.glPushMatrix();// www . j a v a2 s .c o m GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); GL11.glEnable(GL11.GL_ALPHA_TEST); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); if (type == ItemRenderType.ENTITY) { GL11.glTranslatef(-0.5f, -0.5f, -0.5f); } if (type == ItemRenderType.INVENTORY) { GL11.glTranslatef(0.0f, -0.1f, 0.0f); } WorldRender.INSTANCE.renderItemBlock(item, type, data); GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:appeng.entity.RenderTinyTNTPrimed.java
License:Open Source License
private void renderPrimedTNT(final EntityTinyTNTPrimed tnt, final double x, final double y, final double z, final float life) { GL11.glPushMatrix();//from ww w . ja v a 2 s. c o m GL11.glTranslatef((float) x, (float) y - 0.25f, (float) z); float f2; if (tnt.fuse - life + 1.0F < 10.0F) { f2 = 1.0F - (tnt.fuse - life + 1.0F) / 10.0F; if (f2 < 0.0F) { f2 = 0.0F; } if (f2 > 1.0F) { f2 = 1.0F; } f2 *= f2; f2 *= f2; final float f3 = 1.0F + f2 * 0.3F; GL11.glScalef(f3, f3, f3); } GL11.glScalef(0.5f, 0.5f, 0.5f); f2 = (1.0F - (tnt.fuse - life + 1.0F) / 100.0F) * 0.8F; this.bindEntityTexture(tnt); this.blockRenderer.renderBlockAsItem(Blocks.tnt, 0, tnt.getBrightness(life)); if (tnt.fuse / 5 % 2 == 0) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, f2); this.blockRenderer.renderBlockAsItem(Blocks.tnt, 0, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_TEXTURE_2D); } GL11.glPopMatrix(); }
From source file:ar.com.quark.backend.lwjgl.opengl.DesktopGLES20.java
License:Apache License
/** * {@inheritDoc} */ @Override public void glBlendFunc(int source, int destination) { GL11.glBlendFunc(source, destination); }
From source file:arekkuusu.grimoireOfAlice.client.render.ItemRenderHolyKeyStone.java
License:Open Source License
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GL11.glPushMatrix();//from w ww . j a v a2 s.c o m GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glRotatef(-5F, 1F, 0F, 0F); TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileEntityHolyKeyStone(), 0.0D, 0.0D, 0.0D, 0.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); }
From source file:arekkuusu.grimoireOfAlice.client.render.ItemRenderHolyStone.java
License:Open Source License
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GL11.glPushMatrix();//from www . ja v a 2 s. co m GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); float s = 1.4F; GL11.glScalef(s, s, s); GL11.glRotatef(-5F, 1F, 0F, 0F); TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileEntityHolyStone(), 0.0D, 0.0D, 0.0D, 0.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); }
From source file:arekkuusu.grimoireOfAlice.client.render.ItemRenderOnbashira.java
License:Open Source License
@Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GL11.glPushMatrix();//from www . j ava 2 s .c om GL11.glTranslatef(0F, -0.7F, -0.5F); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); float s = 0.5F; GL11.glScalef(s, s, s); GL11.glRotatef(0F, 0F, 0F, 0F); TileEntityRendererDispatcher.instance.renderTileEntityAt(new TileEntityOnbashira(), 0.0D, 0.0D, 0.0D, 0.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); }
From source file:betterfonts.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. * * @param str the string being rendered; it can contain color codes * @param x the x coordinate to draw at// ww w.j a v a 2 s .c o m * @param y the y coordinate to draw at * @param color 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(String str, int startX, int startY, int initialColor, 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 */ 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 */ 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 */ 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. */ char c = str.charAt(glyph.stringIndex); if (c >= '0' && c <= '9') { int oldWidth = texture.width; texture = digitGlyphs[fontStyle][c - '0'].texture; 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 */ float x1 = startX + (glyphX) / 2.0F; float x2 = startX + (glyphX + texture.width) / 2.0F; float y1 = startY + (glyph.y) / 2.0F; 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 */ Glyph glyph = entry.glyphs[glyphIndex]; /* The strike/underlines are drawn beyond the glyph's width to include the extra space between glyphs */ 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 */ float x1 = startX + (glyph.x - glyphSpace) / 2.0F; float x2 = startX + (glyph.x + glyph.advance) / 2.0F; float y1 = startY + (UNDERLINE_OFFSET) / 2.0F; 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 */ float x1 = startX + (glyph.x - glyphSpace) / 2.0F; float x2 = startX + (glyph.x + glyph.advance) / 2.0F; float y1 = startY + (STRIKETHROUGH_OFFSET) / 2.0F; 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); } /* Return total horizontal advance (slightly wider than the bounding box, but close enough for centering strings) */ return entry.advance / 2; }
From source file:boilerplate.client.fx.FXRaygun.java
License:Minecraft Mod Public
@Override public void renderParticle(final Tessellator tessellator, final float f, final float f1, final float f2, final float f3, final float f4, final float f5) { tessellator.draw();/*from w w w . j av a 2s. c om*/ GL11.glPushMatrix(); final float var9 = 1.0F; final float slide = this.worldObj.getWorldTime(); final float rot = ((this.worldObj.provider.getWorldTime() % (360 / this.rotationspeed)) * this.rotationspeed) + (this.rotationspeed * f); float size = 0.5F; if (this.pulse) { size = Math.min(this.particleAge / 4.0F, 1.0F); size = this.prevSize + ((size - this.prevSize) * f); } float op = 0.4F; if ((this.pulse) && ((this.particleMaxAge - this.particleAge) <= 4)) { op = 0.4F - ((4 - (this.particleMaxAge - this.particleAge)) * 0.1F); } switch (this.type) { default: // In case I make another type of beam, I can change the beam // texture here break; case 1: // and here... break; case 2: ClientHelper.textureManager().bindTexture(rayTex); } GL11.glTexParameterf(3553, 10242, 10497.0F); GL11.glTexParameterf(3553, 10243, 10497.0F); GL11.glDisable(2884); float var11 = slide + f; if (this.reverse) { var11 *= -1.0F; // why name your variables "var11"? That is so // un-helpful } final float var12 = (-var11 * 0.2F) - MathHelper.floor_float(-var11 * 0.1F); GL11.glEnable(3042); GL11.glBlendFunc(770, 1); GL11.glDepthMask(false); double prex = this.player.prevPosX; double prey = this.player.prevPosY + this.offset; double prez = this.player.prevPosZ; double px = this.player.posX; double py = this.player.posY + this.offset; double pz = this.player.posZ; prex -= MathHelper.cos((this.player.prevRotationYaw / 180.0F) * 3.141593F) * 0.066F; prey -= 0.06D; prez -= MathHelper.sin((this.player.prevRotationYaw / 180.0F) * 3.141593F) * 0.04F; Vec3 vec3d = this.player.getLook(1.0F); prex += vec3d.xCoord * 0.3D; prey += vec3d.yCoord * 0.3D; prez += vec3d.zCoord * 0.3D; px -= MathHelper.cos((this.player.rotationYaw / 180.0F) * 3.141593F) * 0.066F; py -= 0.06D; pz -= MathHelper.sin((this.player.rotationYaw / 180.0F) * 3.141593F) * 0.04F; vec3d = this.player.getLook(1.0F); px += vec3d.xCoord * 0.3D; py += vec3d.yCoord * 0.3D; pz += vec3d.zCoord * 0.3D; final float xx = (float) ((prex + ((px - prex) * f)) - EntityFX.interpPosX); final float yy = (float) ((prey + ((py - prey) * f)) - EntityFX.interpPosY); final float zz = (float) ((prez + ((pz - prez) * f)) - EntityFX.interpPosZ); GL11.glTranslated(xx, yy, zz); final float ry = this.prevYaw + ((this.rotYaw - this.prevYaw) * f); final float rp = this.prevPitch + ((this.rotPitch - this.prevPitch) * f); GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(180.0F + ry, 0.0F, 0.0F, -1.0F); GL11.glRotatef(rp, 1.0F, 0.0F, 0.0F); final double var44 = -0.15D * size; final double var17 = 0.15D * size; final double var44b = -0.15D * size * this.endMod; final double var17b = 0.15D * size * this.endMod; GL11.glRotatef(rot, 0.0F, 1.0F, 0.0F); for (int t = 0; t < 5; t++) { final double var29 = this.length * size * var9; final double var31 = 0.0D; final double var33 = 1.0D; final double var35 = -1.0F + var12 + (t / 3.0F); final double var37 = (this.length * size * var9) + var35; GL11.glRotatef(60.0F, 0.0F, 1.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.setBrightness(200); tessellator.setColorRGBA_F(this.particleRed, this.particleGreen, this.particleBlue, op); tessellator.addVertexWithUV(var44b, var29, 0.0D, var33, var37); tessellator.addVertexWithUV(var44, 0.0D, 0.0D, var33, var35); tessellator.addVertexWithUV(var17, 0.0D, 0.0D, var31, var35); tessellator.addVertexWithUV(var17b, var29, 0.0D, var31, var37); tessellator.draw(); } GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDepthMask(true); GL11.glDisable(3042); GL11.glEnable(2884); GL11.glPopMatrix(); tessellator.startDrawingQuads(); this.prevSize = size; }
From source file:buildcraft.builders.render.RenderArchitect.java
License:Minecraft Mod Public
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { super.renderTileEntityAt(tileentity, x, y, z, f); TileArchitect architect = (TileArchitect) tileentity; GL11.glPushMatrix();//from www .j av a 2 s.co m GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(x, y, z); GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); for (LaserData laser : architect.subLasers) { if (laser != null) { GL11.glPushMatrix(); RenderLaser.doRenderLaserWave(TileEntityRendererDispatcher.instance.field_147553_e, laser, EntityLaser.LASER_TEXTURES[3]); GL11.glPopMatrix(); } } GL11.glPopAttrib(); GL11.glPopMatrix(); }
From source file:buildcraft.builders.render.RenderConstructionMarker.java
License:Minecraft Mod Public
@Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { super.renderTileEntityAt(tileentity, x, y, z, f); TileConstructionMarker marker = (TileConstructionMarker) tileentity; GL11.glPushMatrix();/* w w w . j a v a2 s. c o m*/ GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(x, y, z); GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord); if (marker.laser != null) { GL11.glPushMatrix(); RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, marker.laser, EntityLaser.LASER_TEXTURES[4]); GL11.glPopMatrix(); } if (marker.itemBlueprint != null) { doRenderItem(marker.itemBlueprint, marker.xCoord + 0.5F, marker.yCoord + 0.2F, marker.zCoord + 0.5F); } //GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopAttrib(); GL11.glPopMatrix(); renderItems.render(tileentity, x, y, z); }