Skip to content

Commit

Permalink
Add Display interface for EGL/GLX
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisduerr committed Apr 28, 2024
1 parent 452db72 commit 365feab
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion glutin-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#![deny(clippy::all)]
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![cfg_attr(feature = "cargo-clippy", deny(warnings))]
#![cfg_attr(clippy, deny(warnings))]

mod window;

Expand Down
5 changes: 5 additions & 0 deletions glutin/src/api/egl/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ impl Display {
Device::from_ptr(self.inner.egl, device)
}

/// Get a reference to the initialized EGL API.
pub fn egl(&self) -> &'static Egl {
self.inner.egl
}

/// Terminate the EGL display.
///
/// When the display is managed by glutin with the
Expand Down
6 changes: 2 additions & 4 deletions glutin/src/api/egl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ pub mod device;
pub mod display;
pub mod surface;

/// TODO
pub static EGL: Lazy<Option<Egl>> = Lazy::new(|| {
pub(crate) static EGL: Lazy<Option<Egl>> = Lazy::new(|| {
#[cfg(windows)]
let paths = ["libEGL.dll", "atioglxx.dll"];

Expand All @@ -42,8 +41,7 @@ pub static EGL: Lazy<Option<Egl>> = Lazy::new(|| {
type EglGetProcAddress = unsafe extern "C" fn(*const ffi::c_void) -> *const ffi::c_void;
static EGL_GET_PROC_ADDRESS: OnceCell<libloading_os::Symbol<EglGetProcAddress>> = OnceCell::new();

/// TODO
#[allow(private_interfaces)]
/// EGL interface.
#[allow(missing_debug_implementations)]
pub struct Egl(pub SymWrapper<egl::Egl>);

Expand Down
5 changes: 5 additions & 0 deletions glutin/src/api/glx/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ impl Display {
Ok(Self { inner })
}

/// Get a reference to the initialized GLX API.
pub fn glx(&self) -> &'static Glx {
self.inner.glx
}

fn extract_display_features(
extensions: &HashSet<&'static str>,
version: Version,
Expand Down
4 changes: 3 additions & 1 deletion glutin/src/api/glx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ static GLX_EXTRA: Lazy<Option<GlxExtra>> = Lazy::new(|| {
Some(GlxExtra::new(glx))
});

pub(crate) struct Glx(pub SymWrapper<glx::Glx>);
/// GLX interface.
#[allow(missing_debug_implementations)]
pub struct Glx(pub SymWrapper<glx::Glx>);

unsafe impl Sync for Glx {}
unsafe impl Send for Glx {}
Expand Down
2 changes: 1 addition & 1 deletion glutin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#![deny(clippy::all)]
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![cfg_attr(feature = "cargo-clippy", deny(warnings))]
#![cfg_attr(clippy, deny(warnings))]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

#[cfg(all(not(egl_backend), not(glx_backend), not(wgl_backend), not(cgl_backend)))]
Expand Down
2 changes: 1 addition & 1 deletion glutin_examples/examples/egl_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ mod example {
}

let path = Path::new(IMG_PATH);
let file = OpenOptions::new().write(true).create(true).open(path).unwrap();
let file = OpenOptions::new().write(true).truncate(true).open(path).unwrap();

let mut encoder = png::Encoder::new(file, 1280, 720);
encoder.set_depth(png::BitDepth::Eight);
Expand Down
6 changes: 3 additions & 3 deletions glutin_examples/examples/switch_render_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use glutin::config::ConfigTemplateBuilder;
use glutin::context::{ContextAttributesBuilder, PossiblyCurrentContext};
use glutin::display::GetGlDisplay;
use glutin::error::{Error as GlutinError, ErrorKind};
use glutin::prelude::{NotCurrentGlContext, PossiblyCurrentGlContext, *};
use glutin::surface::{GlSurface, Surface, WindowSurface};
use glutin::prelude::*;
use glutin::surface::{Surface, WindowSurface};
use glutin_examples::gl::types::GLfloat;
use glutin_examples::{gl_config_picker, Renderer};
use glutin_winit::{self, DisplayBuilder, GlWindow};
use glutin_winit::{DisplayBuilder, GlWindow};
use raw_window_handle::HasRawWindowHandle;
use winit::dpi::PhysicalSize;
use winit::event::{ElementState, Event, WindowEvent};
Expand Down
2 changes: 1 addition & 1 deletion glutin_examples/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use glutin::display::GetGlDisplay;
use glutin::prelude::*;
use glutin::surface::SwapInterval;

use glutin_winit::{self, DisplayBuilder, GlWindow};
use glutin_winit::{DisplayBuilder, GlWindow};

pub mod gl {
#![allow(clippy::all)]
Expand Down

0 comments on commit 365feab

Please sign in to comment.