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

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

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

GLFW.glfwInit介绍

[英]Initializes the GLFW library. Before most GLFW functions can be used, GLFW must be initialized, and before an application terminates GLFW should be terminated in order to free any resources allocated during or after initialization.

If this function fails, it calls #glfwTerminate before returning. If it succeeds, you should call #glfwTerminate before the application exits.

Additional calls to this function after successful initialization but before termination will return #GLFW_TRUE immediately.

Note
  • This function must only be called from the main thread.
  • macOS: This function will change the current directory of the application to the Contents/Resources subdirectory of the application's bundle, if present. This can be disabled with the #GLFW_COCOA_CHDIR_RESOURCES init hint.
    [中]初始化GLFW库。在使用大多数GLFW函数之前,必须初始化GLFW,并且在应用程序终止之前,应终止GLFW,以便释放初始化期间或之后分配的任何资源。
    如果此函数失败,它将在返回前调用#glfweterminate。如果成功,则应在应用程序退出之前调用#glfweterminate。
    初始化成功后但终止前对该函数的其他调用将立即返回#GLFW_TRUE。
    #####注
    *只能从主线程调用此函数。
    *macOS:此函数将应用程序的当前目录更改为应用程序包的“Contents/Resources”子目录(如果存在)。这可以通过#GLFW_cococoa_CHDIR_RESOURCES init提示禁用。

代码示例

代码示例来源: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

if (!glfwInit()) {
  throw new IllegalStateException("Unable to initialize GLFW");

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

if ( glfwInit() == false ) {
  throw new IllegalStateException("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: fynnfluegge/oreon-engine

public static void create(){
    
    init();

    camera = new GLCamera();
    window = new GLWindow(); 
    resources = new GLResources();

    if (!glfwInit())
      throw new IllegalStateException("Unable to initialize GLFW");

    // create OpenGL Context
    window.create();
    
    log.info("OpenGL version: " + GL11.glGetString(GL11.GL_VERSION));
//        log.info("Max Geometry Uniform Blocks: " + GL11.glGetInteger(GL31.GL_MAX_GEOMETRY_UNIFORM_BLOCKS));
//        log.info("Max Geometry Shader Invocations: " + GL11.glGetInteger(GL40.GL_MAX_GEOMETRY_SHADER_INVOCATIONS));
//        log.info("Max Uniform Buffer Bindings: " + GL11.glGetInteger(GL31.GL_MAX_UNIFORM_BUFFER_BINDINGS));
//        log.info("Max Uniform Block Size: " + GL11.glGetInteger(GL31.GL_MAX_UNIFORM_BLOCK_SIZE) + " bytes");
//        log.info("Max SSBO Block Size: " + GL11.glGetInteger(GL43.GL_MAX_SHADER_STORAGE_BLOCK_SIZE) + " bytes");    
//        log.info("Max Image Bindings: " + GL11.glGetInteger(GL42.GL_MAX_IMAGE_UNITS));

    GLUtil.init();
  }

代码示例来源: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: fynnfluegge/oreon-engine

deviceManager = new DeviceManager();
if (!glfwInit())
  throw new IllegalStateException("Unable to initialize GLFW");

代码示例来源: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

if ( glfwInit() != GL11.GL_TRUE )
  throw new IllegalStateException("Unable to initialize GLFW");

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

if ( glfwInit() != GL11.GL_TRUE )
  throw new IllegalStateException("Unable to initialize GLFW");

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

if (!glfwInit()) throw new RuntimeException("Failed to init GLFW.");

代码示例来源:origin: lwjglgamedev/lwjglbook

if (!glfwInit()) {
  throw new IllegalStateException("Unable to initialize GLFW");

代码示例来源:origin: lwjglgamedev/lwjglbook

if (!glfwInit()) {
  throw new IllegalStateException("Unable to initialize GLFW");

代码示例来源:origin: lwjglgamedev/lwjglbook

if (!glfwInit()) {
  throw new IllegalStateException("Unable to initialize GLFW");

代码示例来源:origin: lwjglgamedev/lwjglbook

if (!glfwInit()) {
  throw new IllegalStateException("Unable to initialize GLFW");

代码示例来源:origin: lwjglgamedev/lwjglbook

if (!glfwInit()) {
  throw new IllegalStateException("Unable to initialize GLFW");

代码示例来源:origin: lwjglgamedev/lwjglbook

if (!glfwInit()) {
  throw new IllegalStateException("Unable to initialize GLFW");

代码示例来源:origin: lwjglgamedev/lwjglbook

if (!glfwInit()) {
  throw new IllegalStateException("Unable to initialize GLFW");

相关文章

GLFW类方法