8个版本 (5个重大变更)
0.55.0 | 2024年2月21日 |
---|---|
0.51.1 | 2023年2月19日 |
0.50.0 | 2023年2月1日 |
0.49.1 | 2023年1月7日 |
0.44.1 | 2022年8月26日 |
#139 in 图形API
63 每月下载量
在 2 个Crates中使用(通过 egui_window_glfw_passthrough)
180KB
3.5K SLoC
警告
README可能不正确,因为我目前保持原样。我最终计划放弃这个库,并恢复到原始的piston的 glfw-rs
,一旦glfw发布带有鼠标Passthrough补丁的稳定版本 3.4
。
glfw-rs
GLFW绑定和Rust编程语言的包装器。
示例
use glfw_passthrough as 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)
}
_ => {}
}
}
使用 glfw-rs
先决条件
确保您已编译并安装了GLFW 3.x。您可能可以在包管理器中找到它,例如在OS X上:brew install glfw3
(您可能需要运行 brew tap homebrew/versions
)。如果没有,您可以下载并从GLFW网站提供的源代码构建库。注意,如果您在Linux上使用CMake编译GLFW,您将需要提供 -DCMAKE_C_FLAGS=-fPIC
参数。您可以安装GLFW到您的 PATH
,否则您在调用 make
或 make lib
时必须指定包含库二进制文件的目录。
GLFW_LIB_DIR=path/to/glfw/lib/directory make
将 glfw-rs-passthorugh 包含到您的项目中
将以下内容添加到您的 Cargo.toml
[dependencies.glfw-passthrough]
version = "*"
在Windows上
默认情况下,glfw-rs-passthrough
将尝试编译 glfw
库。如果您想链接到您自定义构建的 glfw
或如果构建不成功(在Windows上可能是这种情况),您可以禁用此功能
[dependencies.glfw-passthrough]
git = "https://github.com/coderedart/glfw-rs-passthrough.git"
default-features = false
依赖关系
~1.1–3.5MB
~73K SLoC