Splash 纹理管理

基本信息

属性 值
类 alexiil.mods.load.SplashTextureManager
父类 net.minecraft.client.renderer.texture.TextureManager
实例字段 List<ResourceTexture> ownedTextures

行为

背景纹理绑定

  • bindBackgroundTexture(ResourceLocation):跳过 ownedTextures 追踪,避免主线程与渲染线程同时绑定导致 ownedTextures 状态污染。
  • bindTexture(ResourceLocation):对 owned 列表里的 ResourceTexture 打 usedThisFrame=true,便于 endFrame 释放一帧内未引用的纹理。

帧生命周期

  • beginFrame():把所有 ownedTextures 的 usedThisFrame=false。
  • endFrame():遍历 owned 列表,回收 usedThisFrame=false 的纹理 GL id,并从列表中移除。
  • close():释放所有 owned 纹理 + 清空列表。

上传工具方法

public static void upload(int textureId, int[] pixels, int width, int height, boolean blur, boolean clamp);
public static void upload(int textureId, BufferedImage image, int width, int height, boolean blur, boolean clamp);
  • blur=false → GL_NEAREST;blur=true → GL_LINEAR。
  • clamp=false → GL_REPEAT(wrap);clamp=true → GL_CLAMP_TO_EDGE。
  • pixels 优先使用;如果同时给 BufferedImage,则把 BufferedImage.getRGB 拷到 pixels 后再用 pixels 版本上传。

ResourceTexture 内部类

  • 继承 AbstractTexture,保存创建时的 ResourceLocation,对 loadTexture(IResourceManager) 做空实现(资源由 SplashTextureManager 自行解析)。
  • 字段:int glTextureId、ResourceLocation location、boolean usedThisFrame。

数值

数值 默认
默认 filter NEAREST(blur=false)
默认 wrap REPEAT(clamp=false)

使用场景

  • MinecraftDisplayer 在加载阶段用 SplashTextureManager 作为自己的 TextureManager,让所有纹理引用走 owned 列表,便于线程切换时回收。
  • LateInitDynamicTexture.loadTexture 也复用 upload 静态方法。

相关条目