GlBackend.java

com.mojang.blaze3d.opengl.GlBackend

信息

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

    TODO

字段/常量

  • VERSION_MAJOR

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

      TODO

  • VERSION_MINOR

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

      TODO

内部类/嵌套类型

构造器

方法

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

public String getName() @ L19

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

参数:

说明:

TODO

public void setWindowHints() @ L24

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

参数:

说明:

TODO

public void handleWindowCreationErrors(GLFWErrorCapture.Error error) @ L34

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

参数:

  • error: GLFWErrorCapture.Error

说明:

TODO

public GpuDevice createDevice(long window, ShaderSource defaultShaderSource, GpuDebugOptions debugOptions) @ L49

  • 方法名:createDevice
  • 源码定位:L49
  • 返回类型:GpuDevice
  • 修饰符:public

参数:

  • window: long
  • defaultShaderSource: ShaderSource
  • debugOptions: GpuDebugOptions

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class GlBackend implements GpuBackend {
    private static final int VERSION_MAJOR = 3;
    private static final int VERSION_MINOR = 3;
 
    @Override
    public String getName() {
        return "OpenGL";
    }
 
    @Override
    public void setWindowHints() {
        GLFW.glfwWindowHint(139265, 196609);
        GLFW.glfwWindowHint(139275, 221185);
        GLFW.glfwWindowHint(139266, 3);
        GLFW.glfwWindowHint(139267, 3);
        GLFW.glfwWindowHint(139272, 204801);
        GLFW.glfwWindowHint(139270, 1);
    }
 
    @Override
    public void handleWindowCreationErrors(GLFWErrorCapture.@Nullable Error error) throws BackendCreationException {
        if (error != null) {
            if (error.error() == 65542) {
                throw new BackendCreationException("Driver does not support OpenGL");
            } else if (error.error() == 65543) {
                throw new BackendCreationException("Driver does not support OpenGL 3.3");
            } else {
                throw new BackendCreationException(error.toString());
            }
        } else {
            throw new BackendCreationException("Failed to create window with OpenGL context");
        }
    }
 
    @Override
    public GpuDevice createDevice(long window, ShaderSource defaultShaderSource, GpuDebugOptions debugOptions) {
        return new GpuDevice(new GlDevice(window, defaultShaderSource, debugOptions));
    }
}

引用的其他类