Skip to content

Commit 49fdabc

Browse files
authored
Merge pull request #589 from coderedart/master
- It changes dependency to glfw-sys (with generated bindings). Most of the diff is just prefixing constants with GLFW in ffi module. - changes error callback to not panic on get_clipboard_string - adds passthrough and runtime platform selection support. - changes vulkan types to use the ones from glfw-sys. (removes ash dependency) - enable all features docs.rs.
2 parents 1238aa6 + 82ac53d commit 49fdabc

File tree

10 files changed

+546
-1156
lines changed

10 files changed

+546
-1156
lines changed

.github/workflows/check.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# run cargo check on all platforms
2+
name: Check
3+
on: [push]
4+
jobs:
5+
check:
6+
name: Check
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ubuntu-latest, macos-latest, windows-latest]
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
submodules: true
15+
16+
- uses: dtolnay/rust-toolchain@stable
17+
- uses: lukka/get-cmake@latest
18+
19+
- name: Install dependencies
20+
if: matrix.os == 'ubuntu-latest'
21+
run: |
22+
sudo apt update
23+
sudo apt install -y libglfw3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev libwayland-dev libxkbcommon-dev libglfw3-dev cmake
24+
25+
# glfw 3.4 is not available on ubuntu yet. So, skip pkg-config check for now.
26+
- name: PreBuilt Libs
27+
if: matrix.os != 'ubuntu-latest'
28+
run: cargo run --example=version --features=prebuilt-libs
29+
30+
- name: Src Builds
31+
run: |
32+
cargo run --example=version --features=src-build
33+
cargo run --example=version --features=src-build,static-link

Cargo.toml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@ rust-version = "1.56"
1414
bitflags = "1.0.0"
1515
raw-window-handle-0-5 = { package = "raw-window-handle", version = "0.5.0", optional = true }
1616
raw-window-handle-0-6 = { package = "raw-window-handle", version = "0.6.0", optional = true }
17+
# TODO: remove the package attribute after glfw-sys is published
18+
glfw-sys = { version = "6", package = "glfw-sys-passthrough"}
1719

1820
[target.'cfg(target_os = "macos")'.dependencies]
1921
objc2 = "0.5.1"
2022

2123
[target.'cfg(target_os = "windows")'.dependencies]
2224
winapi = { version = "0.3", features = ["libloaderapi"] }
2325

24-
[dependencies.glfw-sys]
25-
optional = true
26-
version = "5.0.0"
2726

2827
[dependencies.image]
2928
optional = true
@@ -33,9 +32,6 @@ version = "^0.25.1"
3332
optional = true
3433
version = "0.4"
3534

36-
[dependencies.ash]
37-
optional = true
38-
version = "0.38"
3935

4036
[dependencies.serde]
4137
optional = true
@@ -44,13 +40,25 @@ features = ["derive"]
4440

4541
[dev-dependencies]
4642
log = "0.4"
43+
ash = "0.38"
4744

4845
[features]
49-
all = ["image", "vulkan", "log", "wayland", "raw-window-handle-v0-6"]
50-
default = ["glfw-sys", "raw-window-handle-v0-6"]
51-
with-window-handle-v0-5 = ["glfw-sys", "raw-window-handle-v0-5"]
52-
vulkan = ["ash"]
46+
all = ["image", "vulkan", "log", "wayland", "x11", "raw-window-handle-v0-6"]
47+
default = ["all", "prebuilt-libs"]
48+
with-window-handle-v0-5 = ["raw-window-handle-v0-5"]
49+
vulkan = ["glfw-sys/vulkan"]
5350
wayland = ["glfw-sys/wayland"]
54-
raw-window-handle-v0-6 = ["dep:raw-window-handle-0-6"]
55-
raw-window-handle-v0-5 = ["dep:raw-window-handle-0-5"]
51+
x11 = ["glfw-sys/x11"]
52+
native-handles = ["glfw-sys/native-handles"]
53+
src-build = ["glfw-sys/src-build"]
54+
prebuilt-libs = ["glfw-sys/prebuilt-libs"]
55+
static-link = ["glfw-sys/static-link"]
56+
raw-window-handle-v0-6 = ["dep:raw-window-handle-0-6", "native-handles"]
57+
raw-window-handle-v0-5 = ["dep:raw-window-handle-0-5", "native-handles"]
5658
serde = ["dep:serde"]
59+
60+
61+
[package.metadata.docs.rs]
62+
features = ["all"]
63+
no-default-features = true
64+
targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-pc-windows-msvc"]

examples/error.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ extern crate glfw;
2020
extern crate log;
2121

2222
fn main() {
23-
let mut glfw = glfw::init(error_callback)
24-
.unwrap();
23+
let mut glfw = glfw::init(error_callback).unwrap();
2524

2625
// Force the error callback to be triggered
2726
glfw.window_hint(glfw::WindowHint::ContextVersion(40000, 3000)); // Ridiculous!

examples/multiwindow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
extern crate glfw;
1717

18-
use glfw::{Action, Key};
1918
use glfw::GlfwReceiver as Receiver;
19+
use glfw::{Action, Key};
2020

2121
type WindowInstance = (glfw::PWindow, Receiver<(f64, glfw::WindowEvent)>);
2222
type WindowVector = Vec<WindowInstance>;

examples/raw_window_handle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ extern crate raw_window_handle_0_6 as raw_window_handle;
2121
extern crate raw_window_handle_0_5 as raw_window_handle;
2222

2323
use glfw::{Action, Context, Key};
24-
#[cfg(feature = "raw-window-handle-v0-6")]
25-
use raw_window_handle::{HasWindowHandle, RawWindowHandle};
2624
#[cfg(not(feature = "raw-window-handle-v0-6"))]
2725
use raw_window_handle::{HasRawWindowHandle, RawWindowHandle};
26+
#[cfg(feature = "raw-window-handle-v0-6")]
27+
use raw_window_handle::{HasWindowHandle, RawWindowHandle};
2828

2929
fn main() {
3030
let mut glfw = glfw::init_no_callbacks().unwrap();

examples/vulkan.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ use std::ptr;
2626

2727
#[cfg(feature = "vulkan")]
2828
fn main() {
29+
use ash::vk::Handle;
30+
2931
let mut glfw = glfw::init_no_callbacks().unwrap();
3032

3133
glfw.window_hint(glfw::WindowHint::Visible(true));
@@ -52,8 +54,13 @@ fn main() {
5254

5355
let mut surface: std::mem::MaybeUninit<vk::SurfaceKHR> = std::mem::MaybeUninit::uninit();
5456

55-
if window.create_window_surface(instance.handle(), ptr::null(), surface.as_mut_ptr())
56-
!= vk::Result::SUCCESS
57+
if unsafe {
58+
window.create_window_surface(
59+
instance.handle().as_raw() as _,
60+
ptr::null(),
61+
surface.as_mut_ptr() as _,
62+
)
63+
} != vk::Result::SUCCESS.as_raw()
5764
{
5865
panic!("Failed to create GLFW window surface.");
5966
}

src/callbacks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,4 @@ pub mod unbuffered {
157157
});
158158
UnsetHandlerGuard { _private: () }
159159
}
160-
}
160+
}

src/ffi/link.rs

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)