Java 类org.lwjgl.system.APIUtil 实例源码

项目:debug    文件:GLFW.java   
public static boolean glfwInit() {
    boolean ret;
    if (Properties.VALIDATE.enabled) {
        debug("Registering GLFWErrorCallback");
        /* Set a GLFW error callback first and remember any possibly current callback to delegate to */
        errorCallback = new GLFWErrorCallback() {
            private final Map<Integer, String> ERROR_CODES = APIUtil.apiClassTokens((field, value) -> 0x10000 < value && value < 0x20000, null, org.lwjgl.glfw.GLFW.class);

            public void invoke(int error, long description) {
                String msg = getDescription(description);
                System.err.printf("[LWJGL] %s error\n", ERROR_CODES.get(error));
                System.err.println("\tDescription : " + msg);
                System.err.println("\tStacktrace  :");
                StackTraceElement[] stack = Thread.currentThread().getStackTrace();
                for (int i = 4; i < stack.length; i++) {
                    System.err.print("\t\t");
                    System.err.println(stack[i].toString());
                }
                if (userCallback != null) {
                    userCallback.invoke(error, description);
                }
            }
        };
        userCallback = org.lwjgl.glfw.GLFW.glfwSetErrorCallback(errorCallback);
        ret = org.lwjgl.glfw.GLFW.glfwInit();
        if (!ret) {
            error("glfwInit returned false");
        }
    } else {
        ret = org.lwjgl.glfw.GLFW.glfwInit();
    }
    RT.glfwInitialized = ret;
    return ret;
}