Code Monkey home page Code Monkey logo

glfw-rs's Introduction

glfw-rs

Crates.io Docs.rs Build Status

GLFW bindings and wrapper for The Rust Programming Language.

Example

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. 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 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:

[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:

[dependencies.glfw]
version = "*"
default-features = false

Raw window handle 0.5.0 compatibility

By default, glfw-rs uses raw-window-handle at v0.6.0. If your project is depending on glfw-rs with raw-window-handle v0.5.0, then use this line in your Cargo.toml:

glfw = { version = 0.56.0 , default-features = false, features = ["with-window-handle-v0-5"] }

Support

Contact bjz on irc.mozilla.org #rust and #rust-gamedev, or post an issue on GitHub.

glfw-rs in use

glfw-rs with other graphical APIs

In certain circumstances OpenGL which GLFW uses can conflict with the new handle that the graphical API is also trying to use, causing crashes, to fix this add

glfw.window_hint(WindowHint::ClientApi(ClientApiHint::NoApi));

before creating the window. If using this however you cannot use certain built-in functions, such as window.swap_buffers(), window.make_current(), and glfw.set_swap_interval(), but these should have equivalents provided by the graphical API.

glfw-rs's People

Contributors

999eagle avatar alegalle avatar aloucks avatar arturoc avatar bohdloss avatar brendanzab avatar bsekura avatar bvssvni avatar csherratt avatar emberian avatar frostie314159 avatar glowcoil avatar hadronized avatar hannobraun avatar heroesgrave avatar jasongrlicky avatar jhasse avatar kimundi avatar kvark avatar larsbergstrom avatar luqmana avatar metajack avatar novacrazy avatar ozkriff avatar rlane avatar rugamaga avatar sebcrozet avatar thatguydoru avatar vallentin avatar vecvec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glfw-rs's Issues

Unresolved name `marker::NoSync`

I'm getting a compilation error when adding this project to my cargo file:

Compiling glfw v0.0.1 (https://github.com/bjz/glfw-rs.git#df29ebf1)
Could not compile `glfw`.

--- stderr
src/glfw/callbacks.rs:92:27: 92:41 error: unresolved name `marker::NoSync`.
src/glfw/callbacks.rs:92                 no_share: marker::NoSync,
                                                   ^~~~~~~~~~~~~~
src/glfw/callbacks.rs:23:1: 61:2 note: in expansion of callback!
src/glfw/callbacks.rs:83:5: 96:6 note: expansion site
src/glfw/lib.rs:359:15: 359:29 error: use of undeclared type name `marker::NoSync`
src/glfw/lib.rs:359     no_share: marker::NoSync,
                                  ^~~~~~~~~~~~~~
src/glfw/lib.rs:431:19: 431:33 error: unresolved name `marker::NoSync`.
src/glfw/lib.rs:431         no_share: marker::NoSync,
                                      ^~~~~~~~~~~~~~
src/glfw/lib.rs:501:27: 501:41 error: unresolved name `marker::NoSync`.
src/glfw/lib.rs:501                 no_share: marker::NoSync,
                                              ^~~~~~~~~~~~~~
src/glfw/lib.rs:527:31: 527:45 error: unresolved name `marker::NoSync`.
src/glfw/lib.rs:527                     no_share: marker::NoSync,
                                                  ^~~~~~~~~~~~~~
src/glfw/lib.rs:758:15: 758:29 error: use of undeclared type name `marker::NoSync`
src/glfw/lib.rs:758     no_share: marker::NoSync,
                                  ^~~~~~~~~~~~~~
src/glfw/lib.rs:1236:27: 1236:41 error: unresolved name `marker::NoSync`.
src/glfw/lib.rs:1236                 no_share: marker::NoSync,
                                               ^~~~~~~~~~~~~~
error: aborting due to 7 previous errors

I installed glfw3 like so:

brew install --static homebrew/versions/glfw3

And added the dependency to glfw-rs like so:

[dependencies.glfw]
git = "https://github.com/bjz/glfw-rs.git"

Any ideas what I can do to make it compile? Thanks.

Full screen mode failing

I attempted to modify the 'window' example to start up in full screen.

glfw::set_error_callback(~ErrorContext);

glfw::start(proc() {
    let monitor = glfw::Monitor::get_primary().unwrap();
    let window_mode = glfw::FullScreen(monitor);
    let (w, h) = (1024, 768); // monitor.get_physical_size();
    let window = glfw::Window::create(w as u32, h as u32, "Hello this is window", window_mode)
.expect("Failed to create GLFW window.");

    window.set_key_polling(true);
    window.make_context_current();

    while !window.should_close() {
        glfw::poll_events();
        for (_, event) in window.flush_events() {
            handle_window_event(&window, event);
        }
    }
});

The full screen does not cover the entire screen. Sometimes it appears with decoration and sometimes it does not:

With decoration:

http://i.imgur.com/kvOYZH7.png

Without decoration:

http://i.imgur.com/VsuNXw1.png

I consulted #rust-gamedev and somebody told me to clone GLFW (https://github.com/glfw/glfw) and run 'tests/reopen'. In this test it toggles window mode every 5 seconds. In full screen it appears fine without decoration.

'uname -a':

Linux sven-macmini 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Does not support out of tree builds

glfw-rs doesn't support out of tree builds. I can't setup a different build directory, and make glfw-rs into into it.

Note that this issue is only related to me because of a similar issue with q3, and it seems like @jeaye is planning to fix this issue on the way to fixing that issue so you probable don't have to do anything. Mostly, I'm just putting up this issue for completeness.

Remove window.poll_events()

We already have glfw::poll_events() and should not have to poll individually on the window as well.

I've been looking at several solutions:

  • Just add an argument of type [Window] to glfw::poll_events, which is very simple, but would prevent the blind integration of calls to event polling deep in a runtime if they do not have access to all created windows. The downside is that wait_events() basically still does not work.
  • Create a separate task that also runs on the main platform thread but owns the callbacks and does blocking calls on the port. The main challenges with this approach are that it requires access to the Window instance, which cannot currently be shared across task boundaries (AFAIK).
  • Find a way to store a pointer to the Window instance safely in the UserWindowPointer and change away from the ports back to a direct call. The type system really does not like this approach, but frankly it seems to "fit" best with the threading requirements (i.e., that everything run on the main/platform/UI thread and that callbacks happen somewhat close in time to their triggering UI event).

Compiling a binary with glfw-rs rlib fails

I am using glfw-rs for 2 projects.

The first is a library, and that compiles fine.

However, when I try to use it in a binary, it gives me this error:

note: lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_callbacks::hce5ef173e2a3e4a8zIaN::v0.1':
glfw.rc:(.text+0x6791): undefined reference to `glfwGetWindowUserPointer'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Drop$Window::drop::h7dde909414fa68faqgaR::v0.1':
glfw.rc:(.text+0x684d): undefined reference to `glfwDestroyWindow'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `init::hb88950b030c32452am::v0.1':
glfw.rc:(.text+0x19d22): undefined reference to `glfwInit'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `terminate::h06a091ee8238c6adaH::v0.1':
glfw.rc:(.text+0x19e12): undefined reference to `glfwTerminate'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `get_version::he6cde4145c45e0a6a9::v0.1':
glfw.rc:(.text+0x1a2cb): undefined reference to `glfwGetVersion'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `get_version_string::h1c0968918b96f5fbaQ::v0.1':
glfw.rc:(.text+0x1a332): undefined reference to `glfwGetVersionString'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Monitor::get_primary::h3853b6cbd7313615Y8aj::v0.1':
glfw.rc:(.text+0x1a885): undefined reference to `glfwGetPrimaryMonitor'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Monitor::get_connected::h4be1565a895f30a4Y8av::v0.1':
glfw.rc:(.text+0x1ac97): undefined reference to `glfwGetMonitors'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Monitor::get_pos::he59b4e2435e75c20Y8aC::v0.1':
glfw.rc:(.text+0x1d0b1): undefined reference to `glfwGetMonitorPos'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Monitor::get_physical_size::h62c201859d501fd7Y8aD::v0.1':
glfw.rc:(.text+0x1d141): undefined reference to `glfwGetMonitorPhysicalSize'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Monitor::get_name::h3aaa47ce9a49ff01Y8aE::v0.1':
glfw.rc:(.text+0x1d1b1): undefined reference to `glfwGetMonitorName'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Monitor::get_video_modes::habc1eb616b4f6084Y8aF::v0.1':
glfw.rc:(.text+0x1d222): undefined reference to `glfwGetVideoModes'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Monitor::get_video_mode::h37829ff8c22c4176Y8a5::v0.1':
glfw.rc:(.text+0x1f3f2): undefined reference to `glfwGetVideoMode'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Monitor::set_gamma::hb72e6497bc957badY8af::v0.1':
glfw.rc:(.text+0x1f795): undefined reference to `glfwSetGamma'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Monitor::get_gamma_ramp::he5620e904f03cc69Y8ag::v0.1':
glfw.rc:(.text+0x1f7ea): undefined reference to `glfwGetGammaRamp'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Monitor::set_gamma_ramp::h0916bc26c5d52f68Y8aK::v0.1':
glfw.rc:(.text+0x2029e): undefined reference to `glfwSetGammaRamp'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `window_hint::default::h8b944d383993d970a9::v0.1':
glfw.rc:(.text+0x20632): undefined reference to `glfwDefaultWindowHints'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `window_hint::red_bits::h7734298ed8e426cdah::v0.1':
glfw.rc:(.text+0x20691): undefined reference to `glfwWindowHint'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `window_hint::green_bits::h7f16fb821c94c4f7ay::v0.1':
glfw.rc:(.text+0x206f1): undefined reference to `glfwWindowHint'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `window_hint::blue_bits::h9b7c12b1e849a2f3aP::v0.1':
glfw.rc:(.text+0x20751): undefined reference to `glfwWindowHint'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `window_hint::alpha_bits::hd09ef5f10535b0f1a6::v0.1':
glfw.rc:(.text+0x207b1): undefined reference to `glfwWindowHint'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `window_hint::depth_bits::h0e050a88d7071becan::v0.1':
glfw.rc:(.text+0x20811): undefined reference to `glfwWindowHint'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o):glfw.rc:(.text+0x20871): more undefined references to `glfwWindowHint' follow
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::create_intern::h792ee9afba3b4e4bzIay::v0.1':
glfw.rc:(.text+0x251e1): undefined reference to `glfwSetWindowUserPointer'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `__extensions__::create_intern::anon::expr_fn::ai':
glfw.rc:(.text+0x3454b): undefined reference to `glfwCreateWindow'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::free_callbacks::h637276bd461f94fdzIag::v0.1':
glfw.rc:(.text+0x35792): undefined reference to `glfwGetWindowUserPointer'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::should_close::h047252be1fe4a503zIak::v0.1':
glfw.rc:(.text+0x358a1): undefined reference to `glfwWindowShouldClose'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::set_should_close::hadae698fe4194191zIal::v0.1':
glfw.rc:(.text+0x35921): undefined reference to `glfwSetWindowShouldClose'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `__extensions__::set_title::anon::expr_fn::ar':
glfw.rc:(.text+0x35f4b): undefined reference to `glfwSetWindowTitle'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_pos::h69c599f3faf9848dzIas::v0.1':
glfw.rc:(.text+0x35fc1): undefined reference to `glfwGetWindowPos'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::set_pos::h78e8b5b34c0eb5c2zIat::v0.1':
glfw.rc:(.text+0x36051): undefined reference to `glfwSetWindowPos'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_size::hd7b5c79ab4f4e6e4zIau::v0.1':
glfw.rc:(.text+0x360c1): undefined reference to `glfwGetWindowSize'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::set_size::h6e6a6ebc34143f20zIav::v0.1':
glfw.rc:(.text+0x36151): undefined reference to `glfwSetWindowSize'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_framebuffer_size::h5ee0e88cea57a5dezIaw::v0.1':
glfw.rc:(.text+0x361c1): undefined reference to `glfwGetFramebufferSize'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::iconify::h9239e05fb0576a94zIax::v0.1':
glfw.rc:(.text+0x36231): undefined reference to `glfwIconifyWindow'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::restore::h84ba1a72d7ea26e4zIay::v0.1':
glfw.rc:(.text+0x36281): undefined reference to `glfwRestoreWindow'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::show::h205b5d6e76e80736zIaz::v0.1':
glfw.rc:(.text+0x362d1): undefined reference to `glfwShowWindow'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::hide::h2056347b2fb7a27ezIaA::v0.1':
glfw.rc:(.text+0x36321): undefined reference to `glfwHideWindow'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_window_mode::h18e6f73c5dabe00bzIaB::v0.1':
glfw.rc:(.text+0x3637f): undefined reference to `glfwGetWindowMonitor'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::is_focused::h29eeb12ea5493e88zIaC::v0.1':
glfw.rc:(.text+0x363f0): undefined reference to `glfwGetWindowAttrib'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::is_iconified::hc298a61aba6ab870zIaD::v0.1':
glfw.rc:(.text+0x36470): undefined reference to `glfwGetWindowAttrib'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_client_api::he1249f6860386d7czIaE::v0.1':
glfw.rc:(.text+0x364f0): undefined reference to `glfwGetWindowAttrib'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_context_version::h2ca46e692fb5857dzIaF::v0.1':
glfw.rc:(.text+0x3655e): undefined reference to `glfwGetWindowAttrib'
glfw.rc:(.text+0x3658d): undefined reference to `glfwGetWindowAttrib'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o):glfw.rc:(.text+0x365bd): more undefined references to `glfwGetWindowAttrib' follow
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_cursor_mode::h16cdc5d48d967c3ezIaN::v0.1':
glfw.rc:(.text+0x36970): undefined reference to `glfwGetInputMode'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::set_cursor_mode::h55440baeefd04e0fzIaQ::v0.1':
glfw.rc:(.text+0x36a36): undefined reference to `glfwSetInputMode'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::has_sticky_keys::h09b9a1262d5b4c15zIaR::v0.1':
glfw.rc:(.text+0x36a90): undefined reference to `glfwGetInputMode'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::set_sticky_keys::h0ad44d21847c4abczIaS::v0.1':
glfw.rc:(.text+0x36b20): undefined reference to `glfwSetInputMode'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::has_sticky_mouse_buttons::h2461e14db5144b47zIaT::v0.1':
glfw.rc:(.text+0x36b80): undefined reference to `glfwGetInputMode'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::set_sticky_mouse_buttons::hd8408bc88a9fb7a8zIaU::v0.1':
glfw.rc:(.text+0x36c10): undefined reference to `glfwSetInputMode'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_key::h344e6f53daaaeb6fzIaV::v0.1':
glfw.rc:(.text+0x36c77): undefined reference to `glfwGetKey'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_mouse_button::h86aea726ecf8c2dfzIaW::v0.1':
glfw.rc:(.text+0x36ce7): undefined reference to `glfwGetMouseButton'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_cursor_pos::h947f35b8095d91f3zIaX::v0.1':
glfw.rc:(.text+0x36d7a): undefined reference to `glfwGetCursorPos'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::set_cursor_pos::ha23cc1df091e7831zIaY::v0.1':
glfw.rc:(.text+0x36e09): undefined reference to `glfwSetCursorPos'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `__extensions__::set_clipboard_string::anon::expr_fn::a0':
glfw.rc:(.text+0x36eeb): undefined reference to `glfwSetClipboardString'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_clipboard_string::ha224eb957a8495f0zIa1::v0.1':
glfw.rc:(.text+0x36f41): undefined reference to `glfwGetClipboardString'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `make_context_current::hd639d7cec832c049ab::v0.1':
glfw.rc:(.text+0x37013): undefined reference to `glfwMakeContextCurrent'
glfw.rc:(.text+0x3702f): undefined reference to `glfwMakeContextCurrent'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::is_current_context::hf9cda9699d6bd0a8zIa4::v0.1':
glfw.rc:(.text+0x370da): undefined reference to `glfwGetCurrentContext'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::swap_buffers::he54cab00b29677b0zIa5::v0.1':
glfw.rc:(.text+0x37141): undefined reference to `glfwSwapBuffers'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_x11_window::h3d2e6e10df1aa548zIa6::v0.1':
glfw.rc:(.text+0x37191): undefined reference to `glfwGetX11Window'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Window::get_glx_context::h0185add61ddaf201zIa7::v0.1':
glfw.rc:(.text+0x371e1): undefined reference to `glfwGetGLXContext'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `get_x11_display::h88612354e98e4880aE::v0.1':
glfw.rc:(.text+0x37222): undefined reference to `glfwGetX11Display'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `poll_events::h860eb0bc14878a18ae::v0.1':
glfw.rc:(.text+0x37262): undefined reference to `glfwPollEvents'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `wait_events::h857bf203a08b782cam::v0.1':
glfw.rc:(.text+0x372a2): undefined reference to `glfwWaitEvents'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Joystick::is_present::haf931ace8ec54046rxaJ::v0.1':
glfw.rc:(.text+0x38c08): undefined reference to `glfwJoystickPresent'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Joystick::get_axes::h63185762ab9f3267rxaK::v0.1':
glfw.rc:(.text+0x38c8a): undefined reference to `glfwGetJoystickAxes'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Joystick::get_buttons::h796fcd1261f65527rxaP::v0.1':
glfw.rc:(.text+0x3a8aa): undefined reference to `glfwGetJoystickButtons'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `Joystick::get_name::hd70983756f55c948rxaA::v0.1':
glfw.rc:(.text+0x3bea8): undefined reference to `glfwGetJoystickName'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `get_time::h8b5ce6c98c399c9aaS::v0.1':
glfw.rc:(.text+0x3bef2): undefined reference to `glfwGetTime'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `set_time::hcabab35afcda5ac7a3::v0.1':
glfw.rc:(.text+0x3bf52): undefined reference to `glfwSetTime'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `set_swap_interval::h12e4a4b19770bec4aj::v0.1':
glfw.rc:(.text+0x3bfa0): undefined reference to `glfwSwapInterval'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `extension_supported::anon::expr_fn::aF':
glfw.rc:(.text+0x3c5c5): undefined reference to `glfwExtensionSupported'
lib/libglfw-b34bcc5c-0.1.rlib(glfw.o): In function `get_proc_address::anon::expr_fn::aK':
glfw.rc:(.text+0x3cbed): undefined reference to `glfwGetProcAddress'
collect2: error: ld returned 1 exit status

When I recompile glfw-rs as a dynamic library, and try again, it works fine.

I suspect this is a linking problem, and you can't really fix it, but if that is the case, do you at least know of a workaround so I can use glfw-rs as a rlib?

`io error: no such file or directory` in link.rs

Running with latest Rust (rustc 0.12.0-pre-nightly (f5ac41185 2014-08-05 19:06:23 +0000)), trying to build with Cargo, I get the following error:

   Compiling semver v0.0.1 (https://github.com/rust-lang/semver#e17191f5)
   Compiling link_glfw v0.1.0 (file:/private/tmp/clean/glfw-rs)
   Compiling glfw v0.0.1 (file:/private/tmp/clean/glfw-rs)
src/glfw/ffi/link.rs:27:1: 27:13 error: io error: no such file or directory
src/glfw/ffi/link.rs:27 #[link_glfw]
                        ^~~~~~~~~~~~
error: aborting due to previous error
Could not compile `glfw`.

To learn more, run the command again with --verbose.

Very new to rust, so this might just be me not knowing what I'm doing.

-lglfw Fails

On OSX I got the following error: "ld: library not found for -lglfw".
I still got the same error after making sure GLFW was correctly installed.

After a while I figured that glfw uses "libglfw3.a" instead of "libglfw.a".
After renaming "/usr/local/lib/libglfw3.a" to "libglfw.a" it worked.

Not sure if anyone else got this error message, but just wanted to point this out.

error: conflicting implementations for trait `collections::hash::Hash`

<std macros>:5:59: 5:63 error: conflicting implementations for trait `collections::hash::Hash` [E0119]
<std macros>:5         #[deriving(PartialEq, Eq, Clone, PartialOrd, Ord, Hash)]
                                                                         ^~~~
note: in expansion of #[deriving]
<std macros>:5:9: 5:65 note: expansion site
<std macros>:1:1: 108:2 note: in expansion of bitflags!
src/glfw.rs:1022:1: 1031:2 note: expansion site
src/glfw.rs:1024:16: 1024:20 note: note conflicting implementation here
src/glfw.rs:1024     #[deriving(Hash)]

errors with rust master

I get the following errors with current rust master. Tried that because 0.8 also failed.

rustc 0.9-pre (747213a 2013-11-21 21:51:26 -0800)

WARNING: The Rust package manager is experimental and may be unstable
rusth_workspace/src/glfw/extfn.rs:32:21: 32:88 error: expected function but found `~fn(Error, ~str)`
rusth_workspace/src/glfw/extfn.rs:32             unsafe { (**cb)(cast::transmute(error), str::raw::from_c_str(description)) }
                                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:47:21: 47:80 error: expected function but found `~fn(&Monitor, MonitorEvent)`
rusth_workspace/src/glfw/extfn.rs:47             unsafe { (**cb)(&Monitor { ptr: monitor }, cast::transmute(event)) }
                                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, int, int)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:84:0: 84:129 note: expansion site
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, int, int)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:85:0: 85:133 note: expansion site
rusth_workspace/src/glfw/extfn.rs:68:58: 68:73 error: expected function but found `~fn(&Window)`
rusth_workspace/src/glfw/extfn.rs:68                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window));
                                                                                                             ^~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:86:0: 86:107 note: expansion site
rusth_workspace/src/glfw/extfn.rs:68:58: 68:73 error: expected function but found `~fn(&Window)`
rusth_workspace/src/glfw/extfn.rs:68                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window));
                                                                                                             ^~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:87:0: 87:109 note: expansion site
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, bool)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:88:0: 88:127 note: expansion site
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, bool)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:89:0: 89:131 note: expansion site
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, int, int)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:90:0: 90:145 note: expansion site
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, MouseButton, Action, Modifiers)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:91:0: 91:190 note: expansion site
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, f64, f64)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:92:0: 92:136 note: expansion site
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, bool)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:93:0: 93:134 note: expansion site
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, f64, f64)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:94:0: 94:132 note: expansion site
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, Key, i32, Action, Modifiers)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:95:0: 95:188 note: expansion site
rusth_workspace/src/glfw/extfn.rs:77:58: 77:89 error: expected function but found `~fn(&Window, char)`
rusth_workspace/src/glfw/extfn.rs:77                 window.get_fns().$field.as_ref().map(|cb| (*cb)(&window $(, $arg_conv)*));
                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rusth_workspace/src/glfw/extfn.rs:63:0: 82:1 note: in expansion of window_callback!
rusth_workspace/src/glfw/extfn.rs:96:0: 96:147 note: expansion site
error: aborting due to 15 previous errors

Latest changes break mouse input

I was on f6e2fb2 and pulled to latest 8ec06d7. Somewhere in there the cursor code became borked; when I run it my cursor does not get proper updates and things get kind of wacky. I see there are changes (719c624) to the way coords are stored, and I've updated my callbacks appropriately. For now, I'm going to hang back. Let me know what you think.

Callbacks: https://github.com/Jeaye/q3/blob/master/src/main.rs#L43
Cursor manipulation: https://github.com/Jeaye/q3/blob/master/src/gl/camera.rs#L100

Cheers,
Jeaye

linker spew trying to build some piston-examples

On Ubuntu Trusty 64bit.. if I need to take this to piston-examples, please do let me know. @bvssvni because you last touched piston-examples :P

   Compiling cube v0.0.0 (file:///home/jeff/src/piston-examples/gfx_cube)                                                           [40/1128]
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' '/home/jeff/src/piston-examples/gfx_cube/target/cube' '/home/
jeff/src/piston-examples/gfx_cube/target/cube.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-nodefaultlibs' '-Wl,--gc-sections' '-pie' '-Wl,--as-needed' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libnative-4e7c5e5c.rlib' '/home/jeff/src/piston-examples/
gfx_cube/target/deps/libglfw_game_window-468f5017f8c5f063.rlib' '/home/jeff/src/piston-examples/gfx_cube/target/deps/libgfx-fc4b15dac9046bd1.rlib' '/home/jeff/src/piston-examples/gfx_cube/target/deps/librender-f5001d138512a2a1.rlib' '/home/jeff/src/piston-examples/gfx_cube/target/d
eps/libpiston-84163e5ca344ca3d.rlib' '/home/jeff/src/piston-examples/gfx_cube/target/deps/libgraphics-ab29a476f787ded6.rlib' '/home/jeff/src/
piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib' '/home/jeff/src/piston-examples/gfx_cube/target/deps/libsemver-588b3e8c2b1d977b.rlib' '/home/jeff/src/piston-examples/gfx_cube/target/deps/libshader_version-be2bb9fb7463fbbb.rlib' '/home/jeff/src/piston-examples/gf
x_cube/target/deps/libvecmath-cb72b1b0b9fb4b3e.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtime-4e7c5e5c.rlib' '/usr/local/
lib/rustlib/x86_64-unknown-linux-gnu/lib/libserialize-4e7c5e5c.rlib' '/home/jeff/src/piston-examples/gfx_cube/target/deps/libimage-81921c4d82795555.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libflate-4e7c5e5c.rlib' '/home/jeff/src/piston-examples/gfx_cube/target/dep
s/libdevice-90ea174d3da6debc.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblog-4e7c5e5c.rlib' '/home/jeff/src/piston-examples
/gfx_cube/target/deps/libgl-bb78cdc3bae0f4e0.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4e7c5e5c.rlib' '/usr/local/lib
/rustlib/x86_64-unknown-linux-gnu/lib/librand-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsync-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustrt-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections
-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu
/lib/liblibc-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4e7c5e5c.rlib' '-L' '/home/jeff/src/piston-examples/gfx_cube/target/deps' '-L' '/home/jeff/src/piston-examples/gfx
_cube/target' '-L' '/home/jeff/src/piston-examples/gfx_cube/.rust' '-L' '/home/jeff/src/piston-examples/gfx_cube' '-Wl,--whole-archive' '-Wl,
-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynamic' '-lglfw' '-lrt' '-lXrandr' '-lXi' '-lXcursor' '-lGL' '-lm' '-ldl' '-lXrender' '-ldrm' '-lXdamage' '-lX11-xcb' '-lxcb-glx' '-lxcb-dri2' '-lxcb-dri3' '-lxcb-present' '-lxcb-sync' '-lxshmfence' '-lXxf86vm' '-lXfixes' '-lXext' '-lX11' 
'-lpthread' '-lxcb' '-lXau' '-lXdmcp' '-lrt' '-ldl' '-lpthread' '-lgcc_s' '-lpthread' '-lc' '-lm' '-lcompiler-rt'
note: /home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw_game_window-468f5017f8c5f063.rlib(glfw_game_window-468f5017f8c5f063.o): In function `Context::make_current::h6232219542696057149':
glfw_game_window.rs:(.text._ZN7Context12make_current20h6232219542696057149E+0x4b): undefined reference to `glfwMakeContextCurrent'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw_game_window-468f5017f8c5f063.rlib(glfw_game_window-468f5017f8c5f063.o): In functi
on `callbacks::error::set::closure.5836':
glfw_game_window.rs:(.text._ZN9callbacks5error3set12closure.5836E+0x45): undefined reference to `glfwSetErrorCallback'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `callbacks::error::un
set::closure.6921':
glfw.rs:(.text._ZN9callbacks5error5unset12closure.6921E+0x45): undefined reference to `glfwSetErrorCallback'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `callbacks::get_sende
r::hc7522431a818c2f2xNa':
glfw.rs:(.text._ZN9callbacks10get_sender20hc7522431a818c2f2xNaE+0x3f): undefined reference to `glfwGetWindowUserPointer'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `Glfw::window_hint::h
b2d3b5b90253e792Ple':
glfw.rs:(.text._ZN4Glfw11window_hint20hb2d3b5b90253e792PleE+0x13e): undefined reference to `glfwWindowHint'
glfw.rs:(.text._ZN4Glfw11window_hint20hb2d3b5b90253e792PleE+0x185): undefined reference to `glfwWindowHint'
glfw.rs:(.text._ZN4Glfw11window_hint20hb2d3b5b90253e792PleE+0x1cc): undefined reference to `glfwWindowHint'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o):glfw.rs:(.text._ZN4Glfw11window_hint20hb2d3b5b90253e792PleE+0x213): more undefined references to `glfwWindowHint' follow
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `Glfw::create_window_intern::h98ab68b09ea0744aFre':
glfw.rs:(.text._ZN4Glfw20create_window_intern20h98ab68b09ea0744aFreE+0x390): undefined reference to `glfwSetWindowUserPointer'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `Glfw::create_window_intern::closure.7939':
glfw.rs:(.text._ZN4Glfw20create_window_intern12closure.7939E+0xf3): undefined reference to `glfwCreateWindow'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `Window.Drop::drop::h15a80f60444688ebv1f':
glfw.rs:(.text._ZN11Window.Drop4drop20h15a80f60444688ebv1fE+0x492): undefined reference to `glfwDestroyWindow'
glfw.rs:(.text._ZN11Window.Drop4drop20h15a80f60444688ebv1fE+0x4cb): undefined reference to `glfwGetWindowUserPointer'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `Window::should_close::h3cd12d880f307666vEf':
glfw.rs:(.text._ZN6Window12should_close20h3cd12d880f307666vEfE+0x3f): undefined reference to `glfwWindowShouldClose'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `Window::set_should_close::haf434c9d0b0f7cacLEf':
glfw.rs:(.text._ZN6Window16set_should_close20haf434c9d0b0f7cacLEfE+0x5b): undefined reference to `glfwSetWindowShouldClose'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `Window::get_framebuffer_size::h8fac78b393998551THf':
glfw.rs:(.text._ZN6Window20get_framebuffer_size20h8fac78b393998551THfE+0x66): undefined reference to `glfwGetFramebufferSize'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `Window::set_cursor_pos_polling::h1cdf497aa037a807kYf':
glfw.rs:(.text._ZN6Window22set_cursor_pos_polling20h1cdf497aa037a807kYfE+0x6c): undefined reference to `glfwSetCursorPosCallback'
glfw.rs:(.text._ZN6Window22set_cursor_pos_polling20h1cdf497aa037a807kYfE+0xa2): undefined reference to `glfwSetCursorPosCallback'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `Window::set_scroll_polling::h7797dc9e0d939085wZf':
glfw.rs:(.text._ZN6Window18set_scroll_polling20h7797dc9e0d939085wZfE+0x6c): undefined reference to `glfwSetScrollCallback'
glfw.rs:(.text._ZN6Window18set_scroll_polling20h7797dc9e0d939085wZfE+0xa2): undefined reference to `glfwSetScrollCallback'
/home/jeff/src/piston-examples/gfx_cube/target/deps/libglfw-9f6ea9f24181e05c.rlib(glfw-9f6ea9f24181e05c.o): In function `Window::set_cursor_mode::h3048e89321210addXSf':
glfw.rs:(.text._ZN6Window15set_cursor_mode20h3048e89321210addXSfE+0x65): undefined reference to `glfwSetInputMode'
collect2: error: ld returned 1 exit status

error: aborting due to previous error

Example in README out of date

let window = ... should be let (window, events) = ... otherwise events is not declared.

Also, window.make_context_current(); should be window.make_current();

std::rt::start_on_main_thread no longer exists?

I get the compile error
unresolved name std::rt::start_on_main_thread
when trying to build any of the examples. I also looked in rust's repo under libstd/rt and couldn't find any instances of the function "start_on_main_thread".

Building against the latest master (for some time now) results in an ICE

Not sure where it's coming from, but something in the latest version of glfw-3 and rustc master results in the following error whenever I simply load the module.

error: internal compiler error: parse_trait_store(): bad input '/'
make: *** [all] Error 101

Code being used:

extern mod glfw;

fn main() {

}

linking fails on current rustc

Leaves a huge trace:

rust version (it was working fine with last week's snapshots):
rustc 0.12.0-pre-nightly (217f1fbfc 2014-07-22 23:11:12 +0000)

error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'myfolder/rs/target/main' 'myfolder/rs/target/main.o' '-Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' '-nodefaultlibs' '-Wl,--gc-sections' '-Wl,--as-needed' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libnative-4e7c5e5c.rlib' 'myfolder/rs/target/deps/libcgmath-7fd3dff6ae911674.rlib' 'myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsemver-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblog-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsync-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustrt-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4e7c5e5c.rlib' '/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-4e7c5e5c.rlib' '-L' 'myfolder/rs/target/deps' '-L' 'myfolder/rs/target' '-L' 'myfolder/rs/.rust' '-L' 'myfolder/rs' '-Wl,-Bdynamic' '-lglfw3' '-lrt' '-lXrandr' '-lXi' '-lXcursor' '-lGL' '-lm' '-ldl' '-lXrender' '-ldrm' '-lXdamage' '-lX11-xcb' '-lxcb-glx' '-lxcb-dri2' '-lxcb-dri3' '-lxcb-present' '-lxcb-sync' '-lxshmfence' '-lXxf86vm' '-lXfixes' '-lXext' '-lX11' '-lpthread' '-lxcb' '-lXau' '-lXdmcp' '-ldl' '-lpthread' '-lgcc_s' '-lpthread' '-lc' '-lm' '-lcompiler-rt'
note: myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw-0c9af359a6be4ca6.o): In function `log_errors::hc4c75145e92dfbcct0d':
glfw.rs:(.text._ZN10log_errors20hc4c75145e92dfbcct0dE+0x0): multiple definition of `log_errors::hc4c75145e92dfbcct0d'
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw.o):glfw.rs:(.text._ZN10log_errors20hc4c75145e92dfbcct0dE+0x0): first defined here
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw-0c9af359a6be4ca6.o): In function `Window.Drop::drop::h5a6a03833224f7e2UQf':
glfw.rs:(.text._ZN11Window.Drop4drop20h5a6a03833224f7e2UQfE+0x0): multiple definition of `Window.Drop::drop::h5a6a03833224f7e2UQf'
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw.o):glfw.rs:(.text._ZN11Window.Drop4drop20h5a6a03833224f7e2UQfE+0x0): first defined here
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw-0c9af359a6be4ca6.o): In function `get_version::h2d77fb5eed4187c13se':
glfw.rs:(.text._ZN11get_version20h2d77fb5eed4187c13seE+0x0): multiple definition of `get_version::h2d77fb5eed4187c13se'
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw.o):glfw.rs:(.text._ZN11get_version20h2d77fb5eed4187c13seE+0x0): first defined here
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw-0c9af359a6be4ca6.o): In function `Window.Context::window_ptr::hbe640057c26360299Vf':
glfw.rs:(.text._ZN14Window.Context10window_ptr20hbe640057c26360299VfE+0x0): multiple definition of `Window.Context::window_ptr::hbe640057c26360299Vf'
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw.o):glfw.rs:(.text._ZN14Window.Context10window_ptr20hbe640057c26360299VfE+0x0): first defined here
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw-0c9af359a6be4ca6.o): In function `fail_on_errors::hc90bccdd17db7de2VYd':
glfw.rs:(.text._ZN14fail_on_errors20hc90bccdd17db7de2VYdE+0x0): multiple definition of `fail_on_errors::hc90bccdd17db7de2VYd'
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw.o):glfw.rs:(.text._ZN14fail_on_errors20hc90bccdd17db7de2VYdE+0x0): first defined here
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw-0c9af359a6be4ca6.o): In function `Key...std..cmp..Eq::assert_receiver_is_total_eq::hb96ffe9eae4ff103vdd':
glfw.rs:(.text._ZN18Key...std..cmp..Eq27assert_receiver_is_total_eq20hb96ffe9eae4ff103vddE+0x0): multiple definition of `Key...std..cmp..Eq::assert_receiver_is_total_eq::hb96ffe9eae4ff103vdd'
myfolder/rs/target/deps/libglfw-0c9af359a6be4ca6.rlib(glfw.o):glfw.rs:(.text._ZN18Key...std..cmp..Eq27assert_receiver_is_total_eq20hb96ffe9eae4ff103vddE+0x0): first defined here

Actual (Loyal) Binding to glfwGetPrimaryMonitor

I think the current binding to glfwGetPrimaryMonitor (with_primary_monitor) isn't really ideal. If you want an actual reference to the monitor, it requires you to put all your code using that monitor in the closure.

Instead there should be an alternative get_primary_monitor which returns an Option<Monitor>. I am not sure if this is possible however - there must have been a reason to not stay loyal to the API, right? (lifetime issue?)

Building on Windows

Everything compiles just fine, but i'm getting this error when launching any of the examples.
error

Incompatibility with gl-rs

error: mismatched types: expected `|&str| -> std::option::Option<extern "system" fn()>` but found `fn(&str) -> std::option::Option<extern "C" fn()>` (expected "system" fn but found "C" fn)

Which was: gl::load_with(glfw::get_proc_address);

The defaults.rs example fails to build

Hi,

I tried building the examples with rust 0.7 on 32-bit Arch Linux. Several examples built successfully until:

defaults.rs:68:8: 68:9 error: type `[(u32,std::option::Option<&'static str>,&'static str), .. 12]` does not implement any method in scope named `each`
defaults.rs:68         }
                       ^
defaults.rs:58:28: 58:47 error: the type of this value must be known in this context
defaults.rs:58         for gl_params.each |&(param, ext, name)| {
                                           ^~~~~~~~~~~~~~~~~~~
defaults.rs:59:41: 59:43 error: the type of this value must be known in this context
defaults.rs:59             if do ext.map_default(true) |&s| {

Put the Key enum into it's own module for easier importing

At the moment code is forced to use glfw::Key___, which means that re-exporting all the keys to something more ideal (eg: Keys::Key___) is a nightmare.

What I propose is to move the Key enum into a module named 'Keys', so that they can be accessed through glfw::Keys::Key___, and therefore easily re-exported through pub use glfw::Keys, or maybe glob imported through use glfw::Keys::* without pulling in the rest of glfw.

I'm not sure if this is wanted, but I have a pull request ready if it is.

Build problems with newest rust nightly

The newest nightly (rustc 0.11.0-pre-nightly (d92926c 2014-05-16 01:06:25 -0700)) gives me several build errors along the lines of

error: mismatched types: expected `Modifiers` but found `core::option::Option<Modifiers>` (expected struct Modifiers but found enum core::option::Option)

and

error: type `&mut core::fmt::FormatWriter` does not implement any method in scope named `write_fmt`

The full build log is here.

undefined references

I was trying to make one of the examples, and I got a few things like this:
../lib/libglfw3-9577b6c2f8956f17-0.1.so: undefined reference to `glfwGetScrollOffset'

I am wondering if it didn't link to glfw3.h properly, or if it needs a pub in front of the definition now.

examples: library not found for -lglfw3 OSX 10.9

I can't build projects with glow-rs, my own does not compile and the examples do not compile.

things i did:
brew install --static glfw3
brew install pkg-config

errors:

error: linking with cc failed: exit code: 1
note: cc '-m64' '-L' ' ... '-lglfw3' ...
note: ld: warning: directory not found for option '-L/ ... /glfw-rs/.rust'
ld: library not found for -lglfw3
clang: error: linker command failed with exit code 1

libc not found

When compiling, it says cant find crate libc. Nowadays libc is in std.

Mutable self ref

Why don`t set_* methods require '&self' parameter to be mutable ('&mut self')?

Undefined reference to glfw**** error.

I get errors like this one when i'm trying to build an application with Cargo and glfw-rs:

/home/zeron/dev/gd/rocketsauce/target/deps/libglfw-cd120128a43da8e1.rlib(glfw-cd120128a43da8e1.o): In function `Window::should_close::ha545ee4ef5439dd0Juf':
glfw.rs:(.text._ZN6Window12should_close20ha545ee4ef5439dd0JufE+0x3f): undefined reference to `glfwWindowShouldClose'

image

As you can see, there is no link.rs in the folder with the checkout of glfw-rs. Rolling back to #194 solves this problem.

Make Failing on Linux Mint

mkdir -p lib
rustc --out-dir=lib --link-args="-lglfw3 -lrt -lXrandr -lXi -lGL -lm -ldl -lXrender -ldrm -lXdamage -lX11-xcb -lxcb-glx -lXxf86vm -lXfixes -lXext -lX11 -lpthread -lxcb -lXau -lXdmcp " -O src/lib/lib.rs
error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'lib/libglfw-rs-c68009f4-0.1.so' 'lib/glfw-rs.o' 'lib/glfw-rs.metadata.o' '-Wl,--as-needed' '-Wl,-O1' '-L/home/sven/Desktop/opensource/glfw-rs/.rust' '-L/home/sven/Desktop/opensource/glfw-rs' '-L/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lstd-966edb7e-0.10-pre' '-ldl' '-lm' '-lpthread' '-shared' '-lmorestack' '-Wl,-rpath,$ORIGIN/../../../../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-Wl,-rpath,/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lglfw3' '-lrt' '-lXrandr' '-lXi' '-lGL' '-lm' '-ldl' '-lXrender' '-ldrm' '-lXdamage' '-lX11-xcb' '-lxcb-glx' '-lXxf86vm' '-lXfixes' '-lXext' '-lX11' '-lpthread' '-lxcb' '-lXau' '-lXdmcp'
note: /usr/bin/ld: /usr/local/lib/libglfw3.a(context.c.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libglfw3.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status

By running 'cat /proc/version' I get:
Linux version 3.5.0-17-generic (buildd@allspice) (gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-2ubuntu1) ) #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012

Improve error message on Mac an Linux when pkg-config could not be found

@brownhead ran into this in #207. The error is pretty obscure:

   Compiling semver v0.0.1 (https://github.com/rust-lang/semver#e17191f5)
   Compiling link_glfw v0.1.0 (file:/private/tmp/clean/glfw-rs)
   Compiling glfw v0.0.1 (file:/private/tmp/clean/glfw-rs)
src/glfw/ffi/link.rs:27:1: 27:13 error: io error: no such file or directory
src/glfw/ffi/link.rs:27 #[link_glfw]
                        ^~~~~~~~~~~~
error: aborting due to previous error
Could not compile `glfw`.

To learn more, run the command again with --verbose.

Documentation missing for using glfw-rs with rustpkg

Running cmake, make and make install as detailed in the README does build the rlib library for glfw-rs, but then one will need to pass the path manually to rustc while using glfw-rs (at least as far as I know). Instructions for using glfw-rs easily with rustpkg would be very helpful indeed.

Does not compile

I am trying to build a copy of the git master, but I'm getting a compile error:

Console output:

sh etc/link-rs.sh "-lglfw -lrt -lm -lXrandr -lXrender -lXi -lGL -lm -lpthread -ldl -ldrm -lXdamage -lXfixes -lX11-xcb -lxcb-glx -lxcb-dri2 -lxcb-dri3 -lxcb-present -lxcb-sync -lxshmfence -lXxf86vm -lXext -lX11 -lpthread -lxcb -lXau -lXdmcp " > src/lib/link.rs
mkdir -p lib
rustc  --out-dir=lib -O src/lib/lib.rs
Makefile:39: recipe for target 'lib' failed

Compile Errors:

src/lib/callbacks.rs:45:65: 45:66 error: expected `,` but found `+`
src/lib/callbacks.rs:45             CALLBACK_KEY.replace(Some(box f as Box<Object<Args> + 'static>));
                                                                                        ^

I am using the rust compiler version 0.10 on a Linux box. Both are x86_64. I'm compiling by running make in the package's root directory.

"Ideomatic" is spelled with an "i"

The current github repository description reads:
"GLFW3 bindings and ideomatic wrapper for Rust."
It should read:
"GLFW3 bindings and idiomatic wrapper for Rust."
Spelling is important! :)

Enforce thread safety at the type level.

According to the GLFW docs, the following functions are thread-safe:

  • glfwGetVersion
  • glfwGetVersionString
  • glfwWindowShouldClose
  • glfwSetWindowShouldClose
  • glfwSetWindowUserPointer
  • glfwGetWindowUserPointer
  • glfwPostEmptyEvent
  • glfwGetTime
  • glfwMakeContextCurrent
  • glfwGetCurrentContext
  • glfwSwapBuffers
  • glfwSwapInterval
  • glfwExtensionSupported
  • glfwGetProcAddress

and the following are thread-unsafe:

  • glfwInit
  • glfwTerminate
  • glfwSetErrorCallback
  • glfwGetMonitors
  • glfwGetPrimaryMonitor
  • glfwGetMonitorPos
  • glfwGetMonitorPhysicalSize
  • glfwGetMonitorName
  • glfwSetMonitorCallback
  • glfwGetVideoModes
  • glfwGetVideoMode
  • glfwSetGamma
  • glfwGetGammaRamp
  • glfwSetGammaRamp
  • glfwDefaultWindowHints
  • glfwWindowHint
  • glfwCreateWindow
  • glfwDestroyWindow
  • glfwSetWindowTitle
  • glfwGetWindowPos
  • glfwSetWindowPos
  • glfwGetWindowSize
  • glfwSetWindowSize
  • glfwGetFramebufferSize
  • glfwIconifyWindow
  • glfwRestoreWindow
  • glfwShowWindow
  • glfwHideWindow
  • glfwGetWindowMonitor
  • glfwGetWindowAttrib
  • glfwSetWindowPosCallback
  • glfwSetWindowSizeCallback
  • glfwSetWindowCloseCallback
  • glfwSetWindowRefreshCallback
  • glfwSetWindowFocusCallback
  • glfwSetWindowIconifyCallback
  • glfwSetFramebufferSizeCallback
  • glfwPollEvents
  • glfwWaitEvents
  • glfwGetInputMode
  • glfwSetInputMode
  • glfwGetKey
  • glfwGetMouseButton
  • glfwGetCursorPos
  • glfwSetCursorPos
  • glfwCreateCursor
  • glfwDestroyCursor
  • glfwSetCursor
  • glfwSetKeyCallback
  • glfwSetCharCallback
  • glfwSetMouseButtonCallback
  • glfwSetCursorPosCallback
  • glfwSetCursorEnterCallback
  • glfwSetScrollCallback
  • glfwSetDropCallback
  • glfwJoystickPresent
  • glfwGetJoystickAxes
  • glfwGetJoystickButtons
  • glfwGetJoystickName
  • glfwSetClipboardString
  • glfwGetClipboardString
  • glfwSetTime

The rest of the functions are safe, as far as I know.

A possible API:

/// A type that lives on the main thread
#[non_sendable]
pub enum Glfw {}

impl Glfw {
    pub fn init() -> Option<Glfw> { ... }
    pub fn poll_events() { ... }
    pub fn create_window(...) -> Option<Window> { ... }
}

Client code:

let glfw = Glfw::init().unwrap();
let window = glfw.create_window(...);

Compilation Error (Mismatched Types) for link_glfw

When trying to compile glfw-rs with the latest nightly I get the following error:

Could not compile link_glfw.
--- stderr
lib.rs:35:54: 35:60 error: mismatched types: expected Box<syntax::ext::base::ItemModifier+'static>, found fn(&mut syntax::ext::base::ExtCtxt<'_>, syntax::codemap::Span, Gc<syntax::codemap::Spanned<syntax::ast::MetaItem_>>, Gc<syntax::ast::Item>) -> Gc<syntax::ast::Item> (expected box, found extern fn)
lib.rs:35 base::ItemModifier(expand));
^~~~~~
error: aborting due to previous error

Building error.

Building glfw3
./src/glfw3.rc:1126:4: 1128:5 error: type `[Joystick]/16` does not implement any method in scope named `filter_map`
./src/glfw3.rc:1126     do Joysticks.filter_map |&joy| {
./src/glfw3.rc:1127         if joy.is_present() { Some(joy) } else { None }
./src/glfw3.rc:1128     }
./src/glfw3.rc:1126:29: 1126:34 error: the type of this value must be known in this context
./src/glfw3.rc:1126     do Joysticks.filter_map |&joy| {
                                                 ^~~~~
./src/glfw3.rc:1126:29: 1126:34 error: mismatched types: expected `<V0>` found borrowed pointer
./src/glfw3.rc:1126     do Joysticks.filter_map |&joy| {
                                                 ^~~~~

Segmentation fault

rustc 0.9
Debian 7.3
Linux 3.2.0-4-686-pae
EGLIBC 2.13-38

extern mod glfw;

struct ErrorContext;
impl glfw::ErrorCallback for ErrorContext {
    fn call(&self, _: glfw::Error, description: ~str) {
        println!("GLFW Error: {:s}", description);
    }
}

fn main() {
    glfw::set_error_callback(~ErrorContext);
}

Linking errors to change in libglfw

I have found a reason for my recent comment in the issue #2 ( https://github.com/bjz/glfw3-rs/issues/2#issuecomment-13452108 ) so I'm opening a new issue for this.

commit 2cea6e37cfd1144ffa04fa0313c2f4cc825c4295
Author: Camilla Berglund <[email protected]>
Date:   Thu Jan 17 19:50:04 2013 +0100

    Removed glfwGetScrollOffset.

    Scroll events do not represent an absolute state, but rather an interpretation
    of a relative change in state, like character input.  So, like character input,
    there is no sane 'current state' to return.  The here removed solution, that of
    accumulating an offset since the last call to event processing, is at best
    mildly confusing.  If a user wishes to implement this solution, it is better for
    it to be explicit in client code than implicit in GLFW calls.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.