GlTextureView.java

com.mojang.blaze3d.opengl.GlTextureView

信息

  • 全限定名:com.mojang.blaze3d.opengl.GlTextureView
  • 类型:public class
  • 包:com.mojang.blaze3d.opengl
  • 源码路径:src/main/java/com/mojang/blaze3d/opengl/GlTextureView.java
  • 起始行号:L12
  • 继承:GpuTextureView
  • 职责:

    TODO

字段/常量

  • EMPTY

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L13
    • 说明:

      TODO

  • closed

    • 类型: boolean
    • 修饰符: private
    • 源码定位: L14
    • 说明:

      TODO

  • firstFboId

    • 类型: int
    • 修饰符: private
    • 源码定位: L15
    • 说明:

      TODO

  • firstFboDepthId

    • 类型: int
    • 修饰符: private
    • 源码定位: L16
    • 说明:

      TODO

  • fboCache

    • 类型: Int2IntMap
    • 修饰符: private
    • 源码定位: L17
    • 说明:

      TODO

内部类/嵌套类型

构造器

protected GlTextureView(GlTexture texture, int baseMipLevel, int mipLevels) @ L19

  • 构造器名:GlTextureView
  • 源码定位:L19
  • 修饰符:protected

参数:

  • texture: GlTexture
  • baseMipLevel: int
  • mipLevels: int

说明:

TODO

方法

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

public boolean isClosed() @ L24

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

参数:

说明:

TODO

public void close() @ L29

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

参数:

说明:

TODO

public int getFbo(DirectStateAccess dsa, GpuTexture depth) @ L46

  • 方法名:getFbo
  • 源码定位:L46
  • 返回类型:int
  • 修饰符:public

参数:

  • dsa: DirectStateAccess
  • depth: GpuTexture

说明:

TODO

private int createFbo(DirectStateAccess dsa, int depthid) @ L63

  • 方法名:createFbo
  • 源码定位:L63
  • 返回类型:int
  • 修饰符:private

参数:

  • dsa: DirectStateAccess
  • depthid: int

说明:

TODO

public GlTexture texture() @ L69

  • 方法名:texture
  • 源码定位:L69
  • 返回类型:GlTexture
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class GlTextureView extends GpuTextureView {
    private static final int EMPTY = -1;
    private boolean closed;
    private int firstFboId = -1;
    private int firstFboDepthId = -1;
    private @Nullable Int2IntMap fboCache;
 
    protected GlTextureView(GlTexture texture, int baseMipLevel, int mipLevels) {
        super(texture, baseMipLevel, mipLevels);
        texture.addViews();
    }
 
    @Override
    public boolean isClosed() {
        return this.closed;
    }
 
    @Override
    public void close() {
        if (!this.closed) {
            this.closed = true;
            this.texture().removeViews();
            if (this.firstFboId != -1) {
                GlStateManager._glDeleteFramebuffers(this.firstFboId);
            }
 
            if (this.fboCache != null) {
                for (int fbo : this.fboCache.values()) {
                    GlStateManager._glDeleteFramebuffers(fbo);
                }
            }
        }
    }
 
    public int getFbo(DirectStateAccess dsa, @Nullable GpuTexture depth) {
        int depthId = depth == null ? 0 : ((GlTexture)depth).id;
        if (this.firstFboDepthId == depthId) {
            return this.firstFboId;
        } else if (this.firstFboId == -1) {
            this.firstFboId = this.createFbo(dsa, depthId);
            this.firstFboDepthId = depthId;
            return this.firstFboId;
        } else {
            if (this.fboCache == null) {
                this.fboCache = new Int2IntArrayMap();
            }
 
            return this.fboCache.computeIfAbsent(depthId, _depthId -> this.createFbo(dsa, _depthId));
        }
    }
 
    private int createFbo(DirectStateAccess dsa, int depthid) {
        int fbo = dsa.createFrameBufferObject();
        dsa.bindFrameBufferTextures(fbo, this.texture().id, depthid, this.baseMipLevel(), 0);
        return fbo;
    }
 
    public GlTexture texture() {
        return (GlTexture)super.texture();
    }
}

引用的其他类