RenderTargetDescriptor.java

com.mojang.blaze3d.resource.RenderTargetDescriptor

信息

  • 全限定名:com.mojang.blaze3d.resource.RenderTargetDescriptor
  • 类型:public record
  • 包:com.mojang.blaze3d.resource
  • 源码路径:src/main/java/com/mojang/blaze3d/resource/RenderTargetDescriptor.java
  • 起始行号:L10
  • 实现:ResourceDescriptor
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public RenderTarget allocate() @ L11

  • 方法名:allocate
  • 源码定位:L11
  • 返回类型:RenderTarget
  • 修饰符:public

参数:

说明:

TODO

public void prepare(RenderTarget resource) @ L15

  • 方法名:prepare
  • 源码定位:L15
  • 返回类型:void
  • 修饰符:public

参数:

  • resource: RenderTarget

说明:

TODO

public void free(RenderTarget resource) @ L25

  • 方法名:free
  • 源码定位:L25
  • 返回类型:void
  • 修饰符:public

参数:

  • resource: RenderTarget

说明:

TODO

public boolean canUsePhysicalResource(ResourceDescriptor<?> other) @ L29

  • 方法名:canUsePhysicalResource
  • 源码定位:L29
  • 返回类型:boolean
  • 修饰符:public

参数:

  • other: ResourceDescriptor<?>

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public record RenderTargetDescriptor(int width, int height, boolean useDepth, int clearColor) implements ResourceDescriptor<RenderTarget> {
    public RenderTarget allocate() {
        return new TextureTarget(null, this.width, this.height, this.useDepth);
    }
 
    public void prepare(RenderTarget resource) {
        if (this.useDepth) {
            RenderSystem.getDevice()
                .createCommandEncoder()
                .clearColorAndDepthTextures(resource.getColorTexture(), this.clearColor, resource.getDepthTexture(), 1.0);
        } else {
            RenderSystem.getDevice().createCommandEncoder().clearColorTexture(resource.getColorTexture(), this.clearColor);
        }
    }
 
    public void free(RenderTarget resource) {
        resource.destroyBuffers();
    }
 
    @Override
    public boolean canUsePhysicalResource(ResourceDescriptor<?> other) {
        return !(other instanceof RenderTargetDescriptor descriptor)
            ? false
            : this.width == descriptor.width && this.height == descriptor.height && this.useDepth == descriptor.useDepth;
    }
}

引用的其他类