public void loadTexture(IResourceManager resourceManager) throws IOException { this.deleteGlTexture(); BufferedImage bufferedimage = null; for (String s : this.layeredTextureNames) { IResource iresource = null; try { if (s != null) { iresource = resourceManager.getResource(new ResourceLocation(s)); BufferedImage bufferedimage1 = TextureUtil.readBufferedImage(iresource.getInputStream()); if (bufferedimage == null) { bufferedimage = new BufferedImage(bufferedimage1.getWidth(), bufferedimage1.getHeight(), 2); } bufferedimage.getGraphics().drawImage(bufferedimage1, 0, 0, (ImageObserver) null); } continue; } catch (IOException ioexception) { LOGGER.error((String) "Couldn\'t load layered image", (Throwable) ioexception); } finally { IOUtils.closeQuietly((Closeable) iresource); } return; } TextureUtil.uploadTextureImage(this.getGlTextureId(), bufferedimage); }
public void deleteTexture(ResourceLocation textureLocation) { ITextureObject itextureobject = this.getTexture(textureLocation); if (itextureobject != null) { TextureUtil.deleteTexture(itextureobject.getGlTextureId()); } }
public void updateAnimation() { ++this.tickCounter; if (this.tickCounter >= this.animationMetadata.getFrameTimeSingle(this.frameCounter)) { int i = this.animationMetadata.getFrameIndex(this.frameCounter); int j = this.animationMetadata.getFrameCount() == 0 ? this.framesTextureData.size() : this.animationMetadata.getFrameCount(); this.frameCounter = (this.frameCounter + 1) % j; this.tickCounter = 0; int k = this.animationMetadata.getFrameIndex(this.frameCounter); if (i != k && k >= 0 && k < this.framesTextureData.size()) { TextureUtil.uploadTextureSub( (int[]) this.framesTextureData.get(k), this.width, this.height, this.originX, this.originY, false, false); } } }
public void updateAnimation() { if (!this.framesTextureData.isEmpty()) { Minecraft minecraft = Minecraft.getMinecraft(); double d0 = 0.0D; if (minecraft.theWorld != null && minecraft.thePlayer != null) { float f = minecraft.theWorld.getCelestialAngle(1.0F); d0 = (double) f; if (!minecraft.theWorld.provider.isSurfaceWorld()) { d0 = Math.random(); } } double d1; for (d1 = d0 - this.field_94239_h; d1 < -0.5D; ++d1) {; } while (d1 >= 0.5D) { --d1; } if (d1 < -1.0D) { d1 = -1.0D; } if (d1 > 1.0D) { d1 = 1.0D; } this.field_94240_i += d1 * 0.1D; this.field_94240_i *= 0.8D; this.field_94239_h += this.field_94240_i; int i; for (i = (int) ((this.field_94239_h + 1.0D) * (double) this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size()) {; } if (i != this.frameCounter) { this.frameCounter = i; TextureUtil.uploadTextureMipmap( (int[][]) this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false); } } }
public void bindTexture(ResourceLocation resource) { ITextureObject itextureobject = (ITextureObject) this.mapTextureObjects.get(resource); if (itextureobject == null) { itextureobject = new SimpleTexture(resource); this.loadTexture(resource, itextureobject); } TextureUtil.bindTexture(itextureobject.getGlTextureId()); }
public void bindTexture(ResourceLocation resource) { Object object = (ITextureObject) this.mapTextureObjects.get(resource); if (object == null) { object = new SimpleTexture(resource); this.loadTexture(resource, (ITextureObject) object); } TextureUtil.bindTexture(((ITextureObject) object).getGlTextureId()); }
public void updateAnimation() { if (!this.framesTextureData.isEmpty()) { Minecraft var1 = Minecraft.getMinecraft(); double var2 = 0.0D; if (var1.world != null && var1.player != null) { float var4 = var1.world.getCelestialAngle(1.0F); var2 = (double) var4; if (!var1.world.provider.isOverworld()) { var2 = Math.random(); } } double var7; for (var7 = var2 - this.field_94239_h; var7 < -0.5D; ++var7) {; } while (var7 >= 0.5D) { --var7; } var7 = M.clamp(var7, -1.0D, 1.0D); this.field_94240_i += var7 * 0.1D; this.field_94240_i *= 0.8D; this.field_94239_h += this.field_94240_i; int var6; for (var6 = (int) ((this.field_94239_h + 1.0D) * (double) this.framesTextureData.size()) % this.framesTextureData.size(); var6 < 0; var6 = (var6 + this.framesTextureData.size()) % this.framesTextureData.size()) {; } if (var6 != this.frameCounter) { this.frameCounter = var6; TextureUtil.uploadTextureMipmap( (int[][]) this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false); } } }
public void modifyTexture(Texture tex, Image pixels, int x, int y) { setTexture(0, tex); TextureUtil.uploadSubTexture(pixels, convertTextureType(tex.getType()), 0, x, y); }
public void updateTexImageData(Image img, Texture.Type type, int unit) { int texId = img.getId(); if (texId == -1) { // create texture glGenTextures(ib1); texId = ib1.get(0); img.setId(texId); objManager.registerObject(img); statistics.onNewTexture(); } // bind texture int target = convertTextureType(type); // if (context.boundTextureUnit != unit) { // glActiveTexture(GL_TEXTURE0 + unit); // context.boundTextureUnit = unit; // } if (context.boundTextures[unit] != img) { glEnable(target); glBindTexture(target, texId); context.boundTextures[unit] = img; statistics.onTextureUse(img, true); } // Check sizes if graphics card doesn't support NPOT if (!GLContext.getCapabilities().GL_ARB_texture_non_power_of_two) { if (img.getWidth() != 0 && img.getHeight() != 0) { if (!FastMath.isPowerOfTwo(img.getWidth()) || !FastMath.isPowerOfTwo(img.getHeight())) { // Resize texture to Power-of-2 size MipMapGenerator.resizeToPowerOf2(img); } } } if (!img.hasMipmaps() && img.isGeneratedMipmapsRequired()) { // No pregenerated mips available, // generate from base level if required // Check if hardware mips are supported if (GLContext.getCapabilities().OpenGL14) { glTexParameteri(target, GL14.GL_GENERATE_MIPMAP, GL_TRUE); } else { MipMapGenerator.generateMipMaps(img); } img.setMipmapsGenerated(true); } else { } if (img.getWidth() > maxTexSize || img.getHeight() > maxTexSize) { throw new RendererException( "Cannot upload texture " + img + ". The maximum supported texture resolution is " + maxTexSize); } /* if (target == GL_TEXTURE_CUBE_MAP) { List<ByteBuffer> data = img.getData(); if (data.size() != 6) { logger.log(Level.WARNING, "Invalid texture: {0}\n" + "Cubemap textures must contain 6 data units.", img); return; } for (int i = 0; i < 6; i++) { TextureUtil.uploadTexture(img, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, i, 0, tdc); } } else if (target == EXTTextureArray.GL_TEXTURE_2D_ARRAY_EXT) { List<ByteBuffer> data = img.getData(); // -1 index specifies prepare data for 2D Array TextureUtil.uploadTexture(img, target, -1, 0, tdc); for (int i = 0; i < data.size(); i++) { // upload each slice of 2D array in turn // this time with the appropriate index TextureUtil.uploadTexture(img, target, i, 0, tdc); } } else {*/ TextureUtil.uploadTexture(img, target, 0, 0); // } img.clearUpdateNeeded(); }
/** Updates the compass based on the given x,z coords and camera direction */ public void updateCompass( World par1World, double par2, double par4, double par6, boolean par8, boolean par9) { if (!this.framesTextureData.isEmpty()) { double d3 = 0.0D; if (par1World != null && !par8) { ChunkCoordinates chunkcoordinates = par1World.getSpawnPoint(); double d4 = (double) chunkcoordinates.posX - par2; double d5 = (double) chunkcoordinates.posZ - par4; par6 %= 360.0D; d3 = -((par6 - 90.0D) * Math.PI / 180.0D - Math.atan2(d5, d4)); if (!par1World.provider.isSurfaceWorld()) { d3 = Math.random() * Math.PI * 2.0D; } } if (par9) { this.currentAngle = d3; } else { double d6; for (d6 = d3 - this.currentAngle; d6 < -Math.PI; d6 += (Math.PI * 2D)) {; } while (d6 >= Math.PI) { d6 -= (Math.PI * 2D); } if (d6 < -1.0D) { d6 = -1.0D; } if (d6 > 1.0D) { d6 = 1.0D; } this.angleDelta += d6 * 0.1D; this.angleDelta *= 0.8D; this.currentAngle += this.angleDelta; } int i; for (i = (int) ((this.currentAngle / (Math.PI * 2D) + 1.0D) * (double) this.framesTextureData.size()) % this.framesTextureData.size(); i < 0; i = (i + this.framesTextureData.size()) % this.framesTextureData.size()) {; } if (i != this.frameCounter) { this.frameCounter = i; TextureUtil.uploadTextureSub( (int[]) this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false); } } }
private void loadCubeResID(Context context, GL10 gl) { cubeResID[0] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[1] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[2] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[3] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[4] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[5] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[6] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[7] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[8] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[9] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[10] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[11] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[12] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[13] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[14] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[15] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[16] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[17] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[18] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[19] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[20] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[21] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[22] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[23] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[24] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[25] = TextureUtil.getTexture(context, gl, R.drawable.icon); cubeResID[26] = TextureUtil.getTexture(context, gl, R.drawable.icon); }