pub fn init<T>(callback: T) -> Result<Glfw, InitError>Expand description
Initializes the GLFW library. This must be called on the main platform thread.
Wrapper for glfwInit.
§Example
extern crate glfw;
fn main() {
let glfw = glfw::init_no_callbacks().unwrap();
}§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::init function.
extern crate glfw;
#[macro_use]
extern crate log;
fn main() {
let glfw = glfw::init(error_callback).unwrap();
}
fn error_callback(err: glfw::Error, description: String) {
error!("GLFW error {:?}: {:?}", err, description);
}§Returns
- If initialization was successful a
Glfwtoken will be returned along with aReceiverfrom which errors can be intercepted. - Subsequent calls to
initwill returnGlfwtoken immediately. - If an initialization error occurred within the GLFW library
Err(InternalInitError)will be returned.