public void render(int x, int y, float extra) { setExtraLevel(extra); glPushMatrix(); shader.bind(); glBindVertexArray(vao); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); { glTranslatef(x, y, 0); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texture); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, Texture.Lava); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vio); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0); glActiveTexture(GL_TEXTURE1); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindTexture(GL_TEXTURE_2D, 0); /* * glTranslatef(x, y, 0); glBindTexture(GL_TEXTURE_2D, texture); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vio); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindTexture(GL_TEXTURE_2D, 0); */ } glDisableVertexAttribArray(1); glDisableVertexAttribArray(0); glBindVertexArray(0); shader.release(); glPopMatrix(); }
public Texture(String path) { try { BufferedImage image = ImageIO.read(new FileInputStream(path)); width = image.getWidth(); height = image.getHeight(); pixels = new int[width * height]; image.getRGB(0, 0, width, height, pixels, 0, width); } catch (IOException e) { e.printStackTrace(); } int[] data = new int[width * height]; for (int i = 0; i < data.length; i++) { int a = (pixels[i] & 0xff000000) >> 24; int r = (pixels[i] & 0xff0000) >> 16; int g = (pixels[i] & 0xff00) >> 8; int b = (pixels[i] & 0xff); data[i] = a << 24 | b << 16 | g << 8 | r; } int id = glGenTextures(); glBindTexture(GL_TEXTURE_2D, id); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); IntBuffer buffer = (IntBuffer) BufferUtils.createIntBuffer(data.length).put(data).flip(); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); this.index = id; glBindTexture(GL_TEXTURE_2D, 0); }
public static void floor() { glBindTexture(GL_TEXTURE_2D, Main.tex_floor); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); FloatBuffer color = BufferUtils.createFloatBuffer(4); color.put(1).put(0.8f).put(0.6f).put(1).flip(); glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color); color = BufferUtils.createFloatBuffer(4); color.put(0).put(0).put(0).put(1).flip(); glMaterial(GL_FRONT, GL_SPECULAR, color); glBegin(GL_QUADS); glNormal3f(0, 1, 0); for (int a = ZA_FLOOR_START; a < ZA_FLOOR_END; a += ZA_FLOOR_RES) { for (int b = ZA_FLOOR_START; b < ZA_FLOOR_END; b += ZA_FLOOR_RES) { glTexCoord2f(0, 0); glVertex3f(a, 0, b); glTexCoord2f(0, 1); glVertex3f(a, 0, b + ZA_FLOOR_RES); glTexCoord2f(1, 1); glVertex3f(a + ZA_FLOOR_RES, 0, b + ZA_FLOOR_RES); glTexCoord2f(1, 0); glVertex3f(a + ZA_FLOOR_RES, 0, b); } } glEnd(); glBindTexture(GL_TEXTURE_2D, ResourceLoader.white); color = BufferUtils.createFloatBuffer(4); color.put(1).put(0.8f).put(0.6f).put(1).flip(); glMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color); }
public static void drawRegion(TextureRegion tex, int x, int y, int w, int h) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, tex.id); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_QUADS); { glTexCoord2f(tex.u, tex.v); glVertex2f(x, y); glTexCoord2f(tex.u2, tex.v); glVertex2f(x + w, y); glTexCoord2f(tex.u2, tex.v2); glVertex2f(x + w, y + h); glTexCoord2f(tex.u, tex.v2); glVertex2f(x, y + h); } glEnd(); glBindTexture(GL_TEXTURE_2D, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); }
public static void beginWater() { useProgram(Shaders.ProgramWater); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, mc.renderEngine.getTexture("/terrain_nh.png")); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, mc.renderEngine.getTexture("/terrain_s.png")); glActiveTexture(GL_TEXTURE0); }
public static void beginTerrain() { useProgram(Shaders.ProgramTerrain); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, mc.renderEngine.getTexture("/terrain_nh.png")); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, mc.renderEngine.getTexture("/terrain_s.png")); glActiveTexture(GL_TEXTURE0); FloatBuffer projection = BufferUtils.createFloatBuffer(16); }
// Load an image from file. private int load(String path) { int[] pixels = null; try { BufferedImage image = ImageIO.read(new FileInputStream(path)); width = image.getWidth(); height = image.getHeight(); pixels = new int[width * height]; image.getRGB(0, 0, width, width, pixels, 0, width); } catch (IOException e) { e.printStackTrace(); } // Rearrange the data from ARGB to RGBA. int[] data = new int[width * height]; for (int i = 0; i < width * height; i++) { // Separate the colour channels. int a = (pixels[i] & 0xff000000) >> 24; int r = (pixels[i] & 0x00ff0000) >> 16; int g = (pixels[i] & 0x0000ff00) >> 8; int b = (pixels[i] & 0x000000ff); // Convert from ARGB to ABGR. data[i] = a << 24 | b << 16 | g << 8 | r; } // int result = glGenTextures(); // "Select" the texture to allow changes. glBindTexture(GL_TEXTURE_2D, result); // Use nearest-neighbour instead of blending when we upscale. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Enable transparency. glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, BufferUtils.createIntBuffer(data)); // Deselect everything. glBindTexture(GL_TEXTURE_2D, 0); return result; }
public void func_78447_b(float p_78447_1_) { GL11.glDisable(3008); int var2; if (this.field_78455_a.field_71439_g.func_70027_ad()) { var2 = this.field_78455_a.field_71446_o.func_78341_b("/terrain.png"); GL11.glBindTexture(3553, var2); this.func_78442_d(p_78447_1_); } if (this.field_78455_a.field_71439_g.func_70094_T()) { var2 = MathHelper.func_76128_c(this.field_78455_a.field_71439_g.field_70165_t); int var3 = MathHelper.func_76128_c(this.field_78455_a.field_71439_g.field_70163_u); int var4 = MathHelper.func_76128_c(this.field_78455_a.field_71439_g.field_70161_v); int var5 = this.field_78455_a.field_71446_o.func_78341_b("/terrain.png"); GL11.glBindTexture(3553, var5); int var6 = this.field_78455_a.field_71441_e.func_72798_a(var2, var3, var4); if (this.field_78455_a.field_71441_e.func_72809_s(var2, var3, var4)) { this.func_78446_a(p_78447_1_, Block.field_71973_m[var6].func_71851_a(2)); } else { for (int var7 = 0; var7 < 8; ++var7) { float var8 = ((float) ((var7 >> 0) % 2) - 0.5F) * this.field_78455_a.field_71439_g.field_70130_N * 0.9F; float var9 = ((float) ((var7 >> 1) % 2) - 0.5F) * this.field_78455_a.field_71439_g.field_70131_O * 0.2F; float var10 = ((float) ((var7 >> 2) % 2) - 0.5F) * this.field_78455_a.field_71439_g.field_70130_N * 0.9F; int var11 = MathHelper.func_76141_d((float) var2 + var8); int var12 = MathHelper.func_76141_d((float) var3 + var9); int var13 = MathHelper.func_76141_d((float) var4 + var10); if (this.field_78455_a.field_71441_e.func_72809_s(var11, var12, var13)) { var6 = this.field_78455_a.field_71441_e.func_72798_a(var11, var12, var13); } } } if (Block.field_71973_m[var6] != null) { this.func_78446_a(p_78447_1_, Block.field_71973_m[var6].func_71851_a(2)); } } if (this.field_78455_a.field_71439_g.func_70055_a(Material.field_76244_g)) { var2 = this.field_78455_a.field_71446_o.func_78341_b("/misc/water.png"); GL11.glBindTexture(3553, var2); this.func_78448_c(p_78447_1_); } GL11.glEnable(3008); }
public static void renderScene() { for (int ID : renderables.keySet()) { List<Renderable> batch = renderables.get(ID); GL11.glBindTexture(GL11.GL_TEXTURE_2D, ID); for (Renderable renderable : batch) { renderable.masterRender(); } GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); } renderables.clear(); }
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { GL11.glDisable(GL11.GL_LIGHTING); GL11.glColor3f(1f, 1f, 1f); // if (!YC_Options.EnableOptifineCompability) // GL11.glTranslatef(0, 0, 1f); GL11.glBindTexture(GL11.GL_TEXTURE_2D, YC_Constants.RemainsTextureID); YC_Mod.m_Ore.Draw(0, 0, 1); GL11.glColor3f(1f, 1f, 1f); GL11.glBindTexture( GL11.GL_TEXTURE_2D, Minecraft.getMinecraft().renderEngine.getTexture("/terrain.png")); GL11.glEnable(GL11.GL_LIGHTING); }
private void bindTextures(Terrain terrain) { TerrainTexturePack pack = terrain.getTexturePack(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getBackgroundTexture().getTextureID()); GL13.glActiveTexture(GL13.GL_TEXTURE1); GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getRedTexture().getTextureID()); GL13.glActiveTexture(GL13.GL_TEXTURE2); GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getGreenTexture().getTextureID()); GL13.glActiveTexture(GL13.GL_TEXTURE3); GL11.glBindTexture(GL11.GL_TEXTURE_2D, pack.getBlueTexture().getTextureID()); GL13.glActiveTexture(GL13.GL_TEXTURE4); GL11.glBindTexture(GL11.GL_TEXTURE_2D, terrain.getBlendMap().getTextureID()); }
public boolean renderWorldBlock( IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { GL11.glPushAttrib(GL11.GL_TEXTURE_BIT); Tessellator t = Tessellator.instance; t.draw(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, YC_Constants.TreeCrystalTextureID); GL11.glPushMatrix(); double t1 = 0, t2 = 0, t3 = 0; if (!YC_Options.EnableOptifineCompability) { ResetTranslation(x, y, z); GL11.glTranslatef(x, y, z); t1 = Tessellator.instance.xOffset; t2 = Tessellator.instance.yOffset; t3 = Tessellator.instance.zOffset; Tessellator.instance.setTranslation(0, 0, 0); } else { GL11.glTranslated( x + Tessellator.instance.xOffset, y + Tessellator.instance.yOffset, z + Tessellator.instance.zOffset); } GL11.glColor4f(1f, 1f, 1f, 1f); // { int md = world.getBlockMetadata(x, y, z); GL11.glTranslatef(0.5f, 0.5f, 0.5f); GL11.glRotatef(GetRotationXFromMD(md), 1, 0, 0); GL11.glRotatef(GetRotationZFromMD(md), 0, 0, 1); GL11.glTranslatef(-0.5f, -0.5f, +0.5f); YC_Mod.m_TreeCrystal.DrawWOTranslation(); if (YC_Options.RenderContourSecondPass) { GL11.glBindTexture( GL11.GL_TEXTURE_2D, Minecraft.getMinecraft().renderEngine.getTexture("/YC/blank.png")); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_LINE); GL11.glColor3f(0f, 0f, 0f); YC_Mod.m_TreeCrystal.DrawWOTranslation(); GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL); } // } if (!YC_Options.EnableOptifineCompability) { Tessellator.instance.setTranslation(t1, t2, t3); } GL11.glPopMatrix(); GL11.glColor4f(1f, 1f, 1f, 1f); GL11.glPopAttrib(); t.startDrawingQuads(); return true; }
/** Renders all the overlays that are in first person mode. Args: partialTickTime */ public void renderOverlays(float par1) { GL11.glDisable(GL11.GL_ALPHA_TEST); int var2; if (this.mc.thePlayer.isBurning()) { var2 = this.mc.renderEngine.getTexture("/terrain.png"); GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2); this.renderFireInFirstPerson(par1); } if (this.mc.thePlayer.isEntityInsideOpaqueBlock()) { var2 = MathHelper.floor_double(this.mc.thePlayer.posX); int var3 = MathHelper.floor_double(this.mc.thePlayer.posY); int var4 = MathHelper.floor_double(this.mc.thePlayer.posZ); int var5 = this.mc.renderEngine.getTexture("/terrain.png"); GL11.glBindTexture(GL11.GL_TEXTURE_2D, var5); int var6 = this.mc.theWorld.getBlockId(var2, var3, var4); if (this.mc.theWorld.isBlockNormalCube(var2, var3, var4)) { this.renderInsideOfBlock(par1, Block.blocksList[var6].getBlockTextureFromSide(2)); } else { for (int var7 = 0; var7 < 8; ++var7) { float var8 = ((float) ((var7 >> 0) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F; float var9 = ((float) ((var7 >> 1) % 2) - 0.5F) * this.mc.thePlayer.height * 0.2F; float var10 = ((float) ((var7 >> 2) % 2) - 0.5F) * this.mc.thePlayer.width * 0.9F; int var11 = MathHelper.floor_float((float) var2 + var8); int var12 = MathHelper.floor_float((float) var3 + var9); int var13 = MathHelper.floor_float((float) var4 + var10); if (this.mc.theWorld.isBlockNormalCube(var11, var12, var13)) { var6 = this.mc.theWorld.getBlockId(var11, var12, var13); } } } if (Block.blocksList[var6] != null) { this.renderInsideOfBlock(par1, Block.blocksList[var6].getBlockTextureFromSide(2)); } } if (this.mc.thePlayer.isInsideOfMaterial(Material.water)) { var2 = this.mc.renderEngine.getTexture("/misc/water.png"); GL11.glBindTexture(GL11.GL_TEXTURE_2D, var2); this.renderWarpedTextureOverlay(par1); } GL11.glEnable(GL11.GL_ALPHA_TEST); }
public void func_579_b(int p_579_1_) { GL11.glDisable(2896); GL11.glDisable(2912); Tessellator var2 = Tessellator.field_1512_a; GL11.glBindTexture(3553, this.field_945_b.field_6315_n.func_1070_a("/gui/background.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); float var3 = 32.0F; var2.func_977_b(); var2.func_990_b(4210752); var2.func_983_a( 0.0D, (double) this.field_950_d, 0.0D, 0.0D, (double) ((float) this.field_950_d / var3 + (float) p_579_1_)); var2.func_983_a( (double) this.field_951_c, (double) this.field_950_d, 0.0D, (double) ((float) this.field_951_c / var3), (double) ((float) this.field_950_d / var3 + (float) p_579_1_)); var2.func_983_a( (double) this.field_951_c, 0.0D, 0.0D, (double) ((float) this.field_951_c / var3), (double) p_579_1_); var2.func_983_a(0.0D, 0.0D, 0.0D, 0.0D, (double) p_579_1_); var2.func_982_a(); }
private void renderPortalOverlay(float var1, int var2, int var3) { if (var1 < 1.0F) { var1 *= var1; var1 *= var1; var1 = var1 * 0.8F + 0.2F; } GL11.glDisable(3008 /*GL_ALPHA_TEST*/); GL11.glDisable(2929 /*GL_DEPTH_TEST*/); GL11.glDepthMask(false); GL11.glBlendFunc(770, 771); GL11.glColor4f(1.0F, 1.0F, 1.0F, var1); GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, this.mc.renderEngine.getTexture("/terrain.png")); float var4 = (float) (Block.portal.blockIndexInTexture % 16) / 16.0F; float var5 = (float) (Block.portal.blockIndexInTexture / 16) / 16.0F; float var6 = (float) (Block.portal.blockIndexInTexture % 16 + 1) / 16.0F; float var7 = (float) (Block.portal.blockIndexInTexture / 16 + 1) / 16.0F; Tessellator var8 = Tessellator.instance; var8.startDrawingQuads(); var8.addVertexWithUV(0.0D, (double) var3, -90.0D, (double) var4, (double) var7); var8.addVertexWithUV((double) var2, (double) var3, -90.0D, (double) var6, (double) var7); var8.addVertexWithUV((double) var2, 0.0D, -90.0D, (double) var6, (double) var5); var8.addVertexWithUV(0.0D, 0.0D, -90.0D, (double) var4, (double) var5); var8.draw(); GL11.glDepthMask(true); GL11.glEnable(2929 /*GL_DEPTH_TEST*/); GL11.glEnable(3008 /*GL_ALPHA_TEST*/); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }
/** Rotate and blurs the skybox view in the main menu */ private void rotateAndBlurSkybox(float par1) { GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.viewportTexture); this.mc.renderEngine.func_98185_a(); GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColorMask(true, true, true, false); Tessellator var2 = Tessellator.instance; var2.startDrawingQuads(); byte var3 = 3; for (int var4 = 0; var4 < var3; ++var4) { var2.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (float) (var4 + 1)); int var5 = this.width; int var6 = this.height; float var7 = (float) (var4 - var3 / 2) / 256.0F; var2.addVertexWithUV( (double) var5, (double) var6, (double) this.zLevel, (double) (0.0F + var7), 0.0D); var2.addVertexWithUV((double) var5, 0.0D, (double) this.zLevel, (double) (1.0F + var7), 0.0D); var2.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, (double) (1.0F + var7), 1.0D); var2.addVertexWithUV(0.0D, (double) var6, (double) this.zLevel, (double) (0.0F + var7), 1.0D); } var2.draw(); GL11.glColorMask(true, true, true, true); this.mc.renderEngine.func_98185_a(); }
/** Updates the small achievement tooltip window, showing a queued achievement if is needed. */ public void updateAchievementWindow() { if (this.theAchievement != null && this.achievementTime != 0L) { double var1 = (double) (System.currentTimeMillis() - this.achievementTime) / 3000.0D; if (!this.haveAchiement && (var1 < 0.0D || var1 > 1.0D)) { this.achievementTime = 0L; } else { this.updateAchievementWindowScale(); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); double var3 = var1 * 2.0D; if (var3 > 1.0D) { var3 = 2.0D - var3; } var3 *= 4.0D; var3 = 1.0D - var3; if (var3 < 0.0D) { var3 = 0.0D; } var3 *= var3; var3 *= var3; int var5 = this.achievementWindowWidth - 160; int var6 = 0 - (int) (var3 * 36.0D); int var7 = this.theGame.renderEngine.getTexture("/achievement/bg.png"); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, var7); GL11.glDisable(GL11.GL_LIGHTING); this.drawTexturedModalRect(var5, var6, 96, 202, 160, 32); if (this.haveAchiement) { this.theGame.fontRenderer.drawSplitString( this.achievementStatName, var5 + 30, var6 + 7, 120, -1); } else { this.theGame.fontRenderer.drawString( this.achievementGetLocalText, var5 + 30, var6 + 7, -256); this.theGame.fontRenderer.drawString(this.achievementStatName, var5 + 30, var6 + 18, -1); } RenderHelper.enableGUIStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_LIGHTING); this.itemRender.renderItemIntoGUI( this.theGame.fontRenderer, this.theGame.renderEngine, this.theAchievement.theItemStack, var5 + 8, var6 + 8); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDepthMask(true); GL11.glEnable(GL11.GL_DEPTH_TEST); } } }
/** Overlays the background to hide scrolled items */ private void overlayBackground(int par1, int par2, int par3, int par4) { // Spout Start GL11.glPushMatrix(); // Spout End Tessellator var5 = Tessellator.instance; GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/background.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); // Spout Start GL11.glTranslatef(0, 0, -0.1f); // Spout End float var6 = 32.0F; var5.startDrawingQuads(); var5.setColorRGBA_I(4210752, par4); var5.addVertexWithUV(0.0D, (double) par2, 0.0D, 0.0D, (double) ((float) par2 / var6)); var5.addVertexWithUV( (double) this.width, (double) par2, 0.0D, (double) ((float) this.width / var6), (double) ((float) par2 / var6)); var5.setColorRGBA_I(4210752, par3); var5.addVertexWithUV( (double) this.width, (double) par1, 0.0D, (double) ((float) this.width / var6), (double) ((float) par1 / var6)); var5.addVertexWithUV(0.0D, (double) par1, 0.0D, 0.0D, (double) ((float) par1 / var6)); var5.draw(); // Spout Start GL11.glPopMatrix(); // Spout End }
private void writeToTexture(RectanglePacker.Rectangle r, ByteBuffer data) { assert r.width * r.height * format.bytes == data.capacity() : r + " * " + format.bytes + " != " + data.capacity(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, id); GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, format.bytes); GL11.glTexSubImage2D( GL11.GL_TEXTURE_2D, 0, r.x, r.y, r.width, r.height, format.glFormat, GL11.GL_UNSIGNED_BYTE, data); GLUtil.checkGLError(); if (mipmap) { mipmapDirty = true; } }
public int loadCubeMap(String[] textures) { int textureID = GL11.glGenTextures(); GL13.glActiveTexture(GL13.GL_TEXTURE0); GL11.glBindTexture(GL13.GL_TEXTURE_CUBE_MAP, textureID); for (int i = 0; i < textures.length; i++) { TextureData data = decodeTextureFile("res/Textures/" + textures[i] + ".png"); GL11.glTexImage2D( GL13.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, data.getBuffer()); } GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL13.GL_TEXTURE_CUBE_MAP, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); this.textures.add(textureID); return textureID; }
/** Draws this button to the screen. */ public void drawButton(Minecraft par1Minecraft, int par2, int par3) { if (this.drawButton) { FontRenderer var4 = par1Minecraft.fontRenderer; GL11.glBindTexture( GL11.GL_TEXTURE_2D, par1Minecraft.renderEngine.getTexture("/pixelmon/gui/rename.png")); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.field_82253_i = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; int var5 = this.getHoverState(this.field_82253_i); if (getHoverState(field_82253_i) == 2) { this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 115, 49, this.height); } this.mouseDragged(par1Minecraft, par2, par3); int var6 = 0xffffff; if (!this.enabled) { var6 = -6250336; } else if (this.field_82253_i) { var6 = 16777120; } this.drawCenteredString( var4, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, var6); } }
private void renderVignette(float f, int i, int j) { f = 1.0F - f; if (f < 0.0F) { f = 0.0F; } if (f > 1.0F) { f = 1.0F; } prevVignetteBrightness += (double) (f - prevVignetteBrightness) * 0.01D; GL11.glDisable(2929 /*GL_DEPTH_TEST*/); GL11.glDepthMask(false); GL11.glBlendFunc(0, 769); GL11.glColor4f(prevVignetteBrightness, prevVignetteBrightness, prevVignetteBrightness, 1.0F); GL11.glBindTexture( 3553 /*GL_TEXTURE_2D*/, mc.renderEngine.getTexture("%blur%/misc/vignette.png")); Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(0.0D, j, -90D, 0.0D, 1.0D); tessellator.addVertexWithUV(i, j, -90D, 1.0D, 1.0D); tessellator.addVertexWithUV(i, 0.0D, -90D, 1.0D, 0.0D); tessellator.addVertexWithUV(0.0D, 0.0D, -90D, 0.0D, 0.0D); tessellator.draw(); GL11.glDepthMask(true); GL11.glEnable(2929 /*GL_DEPTH_TEST*/); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glBlendFunc(770, 771); }
/** Renders dragon's (boss) health on the HUD */ private void renderBossHealth() { if (RenderDragon.entityDragon != null) { EntityDragon var1 = RenderDragon.entityDragon; RenderDragon.entityDragon = null; FontRenderer var2 = this.mc.fontRenderer; ScaledResolution var3 = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); int var4 = var3.getScaledWidth(); short var5 = 182; int var6 = var4 / 2 - var5 / 2; int var7 = (int) ((float) var1.getDragonHealth() / (float) var1.getMaxHealth() * (float) (var5 + 1)); byte var8 = 12; this.drawTexturedModalRect(var6, var8, 0, 74, var5, 5); this.drawTexturedModalRect(var6, var8, 0, 74, var5, 5); if (var7 > 0) { this.drawTexturedModalRect(var6, var8, 0, 79, var7, 5); } String var9 = "Boss health"; var2.drawStringWithShadow( var9, var4 / 2 - var2.getStringWidth(var9) / 2, var8 - 10, 16711935); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/icons.png")); } }
public void render() { text = "" + StaticManager.getScore(); if (hasFocusEffect() && hasFocus()) { getFocusColor().bind(); } else { getNormalColor().bind(); } int xoff = 0; System.out.println("SCORE:" + text + "/" + StaticManager.getScore()); for (int i = 0; i < text.length(); i++) { String subs = text.substring(i, i + 1); GL11.glBindTexture(GL11.GL_TEXTURE_2D, font[getIndex(subs)].getTextureID()); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2i(getX() + xoff, getY()); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2i(getX() + xoff + font[getIndex(subs)].getImageWidth(), getY()); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2i( getX() + xoff + font[getIndex(subs)].getImageWidth(), getY() + font[getIndex(subs)].getImageHeight()); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2i(getX() + xoff, getY() + font[getIndex(subs)].getImageHeight()); GL11.glEnd(); xoff += font[getIndex(subs)].getImageWidth(); } }
@Override public void render() { GL11.glPushMatrix(); GL11.glColor4f(1, 1, 1, 1); // transparent color for overlay GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.img.getID()); GL11.glScalef(this.scale.x, this.scale.y, 1f); GL11.glTranslatef(this.offset.x, this.offset.y, 0f); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(clipping[0], clipping[1]); GL11.glVertex2f(0, 0); GL11.glTexCoord2f(clipping[2], clipping[1]); GL11.glVertex2f(1, 0); GL11.glTexCoord2f(clipping[2], clipping[3]); GL11.glVertex2f(1, 1); GL11.glTexCoord2f(clipping[0], clipping[3]); GL11.glVertex2f(0, 1); GL11.glEnd(); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glPopMatrix(); }
private void renderBossHealth() { if (RenderDragon.field_41038_a == null) { return; } EntityDragon entitydragon = RenderDragon.field_41038_a; RenderDragon.field_41038_a = null; FontRenderer fontrenderer = mc.fontRenderer; ScaledResolution scaledresolution = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight); int i = scaledresolution.getScaledWidth(); char c = '\266'; int j = i / 2 - c / 2; int k = (int) (((float) entitydragon.func_41010_ax() / (float) entitydragon.getMaxHealth()) * (float) (c + 1)); byte byte0 = 12; drawTexturedModalRect(j, byte0, 0, 74, c, 5); drawTexturedModalRect(j, byte0, 0, 74, c, 5); if (k > 0) { drawTexturedModalRect(j, byte0, 0, 79, k, 5); } String s = "Boss health"; fontrenderer.drawStringWithShadow( s, i / 2 - fontrenderer.getStringWidth(s) / 2, byte0 - 10, 0xff00ff); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, mc.renderEngine.getTexture("/gui/icons.png")); }
/** Regenerates any dirty mimaps. */ public void regenerateMipmaps() { if (mipmapDirty) { ByteBuffer data1 = BufferUtils.createByteBuffer(size.getWidth() * size.getHeight() * format.bytes); ByteBuffer data = data1; GL11.glBindTexture(GL11.GL_TEXTURE_2D, id); // read the texture out GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, format.glFormat, GL11.GL_UNSIGNED_BYTE, data); data.rewind(); // regenerate the mipmaps GLU.gluBuild2DMipmaps( GL11.GL_TEXTURE_2D, format.glInternalFormat, size.getWidth(), size.getHeight(), format.glFormat, GL11.GL_UNSIGNED_BYTE, data); mipmapDirty = false; } }
private int loadTexture() { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); ImageIO.write(asBufferedImage, "png", os); int textureID = GL11.glGenTextures(); // Generate texture ID GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); // Bind texture ID // Setup texture scaling filtering GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); // Send texel data to OpenGL GL11.glTexImage2D( GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, asBufferedImage.getWidth(), asBufferedImage.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, asByteBuffer); // Return the texture ID so we can bind it later again return textureID; } catch (IOException e) { e.printStackTrace(); } return 0; }
public static void drawModel(Model m) { glFrontFace(GL_CCW); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); for (Polygon p : m.mesh) { glBindTexture(GL_TEXTURE_2D, p.tex.id); glBegin(GL_TRIANGLES); { for (Vertex v : p.vertices) { glTexCoord2f(v.uv.x, v.uv.y); glNormal3f(v.norm.x, v.norm.y, v.norm.z); glVertex3f(v.pos.x, v.pos.y, v.pos.z); } } glEnd(); } glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); }
private void renderPortalOverlay(float f, int i, int j) { if (f < 1.0F) { f *= f; f *= f; f = f * 0.8F + 0.2F; } GL11.glDisable(3008 /*GL_ALPHA_TEST*/); GL11.glDisable(2929 /*GL_DEPTH_TEST*/); GL11.glDepthMask(false); GL11.glBlendFunc(770, 771); GL11.glColor4f(1.0F, 1.0F, 1.0F, f); GL11.glBindTexture(3553 /*GL_TEXTURE_2D*/, mc.renderEngine.getTexture("/terrain.png")); float f1 = (float) (Block.portal.blockIndexInTexture % 16) / 16F; float f2 = (float) (Block.portal.blockIndexInTexture / 16) / 16F; float f3 = (float) (Block.portal.blockIndexInTexture % 16 + 1) / 16F; float f4 = (float) (Block.portal.blockIndexInTexture / 16 + 1) / 16F; Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(0.0D, j, -90D, f1, f4); tessellator.addVertexWithUV(i, j, -90D, f3, f4); tessellator.addVertexWithUV(i, 0.0D, -90D, f3, f2); tessellator.addVertexWithUV(0.0D, 0.0D, -90D, f1, f2); tessellator.draw(); GL11.glDepthMask(true); GL11.glEnable(2929 /*GL_DEPTH_TEST*/); GL11.glEnable(3008 /*GL_ALPHA_TEST*/); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); }