DynamicTexture.java
net.minecraft.client.renderer.texture.DynamicTexture
信息
- 全限定名:net.minecraft.client.renderer.texture.DynamicTexture
- 类型:public class
- 包:net.minecraft.client.renderer.texture
- 源码路径:src/main/java/net/minecraft/client/renderer/texture/DynamicTexture.java
- 起始行号:L18
- 继承:AbstractTexture
- 实现:Dumpable
- 职责:
TODO
字段/常量
-
LOGGER- 类型:
Logger - 修饰符:
private static final - 源码定位:
L19 - 说明:
TODO
- 类型:
-
pixels- 类型:
NativeImage - 修饰符:
private - 源码定位:
L20 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public DynamicTexture(Supplier<String> label, NativeImage image) @ L22
- 构造器名:DynamicTexture
- 源码定位:L22
- 修饰符:public
参数:
- label: Supplier
- image: NativeImage
说明:
TODO
public DynamicTexture(String label, int width, int height, boolean zero) @ L28
- 构造器名:DynamicTexture
- 源码定位:L28
- 修饰符:public
参数:
- label: String
- width: int
- height: int
- zero: boolean
说明:
TODO
public DynamicTexture(Supplier<String> label, int width, int height, boolean zero) @ L33
- 构造器名:DynamicTexture
- 源码定位:L33
- 修饰符:public
参数:
- label: Supplier
- width: int
- height: int
- zero: boolean
说明:
TODO
方法
下面的方法块按源码顺序生成。
private void createTexture(Supplier<String> label) @ L38
- 方法名:createTexture
- 源码定位:L38
- 返回类型:void
- 修饰符:private
参数:
- label: Supplier
说明:
TODO
private void createTexture(String label) @ L45
- 方法名:createTexture
- 源码定位:L45
- 返回类型:void
- 修饰符:private
参数:
- label: String
说明:
TODO
public void upload() @ L52
- 方法名:upload
- 源码定位:L52
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public NativeImage getPixels() @ L60
- 方法名:getPixels
- 源码定位:L60
- 返回类型:NativeImage
- 修饰符:public
参数:
- 无
说明:
TODO
public void setPixels(NativeImage pixels) @ L64
- 方法名:setPixels
- 源码定位:L64
- 返回类型:void
- 修饰符:public
参数:
- pixels: NativeImage
说明:
TODO
public void close() @ L69
- 方法名:close
- 源码定位:L69
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void dumpContents(Identifier selfId, Path dir) @ L75
- 方法名:dumpContents
- 源码定位:L75
- 返回类型:void
- 修饰符:public
参数:
- selfId: Identifier
- dir: Path
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class DynamicTexture extends AbstractTexture implements Dumpable {
private static final Logger LOGGER = LogUtils.getLogger();
private NativeImage pixels;
public DynamicTexture(Supplier<String> label, NativeImage image) {
this.pixels = image;
this.createTexture(label);
this.upload();
}
public DynamicTexture(String label, int width, int height, boolean zero) {
this.pixels = new NativeImage(width, height, zero);
this.createTexture(label);
}
public DynamicTexture(Supplier<String> label, int width, int height, boolean zero) {
this.pixels = new NativeImage(width, height, zero);
this.createTexture(label);
}
private void createTexture(Supplier<String> label) {
GpuDevice device = RenderSystem.getDevice();
this.texture = device.createTexture(label, 5, TextureFormat.RGBA8, this.pixels.getWidth(), this.pixels.getHeight(), 1, 1);
this.sampler = RenderSystem.getSamplerCache().getRepeat(FilterMode.NEAREST);
this.textureView = device.createTextureView(this.texture);
}
private void createTexture(String label) {
GpuDevice device = RenderSystem.getDevice();
this.texture = device.createTexture(label, 5, TextureFormat.RGBA8, this.pixels.getWidth(), this.pixels.getHeight(), 1, 1);
this.sampler = RenderSystem.getSamplerCache().getRepeat(FilterMode.NEAREST);
this.textureView = device.createTextureView(this.texture);
}
public void upload() {
if (this.texture != null) {
RenderSystem.getDevice().createCommandEncoder().writeToTexture(this.texture, this.pixels);
} else {
LOGGER.warn("Trying to upload disposed texture {}", this.getTexture().getLabel());
}
}
public NativeImage getPixels() {
return this.pixels;
}
public void setPixels(NativeImage pixels) {
this.pixels.close();
this.pixels = pixels;
}
@Override
public void close() {
this.pixels.close();
super.close();
}
@Override
public void dumpContents(Identifier selfId, Path dir) throws IOException {
if (!this.pixels.isClosed()) {
String outputId = selfId.toDebugFileName() + ".png";
Path path = dir.resolve(outputId);
this.pixels.writeToFile(path);
}
}
}引用的其他类
-
- 引用位置:
参数/字段/构造调用/返回值 - 关联成员:
NativeImage()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RenderSystem.getDevice(), RenderSystem.getSamplerCache()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数
- 引用位置: