org.lwjgl.glfw.GLFW.glfwSetErrorCallback()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中org.lwjgl.glfw.GLFW.glfwSetErrorCallback()方法的一些代码示例,展示了GLFW.glfwSetErrorCallback()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GLFW.glfwSetErrorCallback()方法的具体详情如下:
包路径:org.lwjgl.glfw.GLFW
类名称:GLFW
方法名:glfwSetErrorCallback

GLFW.glfwSetErrorCallback介绍

[英]Sets the error callback, which is called with an error code and a human-readable description each time a GLFW error occurs.

The error code is set before the callback is called. Calling #glfwGetError from the error callback will return the same value as the error code argument.

The error callback is called on the thread where the error occurred. If you are using GLFW from multiple threads, your error callback needs to be written accordingly.

Because the description string may have been generated specifically for that error, it is not guaranteed to be valid after the callback has returned. If you wish to use it after the callback returns, you need to make a copy.

Once set, the error callback remains set even after the library has been terminated.

Note
  • This function may be called before #glfwInit.
  • This function must only be called from the main thread.
    [中]设置错误回调,每次发生GLFW错误时,将使用错误代码和人类可读的描述调用该回调。
    在调用回调之前设置错误代码。从错误回调调用#glfwGetError将返回与错误代码参数相同的值。
    在发生错误的线程上调用错误回调。如果从多个线程使用GLFW,则需要相应地编写错误回调。
    由于描述字符串可能是专门为该错误生成的,因此不能保证在回调返回后该字符串有效。如果您希望在回调返回后使用它,则需要制作一份副本。
    设置后,即使在库终止后,错误回调仍保持设置状态。
    #####注
    *此函数可以在#glfwInit之前调用。
    *只能从主线程调用此函数。

代码示例

代码示例来源:origin: libgdx/libgdx

static void initializeGlfw() {
  if (errorCallback == null) {
    Lwjgl3NativesLoader.load();
    errorCallback = GLFWErrorCallback.createPrint(System.err);
    GLFW.glfwSetErrorCallback(errorCallback);
    GLFW.glfwInitHint(GLFW.GLFW_JOYSTICK_HAT_BUTTONS, GLFW.GLFW_FALSE);
    if (!GLFW.glfwInit()) {
      throw new GdxRuntimeException("Unable to initialize GLFW");
    }
  }
}

代码示例来源:origin: libgdx/libgdx

