Skip to content

Commit

Permalink
Load libEGL.so.1 by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothée Haudebourg committed Feb 22, 2021
1 parent 131dd48 commit fa02f96
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unpublished]
## [3.0.1]
### Changed
- Load `libEGL.so.1` by default instead of `libEGL.so`.

## [3.0.0]
### Changed
- Impl `Debug` for `Static`, `Dynamic` and `Instance`.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "khronos-egl"
version = "3.0.0"
version = "3.0.1"
authors = ["Timothée Haudebourg <[email protected]>", "Sean Kerr <[email protected]>"]
license = "MIT/Apache-2.0"
description = "Rust bindings for EGL"
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ which is left unmaintained.
## Usage

You can access the EGL API using an [`Instance`](https://docs.rs/khronos-egl/latest/khronos-egl/struct.Instance.html)
object defined by either statically linking with `libEGL.so` at compile time,
object defined by either statically linking with `libEGL.so.1` at compile time,
or dynamically loading the EGL library at runtime.

### Static linking
Expand Down Expand Up @@ -93,12 +93,12 @@ necessary to find the EGL library at runtime.
You can then load the EGL API into a `Instance<Dynamic<libloading::Library>>` as follows:

```rust
let lib = libloading::Library::new("libEGL.so").expect("unable to find libEGL.so");
let egl = unsafe { egl::DynamicInstance::<egl::EGL1_4>::load_required_from(lib).expect("unable to load libEGL.so") };
let lib = libloading::Library::new("libEGL.so.1").expect("unable to find libEGL.so.1");
let egl = unsafe { egl::DynamicInstance::<egl::EGL1_4>::load_required_from(lib).expect("unable to load libEGL.so.1") };
```

Here, `egl::EGL1_4` is used to specify what is the minimum required version of EGL that must be provided by `libEGL.so`.
This will return a `DynamicInstance<egl::EGL1_4>`, however in that case where `libEGL.so` provides a more recent version of EGL,
Here, `egl::EGL1_4` is used to specify what is the minimum required version of EGL that must be provided by `libEGL.so.1`.
This will return a `DynamicInstance<egl::EGL1_4>`, however in that case where `libEGL.so.1` provides a more recent version of EGL,
you can still upcast ths instance to provide version specific features:
```rust
match egl.upcast::<egl::EGL1_5>() {
Expand Down
2 changes: 1 addition & 1 deletion examples/load-minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use egl::{
};

fn main() {
let minimal_egl = unsafe { Arc::new(egl::DynamicInstance::load().expect("unable to load libEGL.so")) };
let minimal_egl = unsafe { Arc::new(egl::DynamicInstance::load().expect("unable to load libEGL.so.1")) };

println!("EGL version is {}", minimal_egl.version());

Expand Down
2 changes: 1 addition & 1 deletion examples/wayland-dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fn create_surface(
}

fn main() {
let egl = unsafe { Arc::new(egl::DynamicInstance::<egl::EGL1_5>::load_required().expect("unable to load libEGL.so")) };
let egl = unsafe { Arc::new(egl::DynamicInstance::<egl::EGL1_5>::load_required().expect("unable to load libEGL.so.1")) };

// Setup Open GL.
egl.bind_api(egl::OPENGL_API)
Expand Down
26 changes: 13 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! ## Usage
//!
//! You can access the EGL API using an [`Instance`]
//! object defined by either statically linking with `libEGL.so` at compile time,
//! object defined by either statically linking with `libEGL.so.1` at compile time,
//! or dynamically loading the EGL library at runtime.
//!
//! ### Static linking
Expand Down Expand Up @@ -87,17 +87,17 @@
//!
//! ```
//! # extern crate khronos_egl as egl;
//! let lib = libloading::Library::new("libEGL.so").expect("unable to find libEGL.so");
//! let egl = unsafe { egl::DynamicInstance::<egl::EGL1_4>::load_required_from(lib).expect("unable to load libEGL.so") };
//! let lib = libloading::Library::new("libEGL.so.1").expect("unable to find libEGL.so.1");
//! let egl = unsafe { egl::DynamicInstance::<egl::EGL1_4>::load_required_from(lib).expect("unable to load libEGL.so.1") };
//! ```
//!
//! Here, `egl::EGL1_4` is used to specify what is the minimum required version of EGL that must be provided by `libEGL.so`.
//! This will return a `DynamicInstance<egl::EGL1_4>`, however in that case where `libEGL.so` provides a more recent version of EGL,
//! Here, `egl::EGL1_4` is used to specify what is the minimum required version of EGL that must be provided by `libEGL.so.1`.
//! This will return a `DynamicInstance<egl::EGL1_4>`, however in that case where `libEGL.so.1` provides a more recent version of EGL,
//! you can still upcast ths instance to provide version specific features:
//! ```
//! # extern crate khronos_egl as egl;
//! # let lib = libloading::Library::new("libEGL.so").expect("unable to find libEGL.so");
//! # let egl = unsafe { egl::DynamicInstance::<egl::EGL1_4>::load_required_from(lib).expect("unable to load libEGL.so") };
//! # let lib = libloading::Library::new("libEGL.so.1").expect("unable to find libEGL.so.1");
//! # let egl = unsafe { egl::DynamicInstance::<egl::EGL1_4>::load_required_from(lib).expect("unable to load libEGL.so.1") };
//! match egl.upcast::<egl::EGL1_5>() {
//! Some(egl1_5) => {
//! // do something with EGL 1.5
Expand Down Expand Up @@ -1981,14 +1981,14 @@ macro_rules! api {
}

#[inline(always)]
/// Create an EGL instance by finding and loading the `libEGL.so` library.
/// Create an EGL instance by finding and loading the `libEGL.so.1` library.
///
/// This is equivalent to `DynamicInstance::load_from_filename("libEGL.so")`.
/// This is equivalent to `DynamicInstance::load_from_filename("libEGL.so.1")`.
///
/// ## Safety
/// This is fundamentally unsafe since there are no guaranties the found library complies to the EGL API.
pub unsafe fn load() -> Result<DynamicInstance<EGL1_0>, libloading::Error> {
Self::load_from_filename("libEGL.so")
Self::load_from_filename("libEGL.so.1")
}
}
};
Expand Down Expand Up @@ -2193,15 +2193,15 @@ macro_rules! api {
}

#[inline(always)]
/// Create an EGL instance by finding and loading the `libEGL.so` library.
/// Create an EGL instance by finding and loading the `libEGL.so.1` library.
/// This function fails if the EGL library does not provide the minimum required version given by the type parameter.
///
/// This is equivalent to `DynamicInstance::load_required_from_filename("libEGL.so")`.
/// This is equivalent to `DynamicInstance::load_required_from_filename("libEGL.so.1")`.
///
/// ## Safety
/// This is fundamentally unsafe since there are no guaranties the found library complies to the EGL API.
pub unsafe fn load_required() -> Result<DynamicInstance<$id>, LoadError<libloading::Error>> {
Self::load_required_from_filename("libEGL.so")
Self::load_required_from_filename("libEGL.so.1")
}
}
}
Expand Down

0 comments on commit fa02f96

Please sign in to comment.