CubeMapTexture.java
net.minecraft.client.renderer.texture.CubeMapTexture
信息
- 全限定名:net.minecraft.client.renderer.texture.CubeMapTexture
- 类型:public class
- 包:net.minecraft.client.renderer.texture
- 源码路径:src/main/java/net/minecraft/client/renderer/texture/CubeMapTexture.java
- 起始行号:L15
- 继承:ReloadableTexture
- 职责:
TODO
字段/常量
SUFFIXES- 类型:
String[] - 修饰符:
private static final - 源码定位:
L16 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public CubeMapTexture(Identifier resourceId) @ L18
- 构造器名:CubeMapTexture
- 源码定位:L18
- 修饰符:public
参数:
- resourceId: Identifier
说明:
TODO
方法
下面的方法块按源码顺序生成。
public TextureContents loadContents(ResourceManager resourceManager) @ L22
- 方法名:loadContents
- 源码定位:L22
- 返回类型:TextureContents
- 修饰符:public
参数:
- resourceManager: ResourceManager
说明:
TODO
protected void doLoad(NativeImage image) @ L62
- 方法名:doLoad
- 源码定位:L62
- 返回类型:void
- 修饰符:protected
参数:
- image: NativeImage
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class CubeMapTexture extends ReloadableTexture {
private static final String[] SUFFIXES = new String[]{"_1.png", "_3.png", "_5.png", "_4.png", "_0.png", "_2.png"};
public CubeMapTexture(Identifier resourceId) {
super(resourceId);
}
@Override
public TextureContents loadContents(ResourceManager resourceManager) throws IOException {
Identifier location = this.resourceId();
TextureContents var15;
try (TextureContents first = TextureContents.load(resourceManager, location.withSuffix(SUFFIXES[0]))) {
int width = first.image().getWidth();
int height = first.image().getHeight();
NativeImage stackedImage = new NativeImage(width, height * 6, false);
first.image().copyRect(stackedImage, 0, 0, 0, 0, width, height, false, true);
for (int i = 1; i < 6; i++) {
try (TextureContents part = TextureContents.load(resourceManager, location.withSuffix(SUFFIXES[i]))) {
if (part.image().getWidth() != width || part.image().getHeight() != height) {
throw new IOException(
"Image dimensions of cubemap '"
+ location
+ "' sides do not match: part 0 is "
+ width
+ "x"
+ height
+ ", but part "
+ i
+ " is "
+ part.image().getWidth()
+ "x"
+ part.image().getHeight()
);
}
part.image().copyRect(stackedImage, 0, 0, 0, i * height, width, height, false, true);
}
}
var15 = new TextureContents(stackedImage, new TextureMetadataSection(true, false, MipmapStrategy.MEAN, 0.0F));
}
return var15;
}
@Override
protected void doLoad(NativeImage image) {
GpuDevice device = RenderSystem.getDevice();
int width = image.getWidth();
int height = image.getHeight() / 6;
this.close();
this.texture = device.createTexture(this.resourceId()::toString, 21, TextureFormat.RGBA8, width, height, 6, 1);
this.textureView = device.createTextureView(this.texture);
for (int i = 0; i < 6; i++) {
device.createCommandEncoder().writeToTexture(this.texture, image, 0, i, 0, 0, width, height, 0, height * i);
}
}
}引用的其他类
-
- 引用位置:
参数/构造调用 - 关联成员:
NativeImage()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
RenderSystem.getDevice()
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
方法调用/构造调用/返回值 - 关联成员:
TextureContents(), TextureContents.load()
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
TextureMetadataSection()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: