MCPcopy Index your code
hub / github.com/PistonDevelopers/glfw-rs

github.com/PistonDevelopers/glfw-rs @0.6-compatible

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.6-compatible ↗ · + Follow
109 symbols 141 edges 14 files 5 documented · 5% updated 3mo ago★ 69136 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

glfw-rs

GLFW3 bindings for Rust. Based on alegalle's rust_glfw bindings but heavily modified to work with the latest development versions of GLFW and Rust.

If you run into any problems, please let me know.

Instructions

Building glfw-rs

  1. Make sure you have the latest version of GLFW built and installed on your system. This can be cloned from the project's Github repository. Note:
  2. The version that is available from glfw.org is very out of date, and will not work with these bindings.
  3. GLFW builds as a static library as default which doesn't work well with Rust, so you'll have to set the BUILD_SHARED_LIBS CMake option to true before you build and install it.
  4. Make sure you have the latest version of Rust built and installed. As with GLFW, this can be clone from the github repository.
  5. Clone this repository: $ git clone https://github.com/bjz/glfw3-rs.git, then $ cd glfw-rs.
  6. Run $ make. This will build the library to the ./lib directory.

Building the examples

  1. $ cd glfw/examples
  2. $ make or for a specific example $ make <example name> (eg. $ make window)

Using glfw-rs in your own projects

You can add the bindings to your rustc command like so: $ rustc <filename> -L <path to glfw-rs directory>/lib.

In order to use glfw-rs it is essential that you run your main loop from the main OS thread using do task::task().sched_mode(task::PlatformThread).spawn { ... }. Unlike C or C++, Rust programs automatically start on a separate thread from the main OS loop, so if you forget to do this the windows and input events won't be able to update. You can see an example of how to set this up in the window example.

Todo:

  • Fix examples/time.rs
  • Fix issues with callback functions:
  • glfwSetWindowRefreshCallback
  • glfwSetScrollCallback
  • Work out how best to link to glfw on windows
  • Register with Cargo Central.

~B☼

Core symbols most depended-on inside this repo

set_error_callback
called by 7
src/ml.rs
poll_events
called by 4
src/ml.rs
init
called by 2
src/ml.rs
window_hint
called by 2
src/ml.rs
wait_events
called by 2
src/ml.rs
set_swap_interval
called by 2
src/ml.rs
mod_key
called by 2
examples/clipboard.rs
terminate
called by 1
src/ml.rs

Shape

Function 104
Class 3
Method 2

Languages

Rust100%

Modules by API surface

src/ml.rs67 symbols
examples/callbacks.rs17 symbols
examples/gl-struct.rs6 symbols
examples/clipboard.rs4 symbols
examples/window.rs3 symbols
examples/title.rs3 symbols
examples/ml-wrapper.rs3 symbols
src/support/types.rs2 symbols
examples/defaults.rs2 symbols
examples/version.rs1 symbols
examples/modes.rs1 symbols

For agents

$ claude mcp add glfw-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact