Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/PistonDevelopers/glfw-rs
GLFW3 bindings and idiomatic wrapper for Rust.
https://github.com/PistonDevelopers/glfw-rs
Last synced: about 1 month ago
JSON representation
GLFW3 bindings and idiomatic wrapper for Rust.
- Host: GitHub
- URL: https://github.com/PistonDevelopers/glfw-rs
- Owner: PistonDevelopers
- License: apache-2.0
- Created: 2012-09-15T05:09:59.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-02-15T22:12:25.000Z (4 months ago)
- Last Synced: 2024-04-28T03:18:59.908Z (about 1 month ago)
- Language: Rust
- Homepage:
- Size: 1.67 MB
- Stars: 629
- Watchers: 37
- Forks: 118
- Open Issues: 41
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-rust - PistonDevelopers/glfw-rs
- awesome-rust-zh - PistonDevelopers/glfw-rs - [<img src="https://api.travis-ci.org/PistonDevelopers/glfw-rs.svg?branch=master">](https://travis-ci.org/PistonDevelopers/glfw-rs) (库 / 图像)
- awesome-rust - PistonDevelopers/glfw-rs - ci.org/PistonDevelopers/glfw-rs.svg?branch=master)](https://travis-ci.org/PistonDevelopers/glfw-rs) (Libraries / Graphics)
- awesome-stars - glfw-rs
- awesome-rust - PistonDevelopers/glfw-rs - ci.org/PistonDevelopers/glfw-rs.svg?branch=master">](https://travis-ci.org/PistonDevelopers/glfw-rs) (库 Libraries / 图像 Graphics)
- awesome-rust - PistonDevelopers/glfw-rs - ci.org/PistonDevelopers/glfw-rs.svg?branch=master">](https://travis-ci.org/PistonDevelopers/glfw-rs) (Libraries / Graphics)
- awesome-rust-cn - PistonDevelopers/glfw-rs - ci.org/PistonDevelopers/glfw-rs.svg?branch=master">](https://travis-ci.org/PistonDevelopers/glfw-rs) (Libraries / Graphics)
- awesome-stars - glfw-rs
- awesome-rust-cn - PistonDevelopers/glfw-rs
- awesome-rust - PistonDevelopers/glfw-rs - ci.org/PistonDevelopers/glfw-rs.svg?branch=master">](https://travis-ci.org/PistonDevelopers/glfw-rs) (Libraries / Graphics)
- awesome-rust - PistonDevelopers/glfw-rs - ci.org/PistonDevelopers/glfw-rs.svg?branch=master)](https://travis-ci.org/PistonDevelopers/glfw-rs) (Libraries / Graphics)
README
# glfw-rs
[![Crates.io](https://img.shields.io/crates/v/glfw)](https://crates.io/crates/glfw)
[![Docs.rs](https://docs.rs/glfw/badge.svg)](https://docs.rs/glfw)
[![Build Status](https://travis-ci.org/PistonDevelopers/glfw-rs.svg?branch=master)](https://travis-ci.org/PistonDevelopers/glfw-rs)GLFW bindings and wrapper for The Rust Programming Language.
## Example
~~~rust
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.");window.set_key_polling(true);
window.make_current();while !window.should_close() {
glfw.poll_events();
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, _) => {
window.set_should_close(true)
}
_ => {}
}
}
~~~## Using glfw-rs
### Prerequisites
Make sure you have [compiled and installed GLFW 3.x](http://www.glfw.org/docs/latest/compile.html).
You might be able to find it on your package manager, for example on OS X:
`brew install glfw3` (you may need to run `brew tap homebrew/versions`).
If not you can download and build the library
[from the source](http://www.glfw.org/docs/latest/compile.html) 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`:
~~~toml
[dependencies.glfw]
version = "*"
~~~#### 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:~~~toml
[dependencies.glfw]
version = "*"
default-features = false
~~~## Support
Contact `bjz` on irc.mozilla.org [#rust](http://mibbit.com/?server=irc.mozilla.org&channel=%23rust)
and [#rust-gamedev](http://mibbit.com/?server=irc.mozilla.org&channel=%23rust-gamedev),
or [post an issue](https://github.com/bjz/glfw-rs/issues/new) on GitHub.## glfw-rs in use
- [sebcrozet/kiss3d](https://github.com/sebcrozet/kiss3d)
- [Jeaye/q3](https://github.com/Jeaye/q3)
- [cyndis/rsmc](https://github.com/cyndis/rsmc/)
- [ozkriff/zoc](https://github.com/ozkriff/zoc)