GlTimerQuery.java

com.mojang.blaze3d.opengl.GlTimerQuery

信息

  • 全限定名:com.mojang.blaze3d.opengl.GlTimerQuery
  • 类型:public class
  • 包:com.mojang.blaze3d.opengl
  • 源码路径:src/main/java/com/mojang/blaze3d/opengl/GlTimerQuery.java
  • 起始行号:L12
  • 实现:GpuQuery
  • 职责:

    TODO

字段/常量

  • queryId

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

      TODO

  • closed

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

      TODO

  • result

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

      TODO

内部类/嵌套类型

构造器

GlTimerQuery(int queryId) @ L17

  • 构造器名:GlTimerQuery
  • 源码定位:L17
  • 修饰符:package-private

参数:

  • queryId: int

说明:

TODO

方法

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

public OptionalLong getValue() @ L21

  • 方法名:getValue
  • 源码定位:L21
  • 返回类型:OptionalLong
  • 修饰符:public

参数:

说明:

TODO

public void close() @ L36

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class GlTimerQuery implements GpuQuery {
    private final int queryId;
    private boolean closed;
    private OptionalLong result = OptionalLong.empty();
 
    GlTimerQuery(int queryId) {
        this.queryId = queryId;
    }
 
    @Override
    public OptionalLong getValue() {
        RenderSystem.assertOnRenderThread();
        if (this.closed) {
            throw new IllegalStateException("GlTimerQuery is closed");
        } else if (this.result.isPresent()) {
            return this.result;
        } else if (GL32C.glGetQueryObjecti(this.queryId, 34919) == 1) {
            this.result = OptionalLong.of(ARBTimerQuery.glGetQueryObjecti64(this.queryId, 34918));
            return this.result;
        } else {
            return OptionalLong.empty();
        }
    }
 
    @Override
    public void close() {
        RenderSystem.assertOnRenderThread();
        if (!this.closed) {
            this.closed = true;
            GL32C.glDeleteQueries(this.queryId);
        }
    }
}

引用的其他类

  • GpuQuery

    • 引用位置: 实现
  • RenderSystem

    • 引用位置: 方法调用
    • 关联成员: RenderSystem.assertOnRenderThread()