GLFW3 bindings and idiomatic wrapper for Rust.
Switch branches/tags
Nothing to show
Clone or download
Latest commit d3b8700 Oct 1, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Published 0.19.0 Oct 15, 2017
src Merge branch 'master' into master Sep 30, 2018
.gitignore Use syntax extension to generate link arguments Aug 5, 2014
.travis.yml Fix Travis CI build and clean up Oct 14, 2017
AUTHORS Add my name to AUTHORS Oct 22, 2016
Cargo.toml Publish 0.25.0 Sep 30, 2018
LICENSE Add LICENSE and copyright comments May 31, 2013 Removed Travis CI notes Oct 14, 2017


GLFW bindings and wrapper for The Rust Programming Language.


extern crate glfw;

use glfw::{Action, Context, Key};

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

    let (mut window, events) = glfw.create_window(300, 300, "Hello this is window", glfw::WindowMode::Windowed)
        .expect("Failed to create GLFW window.");


    while !window.should_close() {
        for (_, event) in glfw::flush_messages(&events) {
            handle_window_event(&mut window, event);

fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {
    match event {
        glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => {
        _ => {}

Using glfw-rs


Make sure you have compiled and installed GLFW 3.x. You might be able to find it on your package manager, for example on OS X: brew install --static glfw3 (you may need to run brew tap homebrew/versions). If not you can download and build the library from the source supplied on the GLFW website. Note that if you compile GLFW with CMake on Linux, you will have to supply the -DCMAKE_C_FLAGS=-fPIC argument. You may install GLFW to your PATH, otherwise you will have to specify the directory containing the library binaries when you call make or make lib:

GLFW_LIB_DIR=path/to/glfw/lib/directory make

Including glfw-rs in your project

Add this to your Cargo.toml:

git = ""

On Windows

By default, glfw-rs will try to compile the glfw library. If you want to link to your custom build of glfw or if the build doesn't work (which is probably the case on Windows), you can disable this:

git = ""
default-features = false


Contact bjz on #rust and #rust-gamedev, or post an issue on Github.

glfw-rs in use