Skip to content

Commit

Permalink
Fix CI, edition & examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
timothee-haudebourg committed Oct 5, 2023
1 parent cbc6c23 commit 595e890
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 32 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
channel: [ stable, nightly ]
steps:
- uses: actions/checkout@v1
- uses: actions-rs/cargo@v1
- name: Select Rust channel
uses: actions-rs/toolchain@v1
with:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `create_platform_pixmap_surface` is now unsafe.
### Fixed
- Fix `choose_config` & `get_config` undefined behavior when the input `configs`
vector is empty. (Fixes [#21](https://github.com/timothee-haudebourg/khronos-egl/issues/21))
vector is empty. (Fixes [#21](https://github.com/timothee-haudebourg/khronos-egl/issues/21)).
- Fix Windows build (Fixes [#23](https://github.com/timothee-haudebourg/khronos-egl/pull/23)).

## [5.0.0]
### Changed
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ documentation = "https://docs.rs/khronos-egl"
readme = "README.md"
keywords = ["egl", "gl", "khronos", "opengl"]
build = "build.rs"
edition = "2021"

[features]
default = ["1_5"]
Expand Down
3 changes: 0 additions & 3 deletions examples/load-minimal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
extern crate gl;
extern crate khronos_egl as egl;
extern crate libloading;

use egl::{EGL1_2, EGL1_4};
use std::sync::Arc;

Expand Down
15 changes: 5 additions & 10 deletions examples/wayland-dynamic.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
extern crate gl;
extern crate khronos_egl as egl;
extern crate libloading;
extern crate wayland_client;
extern crate wayland_egl;
extern crate wayland_protocols;

use gl::types::{GLboolean, GLchar, GLenum, GLint, GLuint, GLvoid};
use std::ffi::CStr;
use std::ptr;
Expand Down Expand Up @@ -66,11 +60,12 @@ fn setup_wayland() -> DisplayConnection {
}

fn setup_egl(egl: &egl::DynamicInstance, display: &Display) -> egl::Display {
let egl_display = egl
.get_display(display.get_display_ptr() as *mut std::ffi::c_void)
.unwrap();
egl.initialize(egl_display).unwrap();
let egl_display = unsafe {
egl.get_display(display.get_display_ptr() as *mut std::ffi::c_void)
.unwrap()
};

egl.initialize(egl_display).unwrap();
egl_display
}

Expand Down
13 changes: 5 additions & 8 deletions examples/wayland-static.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
extern crate gl;
extern crate khronos_egl as egl;
extern crate wayland_client;
extern crate wayland_egl;
extern crate wayland_protocols;

use egl::API as egl;
use gl::types::{GLboolean, GLchar, GLenum, GLint, GLuint, GLvoid};
Expand Down Expand Up @@ -66,11 +62,12 @@ fn setup_wayland() -> DisplayConnection {
}

fn setup_egl(display: &Display) -> egl::Display {
let egl_display = egl
.get_display(display.get_display_ptr() as *mut std::ffi::c_void)
.unwrap();
egl.initialize(egl_display).unwrap();
let egl_display = unsafe {
egl.get_display(display.get_display_ptr() as *mut std::ffi::c_void)
.unwrap()
};

egl.initialize(egl_display).unwrap();
egl_display
}

Expand Down
18 changes: 9 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
//! let egl = egl::Instance::new(egl::Static);
//!
//! let wayland_display = wayland_client::Display::connect_to_env().expect("unable to connect to the wayland server");
//! let display = egl.get_display(wayland_display.get_display_ptr() as *mut std::ffi::c_void).unwrap();
//! let display = unsafe { egl.get_display(wayland_display.get_display_ptr() as *mut std::ffi::c_void) }.unwrap();
//! egl.initialize(display)?;
//!
//! let attributes = [
Expand Down Expand Up @@ -87,17 +87,17 @@
//!
//! ```
//! # extern crate khronos_egl as egl;
//! 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") };
//! let lib = unsafe { 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.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.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") };
//! # let lib = unsafe { 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 @@ -599,7 +599,7 @@ mod egl1_0 {
/// # fn main() -> Result<(), egl::Error> {
/// # let egl = egl::Instance::new(egl::Static);
/// # let wayland_display = wayland_client::Display::connect_to_env().expect("unable to connect to the wayland server");
/// # let display = egl.get_display(wayland_display.get_display_ptr() as *mut std::ffi::c_void).unwrap();
/// # let display = unsafe { egl.get_display(wayland_display.get_display_ptr() as *mut std::ffi::c_void) }.unwrap();
/// # egl.initialize(display)?;
/// # let attrib_list = [egl::RED_SIZE, 8, egl::GREEN_SIZE, 8, egl::BLUE_SIZE, 8, egl::NONE];
/// // Get the number of matching configurations.
Expand Down Expand Up @@ -660,7 +660,7 @@ mod egl1_0 {
/// # fn main() -> Result<(), egl::Error> {
/// # let egl = egl::Instance::new(egl::Static);
/// # let wayland_display = wayland_client::Display::connect_to_env().expect("unable to connect to the wayland server");
/// # let display = egl.get_display(wayland_display.get_display_ptr() as *mut std::ffi::c_void).unwrap();
/// # let display = unsafe { egl.get_display(wayland_display.get_display_ptr() as *mut std::ffi::c_void) }.unwrap();
/// # egl.initialize(display)?;
/// # let attrib_list = [egl::RED_SIZE, 8, egl::GREEN_SIZE, 8, egl::BLUE_SIZE, 8, egl::NONE];
/// let mut configs = Vec::with_capacity(1);
Expand Down Expand Up @@ -892,7 +892,7 @@ mod egl1_0 {
/// # fn main() -> Result<(), egl::Error> {
/// # let egl = egl::Instance::new(egl::Static);
/// # let wayland_display = wayland_client::Display::connect_to_env().expect("unable to connect to the wayland server");
/// # let display = egl.get_display(wayland_display.get_display_ptr() as *mut std::ffi::c_void).unwrap();
/// # let display = unsafe { egl.get_display(wayland_display.get_display_ptr() as *mut std::ffi::c_void) }.unwrap();
/// # egl.initialize(display)?;
/// let mut configs = Vec::with_capacity(egl.get_config_count(display)?);
/// egl.get_configs(display, &mut configs);
Expand Down Expand Up @@ -929,7 +929,7 @@ mod egl1_0 {
/// # fn main() -> Result<(), egl::Error> {
/// # let egl = egl::Instance::new(egl::Static);
/// # let wayland_display = wayland_client::Display::connect_to_env().expect("unable to connect to the wayland server");
/// # let display = egl.get_display(wayland_display.get_display_ptr() as *mut std::ffi::c_void).unwrap();
/// # let display = unsafe { egl.get_display(wayland_display.get_display_ptr() as *mut std::ffi::c_void) }.unwrap();
/// # egl.initialize(display)?;
/// let mut configs = Vec::with_capacity(egl.get_config_count(display)?);
/// egl.get_configs(display, &mut configs);
Expand Down

0 comments on commit 595e890

Please sign in to comment.