static void initializeGlfw() {
  if (errorCallback == null) {
    Lwjgl3NativesLoader.load();
    errorCallback = GLFWErrorCallback.createPrint(System.err);
    GLFW.glfwSetErrorCallback(errorCallback);
    GLFW.glfwInitHint(GLFW.GLFW_JOYSTICK_HAT_BUTTONS, GLFW.GLFW_FALSE);
    if (!GLFW.glfwInit()) {
      throw new GdxRuntimeException("Unable to initialize GLFW");
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

glfwSetErrorCallback(null);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

glfwSetErrorCallback(errorCallback = new GLFWErrorCallback() {
  @Override
  public void invoke(int error, long description) {

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

glfwSetErrorCallback(errorCallback = new GLFWErrorCallback() {
  @Override
  public void invoke(int error, long description) {

代码示例来源:origin: org.lwjgl.osgi/org.lwjgl.glfw

/** See {@link GLFW#glfwSetErrorCallback SetErrorCallback}. */
public GLFWErrorCallback set() {
  glfwSetErrorCallback(this);
  return this;
}

代码示例来源:origin: WarmfulDevelopment/LWJGL-3-Tutorial

public static void setCallbacks() {
  glfwSetErrorCallback(new GLFWErrorCallbackI() {
    @Override
    public void invoke(int error, long description) {
      throw new IllegalStateException(GLFWErrorCallback.getDescription(description));
    }
  });
}

代码示例来源:origin: com.badlogicgames.gdx/gdx-backend-lwjgl3

static void initializeGlfw() {
  if (errorCallback == null) {
    Lwjgl3NativesLoader.load();
    errorCallback = GLFWErrorCallback.createPrint(System.err);
    GLFW.glfwSetErrorCallback(errorCallback);
    GLFW.glfwInitHint(GLFW.GLFW_JOYSTICK_HAT_BUTTONS, GLFW.GLFW_FALSE);
    if (!GLFW.glfwInit()) {
      throw new GdxRuntimeException("Unable to initialize GLFW");
    }
  }
}

代码示例来源:origin: jsettlers/settlers-remake

public void async_init() {
  if(debug) {
    ec = GLFWErrorCallback.createPrint(System.err);
    GLFW.glfwSetErrorCallback(ec);
  }
  if(!GLFW.glfwInit()) throw new Error("glfwInit() failed!");
  GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, debug ? GLFW.GLFW_TRUE : GLFW.GLFW_DONT_CARE);
  GLFW.glfwWindowHint(GLFW.GLFW_STENCIL_BITS, 1);
  glfw_wnd = GLFW.glfwCreateWindow(width + 1, width + 1, "lwjgl-offscreen", 0, 0);
  GLFW.glfwMakeContextCurrent(glfw_wnd);
  GLFW.glfwSwapInterval(0);
  event_converter.registerCallbacks();
}

代码示例来源:origin: Renanse/Ardor3D

@Override
public void init() {
  if (_inited) {
    return;
  }
  GLFWErrorCallback.createPrint(System.err).set();
  if (!GLFW.glfwInit()) {
    throw new IllegalStateException("Unable to initialize GLFW");
  }
  try {
    GLFW.glfwDefaultWindowHints();
    GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GL11C.GL_FALSE);
    GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GL11C.GL_FALSE);
    GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 3);
    GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 3);
    GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_DEBUG_CONTEXT, GLFW.GLFW_TRUE);
    GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
    GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE);
    GLFW.glfwSetErrorCallback(_errorCallback = GLFWErrorCallback.createPrint(System.err));
    _windowId = GLFW.glfwCreateWindow(_settings.getWidth(), _settings.getHeight(), "Ardor3D", 0, 0);
  } catch (final Exception e) {
    logger.severe("Cannot create window");
    logger.logp(Level.SEVERE, this.getClass().toString(), "initDisplay()", "Exception", e);
    throw new Ardor3dException("Cannot create window: " + e.getMessage());
  }
  _canvasRenderer.init(_settings, true); // true - do swap in renderer.
  _inited = true;
}

代码示例来源:origin: Renanse/Ardor3D

GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GLFW.GLFW_TRUE);
GLFW.glfwSetErrorCallback(_errorCallback = GLFWErrorCallback.createPrint(System.err));
if (_settings.isFullScreen()) {

代码示例来源:origin: badlogic/lwjgl3-maven-gradle

private void init() {
  glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

代码示例来源:origin: sriharshachilakapati/SilenceEngine

/**
 * Initializes the GLFW3 library. If you are not using the built-in Game class of the SilenceEngine, you should call
 * this method as soon as you can after loading the LWJGL3 natives.
 *
 * @return True if initialised successful, or else False.
 */
public static boolean init()
{
  if (isInitialized())
    return true;
  boolean state = glfwInit();
  // Return immediately in case of error
  if (!state)
    return initialized = false;
  // Error callback that does nothing
  setErrorCallback(null);
  glfwErrorCallback = GLFWErrorCallback.create((error, description) ->
      errorCallback.invoke(error, MemoryUtil.memUTF8(description)));
  // Joystick callback that does nothing
  setJoystickCallback(null);
  glfwJoystickCallback = GLFWJoystickCallback.create((joy, event) ->
      joystickCallback.invoke(joy, event == GLFW_CONNECTED));
  // Register the callback
  glfwSetErrorCallback(glfwErrorCallback);
  return initialized = true;
}

代码示例来源:origin: badlogic/lwjgl3-maven-gradle

private void init() {
  glfwSetErrorCallback(errorCallback = errorCallbackPrint(System.err));

代码示例来源:origin: playn/playn

glfwSetErrorCallback(errorCallback = new GLFWErrorCallback() {
 @Override public void invoke(int error, long description) {
  log().error("GL Error (" + error + "):" + getDescription(description));

代码示例来源:origin: FedUni/caliko

glfwSetErrorCallback(errorCallback = GLFWErrorCallback.createPrint(System.err));

代码示例来源:origin: org.jmonkeyengine/jme3-lwjgl3

glfwSetErrorCallback(errorCallback = new GLFWErrorCallback() {
  @Override
  public void invoke(int error, long description) {

相关文章

GLFW类方法