List of usage examples for org.lwjgl.opengl GL11 glBindTexture
public static void glBindTexture(@NativeType("GLenum") int target, @NativeType("GLuint") int texture)
From source file:bomberman.Chat.java
public void displayMessages(GameController gc, int x, int y, int fontSize) { if (is_writing) { changeFontSize(fontSize);//from w w w .j a va2 s. co m font.drawString(x, y, userInput, Color.cyan); } if (!messages.isEmpty()) { changeFontSize(fontSize); //for (Message message : messages){ for (int i = 0; i < messages.size(); i++) { y -= (fontSize - 2); Message message = messages.get(i); font.drawString(x, y, message.text, Color.yellow); // display chat GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); TextureImpl.unbind(); } } }
From source file:br.com.perin.renderEngine.Renderer.java
public void render(TexturedModel model) { RawModel raw = model.getRawModel();/*from ww w. j a va 2 s. c om*/ GL30.glBindVertexArray(raw.getVaoId()); GL20.glEnableVertexAttribArray(0); GL20.glEnableVertexAttribArray(1); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, model.getTexture().getId()); // Essa linha est com problemas. GL11.glDrawElements(GL11.GL_TRIANGLES, raw.getVertexCount(), GL11.GL_UNSIGNED_INT, 0); GL20.glDisableVertexAttribArray(0); GL20.glDisableVertexAttribArray(1); GL30.glBindVertexArray(0); }
From source file:buildcraft.energy.render.TextureOilFlowFX.java
License:Minecraft Mod Public
@Override public void bindImage(RenderEngine renderengine) { GL11.glBindTexture(3553, renderengine.getTexture(DefaultProps.TEXTURE_BLOCKS)); }
From source file:chb.mods.mffs.client.GuiGraphicButton.java
License:Open Source License
/** * Draws this button to the screen./* w ww . j a v a 2s .c o m*/ */ public void drawButton(Minecraft par1Minecraft, int par2, int par3) { if (this.drawButton) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, par1Minecraft.renderEngine.getTexture("/chb/mods/mffs/sprites/items.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); if ((tileEntity instanceof TileEntityConverter) && typ == 1) { switch (((TileEntityConverter) tileEntity).getswitchtyp()) { case 0: this.drawTexturedModalRect(this.xPosition, this.yPosition, 80, 80, this.width, this.height); break; case 1: this.drawTexturedModalRect(this.xPosition, this.yPosition, 64, 80, this.width, this.height); break; } } if (tileEntity instanceof TileEntityProjector) { if (typ == 1) { switch (((TileEntityProjector) tileEntity).getaccesstyp()) { case 0: this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 80, this.width, this.height); break; case 1: this.drawTexturedModalRect(this.xPosition, this.yPosition, 16, 80, this.width, this.height); break; case 2: this.drawTexturedModalRect(this.xPosition, this.yPosition, 48, 80, this.width, this.height); break; case 3: this.drawTexturedModalRect(this.xPosition, this.yPosition, 32, 80, this.width, this.height); break; } } if (typ == 2) { switch (((TileEntityProjector) tileEntity).getswitchtyp()) { case 0: this.drawTexturedModalRect(this.xPosition, this.yPosition, 80, 80, this.width, this.height); break; case 1: this.drawTexturedModalRect(this.xPosition, this.yPosition, 64, 80, this.width, this.height); break; } } } if (tileEntity instanceof TileEntityCapacitor) { if (typ == 1) { switch (((TileEntityCapacitor) tileEntity).getswitchtyp()) { case 0: this.drawTexturedModalRect(this.xPosition, this.yPosition, 80, 80, this.width, this.height); break; case 1: this.drawTexturedModalRect(this.xPosition, this.yPosition, 64, 80, this.width, this.height); break; } } if (typ == 2) { switch (((TileEntityCapacitor) tileEntity).getPowerlinkmode()) { case 0: this.drawTexturedModalRect(this.xPosition, this.yPosition, 96, 80, this.width, this.height); break; case 1: this.drawTexturedModalRect(this.xPosition, this.yPosition, 112, 80, this.width, this.height); break; case 2: this.drawTexturedModalRect(this.xPosition, this.yPosition, 128, 80, this.width, this.height); break; } } } } }
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. * // w ww .j a v a2 s. c o m * @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:cn.lambdalib.util.client.RenderUtils.java
License:MIT License
/** * Restores the stored texture state. stack depth: 1 *//*from ww w . ja v a2 s . com*/ public static void popTextureState() { if (textureState == -1) { System.err.println("RenderUtils:Texture State Underflow"); return; } GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureState); textureState = -1; }
From source file:colonialdisplay.AntDisplayGL.java
private void drawBackground() { TerrainLocation[][] gridlocations = e.getLocations(); for (TerrainLocation[] locations : gridlocations) { for (TerrainLocation location : locations) { String texture = location.getTerrain().getTexture(); Rectangle bounds = location.getScreenLocation(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tmap.getSheetID()); drawTile(bounds, tmap.getSpriteLocation(texture)); //if(location.getScent().FoodIntensity > 0 || location.getScent().ReturnIntensity > 0){ String r = location.getScent().getTexture(); Rectangle scentbounds = location.getScreenLocation(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tmap.getSheetID()); drawTile(scentbounds, tmap.getSpriteLocation(r)); //}/*from w w w. j a v a 2s . c om*/ } } }
From source file:colonialdisplay.AntDisplayGL.java
private void drawForeGround() { GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glEnable(GL11.GL_BLEND);/*from www .jav a 2 s .c o m*/ ArrayList<Ant> ants = e.getTestAnts(); for (Ant ant : ants) { String r = ant.getTexture(); Rectangle bounds = ant.getScreenPosition(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tmap.getSheetID()); drawTile(bounds, tmap.getSpriteLocation(r)); } }
From source file:com.a2client.corex.Render.java
License:Open Source License
static public void ResetBind() { ResManager.Active.clear();/* ww w . jav a 2 s . c o m*/ if (!multi_texture) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); // GL11.glBindTexture(, 0); // cube map } else { for (int i = 0; i < 16; i++) { ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB + i); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); // GL11.glBindTexture(, 0); // cube map } ARBMultitexture.glActiveTextureARB(ARBMultitexture.GL_TEXTURE0_ARB); } ARBShaderObjects.glUseProgramObjectARB(0); ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, 0); ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0); // slick unbind textures // TextureImpl.unbind(); }
From source file:com.adavr.player.globjects.Texture.java
License:Open Source License
public static void bind(Texture t) { GL11.glBindTexture(t.target, t.id); }