Crate glfw[src]
An ideomatic wrapper for the GLFW library.
Example
extern crate native; extern crate glfw; use glfw::Context; #[start] fn start(argc: int, argv: **u8) -> int { // Run GLFW on the main thread native::start(argc, argv, main) } fn main() { let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap(); // Create a windowed mode window and its OpenGL context let window = glfw.create_window(300, 300, "Hello this is window", glfw::Windowed) .expect("Failed to create GLFW window."); // Make the window's context current window.make_current(); // Loop until the user closes the window while !window.should_close() { // Swap front and back buffers window.swap_buffers(); // Poll for and process events glfw.poll_events(); for (_, event) in glfw::flush_messages(&events) { println!("{}", event); match event { glfw::KeyEvent(glfw::KeyEscape, _, glfw::Press, _) => { window.set_should_close(true) }, _ => {}, } } } }
Reexports
pub use MouseButtonLeft = self::MouseButton1; |
pub use MouseButtonRight = self::MouseButton2; |
pub use MouseButtonMiddle = self::MouseButton3; |
Modules
| ffi | Low-level function bindings and constants pertaining to the underlying GLFW library. |
Structs
| Callback | |
| FlushedMessages | An iterator that yeilds until no more messages are contained in the
|
| GammaRamp | Describes the gamma ramp of a monitor. |
| Glfw | A token from which to call various GLFW functions. It can be obtained by
calling the |
| Joystick | A joystick handle. |
| Modifiers | Key modifiers |
| Monitor | A struct that wraps a |
| RenderContext | A rendering context that can be shared between tasks. |
| ShowAliases | Formats the type using aliases rather than the default variant names. |
| VidMode | Describes a single video mode. |
| Window | A struct that wraps a |
Enums
| Action | Input actions. |
| ClientApi | Client API tokens. |
| ContextRobustness | Context robustness tokens. |
| CursorMode | Cursor modes. |
| Error | Tokens corresponding to various error types. |
| InitError | An error that might be returned when |
| JoystickId | Joystick identifier tokens. |
| Key | Input keys. |
| MonitorEvent | Monitor events. |
| MouseButton | Mouse buttons. The |
| OpenGlProfile | OpenGL profile tokens. |
| WindowEvent | Window event messages. |
| WindowHint | Window hints that can be set using the |
| WindowMode | Describes the mode of a window |
Statics
pub static Alt: Modifiers = BitFlags { bits: $value } |
|
pub static Control: Modifiers = BitFlags { bits: $value } |
|
pub static FAIL_ON_ERRORS: Option<ErrorCallback<()>> = Some(Callback { f: fail_on_errors, data: () }) |
A callback that triggers a task failure when an error is encountered. |
pub static LOG_ERRORS: Option<ErrorCallback<()>> = Some(Callback { f: log_errors, data: () }) |
A callback that logs each error as it is encountered without triggering a task failure. |
pub static Shift: Modifiers = BitFlags { bits: $value } |
|
pub static Super: Modifiers = BitFlags { bits: $value } |
Traits
| Context | Methods common to renderable contexts |
Functions
| fail_on_errors | The function to be used with the |
| flush_messages | Returns an iterator that yeilds until no more messages are contained in the
|
| get_version | Wrapper for |
| get_version_string | Wrapper for |
| init | Initializes the GLFW library. This must be called on the main platform thread. |
| log_errors | The function to be used with the |
| make_context_current | Wrapper for |
Type Definitions
| ErrorCallback | An error callback. This can be supplied with some user data to be passed to the callback function when it is triggered. |
| GLProc | An OpenGL process address. |
| MonitorCallback | An monitor callback. This can be supplied with some user data to be passed to the callback function when it is triggered. |
| Scancode |