GlDebugLabel.java

com.mojang.blaze3d.opengl.GlDebugLabel

信息

  • 全限定名:com.mojang.blaze3d.opengl.GlDebugLabel
  • 类型:public abstract class
  • 包:com.mojang.blaze3d.opengl
  • 源码路径:src/main/java/com/mojang/blaze3d/opengl/GlDebugLabel.java
  • 起始行号:L16
  • 职责:

    TODO

字段/常量

  • LOGGER
    • 类型: Logger
    • 修饰符: private static final
    • 源码定位: L17
    • 说明:

      TODO

内部类/嵌套类型

  • com.mojang.blaze3d.opengl.GlDebugLabel.Core

    • 类型: class
    • 修饰符: private static
    • 源码定位: L63
    • 说明:

      TODO

  • com.mojang.blaze3d.opengl.GlDebugLabel.Empty

    • 类型: class
    • 修饰符: private static
    • 源码定位: L113
    • 说明:

      TODO

  • com.mojang.blaze3d.opengl.GlDebugLabel.Ext

    • 类型: class
    • 修饰符: private static
    • 源码定位: L117
    • 说明:

      TODO

构造器

方法

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

public void applyLabel(GlBuffer buffer) @ L19

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

参数:

  • buffer: GlBuffer

说明:

TODO

public void applyLabel(GlTexture texture) @ L22

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

参数:

  • texture: GlTexture

说明:

TODO

public void applyLabel(GlShaderModule shaderModule) @ L25

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

参数:

  • shaderModule: GlShaderModule

说明:

TODO

public void applyLabel(GlProgram program) @ L28

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

参数:

  • program: GlProgram

说明:

TODO

public void applyLabel(VertexArrayCache.VertexArray vertexArray) @ L31

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

参数:

  • vertexArray: VertexArrayCache.VertexArray

说明:

TODO

public void pushDebugGroup(Supplier<String> label) @ L34

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

参数:

  • label: Supplier

说明:

TODO

public void popDebugGroup() @ L37

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

参数:

说明:

TODO

public static GlDebugLabel create(GLCapabilities caps, boolean wantsLabels, Set<String> enabledExtensions) @ L40

  • 方法名:create
  • 源码定位:L40
  • 返回类型:GlDebugLabel
  • 修饰符:public static

参数:

  • caps: GLCapabilities
  • wantsLabels: boolean
  • enabledExtensions: Set

说明:

TODO

public boolean exists() @ L58

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public abstract class GlDebugLabel {
    private static final Logger LOGGER = LogUtils.getLogger();
 
    public void applyLabel(GlBuffer buffer) {
    }
 
    public void applyLabel(GlTexture texture) {
    }
 
    public void applyLabel(GlShaderModule shaderModule) {
    }
 
    public void applyLabel(GlProgram program) {
    }
 
    public void applyLabel(VertexArrayCache.VertexArray vertexArray) {
    }
 
    public void pushDebugGroup(Supplier<String> label) {
    }
 
    public void popDebugGroup() {
    }
 
    public static GlDebugLabel create(GLCapabilities caps, boolean wantsLabels, Set<String> enabledExtensions) {
        if (wantsLabels) {
            if (caps.GL_KHR_debug && GlDevice.USE_GL_KHR_debug) {
                enabledExtensions.add("GL_KHR_debug");
                return new GlDebugLabel.Core();
            }
 
            if (caps.GL_EXT_debug_label && GlDevice.USE_GL_EXT_debug_label) {
                enabledExtensions.add("GL_EXT_debug_label");
                return new GlDebugLabel.Ext();
            }
 
            LOGGER.warn("Debug labels unavailable: neither KHR_debug nor EXT_debug_label are supported");
        }
 
        return new GlDebugLabel.Empty();
    }
 
    public boolean exists() {
        return false;
    }
 
    @OnlyIn(Dist.CLIENT)
    private static class Core extends GlDebugLabel {
        private final int maxLabelLength = GL11.glGetInteger(33512);
 
        @Override
        public void applyLabel(GlBuffer buffer) {
            Supplier<String> label = buffer.label;
            if (label != null) {
                KHRDebug.glObjectLabel(33504, buffer.handle, StringUtil.truncateStringIfNecessary(label.get(), this.maxLabelLength, true));
            }
        }
 
        @Override
        public void applyLabel(GlTexture texture) {
            KHRDebug.glObjectLabel(5890, texture.id, StringUtil.truncateStringIfNecessary(texture.getLabel(), this.maxLabelLength, true));
        }
 
        @Override
        public void applyLabel(GlShaderModule shaderModule) {
            KHRDebug.glObjectLabel(
                33505, shaderModule.getShaderId(), StringUtil.truncateStringIfNecessary(shaderModule.getDebugLabel(), this.maxLabelLength, true)
            );
        }
 
        @Override
        public void applyLabel(GlProgram program) {
            KHRDebug.glObjectLabel(33506, program.getProgramId(), StringUtil.truncateStringIfNecessary(program.getDebugLabel(), this.maxLabelLength, true));
        }
 
        @Override
        public void applyLabel(VertexArrayCache.VertexArray vertexArray) {
            KHRDebug.glObjectLabel(32884, vertexArray.id, StringUtil.truncateStringIfNecessary(vertexArray.format.toString(), this.maxLabelLength, true));
        }
 
        @Override
        public void pushDebugGroup(Supplier<String> label) {
            KHRDebug.glPushDebugGroup(33354, 0, label.get());
        }
 
        @Override
        public void popDebugGroup() {
            KHRDebug.glPopDebugGroup();
        }
 
        @Override
        public boolean exists() {
            return true;
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    private static class Empty extends GlDebugLabel {
    }
 
    @OnlyIn(Dist.CLIENT)
    private static class Ext extends GlDebugLabel {
        @Override
        public void applyLabel(GlBuffer buffer) {
            Supplier<String> label = buffer.label;
            if (label != null) {
                EXTDebugLabel.glLabelObjectEXT(37201, buffer.handle, StringUtil.truncateStringIfNecessary(label.get(), 256, true));
            }
        }
 
        @Override
        public void applyLabel(GlTexture texture) {
            EXTDebugLabel.glLabelObjectEXT(5890, texture.id, StringUtil.truncateStringIfNecessary(texture.getLabel(), 256, true));
        }
 
        @Override
        public void applyLabel(GlShaderModule shaderModule) {
            EXTDebugLabel.glLabelObjectEXT(35656, shaderModule.getShaderId(), StringUtil.truncateStringIfNecessary(shaderModule.getDebugLabel(), 256, true));
        }
 
        @Override
        public void applyLabel(GlProgram program) {
            EXTDebugLabel.glLabelObjectEXT(35648, program.getProgramId(), StringUtil.truncateStringIfNecessary(program.getDebugLabel(), 256, true));
        }
 
        @Override
        public void applyLabel(VertexArrayCache.VertexArray vertexArray) {
            EXTDebugLabel.glLabelObjectEXT(32884, vertexArray.id, StringUtil.truncateStringIfNecessary(vertexArray.format.toString(), 256, true));
        }
 
        @Override
        public boolean exists() {
            return true;
        }
    }
}

引用的其他类