private void renderQuads(BufferBuilder renderer, List<BakedQuad> quads, int color, ItemStack stack) { boolean flag = color == -1 && !stack.isEmpty(); int i = 0; for (int j = quads.size(); i < j; ++i) { BakedQuad bakedquad = quads.get(i); int k = color; if (flag && bakedquad.hasTintIndex()) { k = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, bakedquad.getTintIndex()); if (EntityRenderer.anaglyphEnable) { k = TextureUtil.anaglyphColor(k); } k = k | -16777216; } net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(renderer, bakedquad, k); } }
TextureUtil.uploadTextureMipmap(this.framesTextureData.get(this.frameCounter), this.width, this.height, this.originX, this.originY, false, false);
/** * Getter for the ID of the texture on the GPU we're using, creates one if necessary. * * @return the texture ID we're currently using. */ private int getGlTextureId() { if (glTextureId == 0) { glTextureId = GlStateManager.generateTexture(); TextureUtil.allocateTexture(glTextureId, RESOLUTION, RESOLUTION); TextureUtil.uploadTexture(glTextureId, image, RESOLUTION, RESOLUTION); } return glTextureId; }
TextureUtil.allocateTextureImpl(getGlTextureId(), mipmapLevels, newWidth, newHeight); TextureUtil.uploadTextureMipmap(loadedSprite.getFrameTextureData(0), loadedSprite.getIconWidth(), loadedSprite.getIconHeight(), loadedSprite.getOriginX(), loadedSprite.getOriginY(), false, false); for (TextureAtlasSprite sprite : spritesNeedingUpload) { spritesNeedingUpload.remove(sprite); TextureUtil.uploadTextureMipmap(sprite.getFrameTextureData(0), sprite.getIconWidth(), sprite.getIconHeight(), sprite.getOriginX(), sprite.getOriginY(), false, false);
int textureId = TextureUtil.glGenTextures(); TextureUtil.allocateTexture(textureId, resolution, resolution); TextureUtil.uploadTexture(textureId, flippedPixels, resolution, resolution);
static Optional<Color> getAverageColor(@Nonnull ResourceLocation resourceLocation) { try { IResource resource = Minecraft.getMinecraft().getResourceManager() .getResource(resourceLocation); Image image = TextureUtil.readBufferedImage(resource.getInputStream()); image = image.getScaledInstance(1, 1, Image.SCALE_DEFAULT); BufferedImage image1 = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics2D = image1.createGraphics(); graphics2D.drawImage(image, 0, 0, null); graphics2D.dispose(); FoodCraftReloaded.getLogger().info("Got " + resourceLocation + " " + new Color(image1.getRGB(0, 0))); return Optional.of(new Color(image1.getRGB(0, 0))); } catch (IOException e) { FoodCraftReloaded.getLogger().info("Cannot read image " + resourceLocation, e); return Optional.empty(); } } }
public void init() { deleteGlTexture(); int maximumTextureSize = Minecraft.getGLMaximumTextureSize(); stitcher = new DynamicStitcher(maximumTextureSize, maximumTextureSize, 0, mipmapLevels); listAnimatedSprites.clear(); initMissingImage(); missingImage.generateMipmaps(mipmapLevels); spritesNeedingUpload.add(missingImage); stitcher.addSprite(missingImage); TextureUtil.allocateTextureImpl(getGlTextureId(), mipmapLevels, stitcher.getImageWidth(), stitcher.getImageHeight()); LOGGER.info("Created {}x{} '{}' atlas", stitcher.getImageWidth(), stitcher.getImageHeight(), basePath); EventUtil.postEventAllowingErrors(new TextureStitchEvent.Pre(this)); ModelLoader.White.INSTANCE.register(this); mapRegisteredSprites.put("builtin/white", ModelLoader.White.INSTANCE); // TODO: why is this necessary ModelDynBucket.LoaderDynBucket.INSTANCE.register(this); EventUtil.postEventAllowingErrors(new TextureStitchEvent.Post(this)); }
public void update() { Preconditions.checkNotNull(dynamicTextureData, "Texture not allocated"); TextureUtil.uploadTexture(getGlTextureId(), dynamicTextureData, width, height); }
public void resize(int width, int height) { if (width != this.width || height != this.height) { this.width = width; this.height = height; TextureUtil.allocateTexture(getGlTextureId(), width, height); } }
/** * Deletes our texture from the GPU, if we have one. */ private void deleteTexture() { if (glTextureId != 0) { TextureUtil.deleteTexture(glTextureId); glTextureId = 0; } }
texture = TextureUtil.glGenTextures();
TextureUtil.allocateTextureImpl(this.getGlTextureId(), 0, stitcher.getCurrentWidth(), stitcher.getCurrentHeight()); Map<String, TextureAtlasSprite> map = Maps.newHashMap(this.mapRegisteredSprites); TextureUtil.uploadTextureMipmap(textureatlassprite1.getFrameTextureData(0), textureatlassprite1.getIconWidth(), textureatlassprite1.getIconHeight(), textureatlassprite1.getOriginX(), textureatlassprite1.getOriginY(), false, false); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Stitching texture atlas");
final BufferedImage bi = TextureUtil.readBufferedImage( iresource.getInputStream() );
@Override public void onData(final ByteBuf data) { if (data.readBoolean()) { Arrays.fill(image, 0); } else { data.readBytes(drawCall); applyDrawCall(drawCall); } TextureUtil.uploadTexture(getGlTextureId(), image, RESOLUTION, RESOLUTION); }
public void dispose() { if (buffer == -1) return; OpenGlHelper.glDeleteRenderbuffers(depth); TextureUtil.deleteTexture(texture); OpenGlHelper.glDeleteFramebuffers(buffer); buffer = -1; }
private void renderQuads(BufferBuilder renderer, List<BakedQuad> quads, int color, ItemStack stack) { boolean flag = color == -1 && !stack.isEmpty(); int i = 0; for (int j = quads.size(); i < j; ++i) { BakedQuad bakedquad = quads.get(i); int k = color; if (flag && bakedquad.hasTintIndex()) { k = itemColors.colorMultiplier(stack, bakedquad.getTintIndex()); if (EntityRenderer.anaglyphEnable) { k = TextureUtil.anaglyphColor(k); } k = k | -16777216; } net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(renderer, bakedquad, k); } }
TextureUtil.allocateTextureImpl(this.getGlTextureId(), 0, stitcher.getCurrentWidth(), stitcher.getCurrentHeight()); Map<String, TextureAtlasSprite> map = Maps.newHashMap(this.mapRegisteredSprites); TextureUtil.uploadTextureMipmap(textureatlassprite1.getFrameTextureData(0), textureatlassprite1.getIconWidth(), textureatlassprite1.getIconHeight(), textureatlassprite1.getOriginX(), textureatlassprite1.getOriginY(), false, false); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Stitching texture atlas");
BufferedImage icon = TextureUtil.readBufferedImage(ClientProxy.class.getResourceAsStream("/assets/" + Reference.MOD_ID + "/textures/app/icon/missing.png")); g.drawImage(icon, 0, 0, ICON_SIZE, ICON_SIZE, null); if(input != null) BufferedImage icon = TextureUtil.readBufferedImage(input); if(icon.getWidth() != ICON_SIZE || icon.getHeight() != ICON_SIZE)
public TextureImageRenderer(final ResourceLocation location) { this.location = location; final TextureManager manager = Minecraft.getMinecraft().getTextureManager(); final ITextureObject image = manager.getTexture(location); if (image instanceof ImageTexture) { this.texture = (ImageTexture) image; } else { if (image != null && image.getGlTextureId() != -1) { TextureUtil.deleteTexture(image.getGlTextureId()); } this.texture = new ImageTexture(location); manager.loadTexture(location, texture); } }
private static int getColorMultiplier(ItemStack stack, int tintIndex) { if (tintIndex == -1 || stack.isEmpty()) return 0xFFFFFFFF; int colorMultiplier = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, tintIndex); if (EntityRenderer.anaglyphEnable) { colorMultiplier = TextureUtil.anaglyphColor(colorMultiplier); } // FUCK YOU // // Always full opacity // colorMultiplier |= 0xff << 24; // -16777216 return colorMultiplier; }