Function glfw::init

source ·
pub fn init<UserData: 'static>(
    callback: Option<ErrorCallback<UserData>>
) -> Result<Glfw, InitError>
Expand description

Initializes the GLFW library. This must be called on the main platform thread.

Wrapper for glfwInit.

Error callback

An error callback can be set if desired. This allows for the handling of any errors that occur during initialization. This can subsequently be changed using the Glfw::set_error_callback function.

Example

extern crate glfw;

fn main() {
   let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
}

Returns

  • If initialization was successful a Glfw token will be returned along with a Receiver from which errors can be intercepted.
  • Subsequent calls to init will return Err(AlreadyInitialized).
  • If an initialization error occurred within the GLFW library Err(InternalInitError) will be returned.