From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../rust/khronos-egl/examples/load-minimal.rs | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 third_party/rust/khronos-egl/examples/load-minimal.rs (limited to 'third_party/rust/khronos-egl/examples/load-minimal.rs') diff --git a/third_party/rust/khronos-egl/examples/load-minimal.rs b/third_party/rust/khronos-egl/examples/load-minimal.rs new file mode 100644 index 0000000000..409376d678 --- /dev/null +++ b/third_party/rust/khronos-egl/examples/load-minimal.rs @@ -0,0 +1,43 @@ +extern crate gl; +extern crate khronos_egl as egl; +extern crate libloading; + +use std::sync::Arc; +use egl::{ + EGL1_2, + EGL1_4 +}; + +fn main() { + let minimal_egl = unsafe { Arc::new(egl::DynamicInstance::load().expect("unable to load libEGL.so.1")) }; + + println!("EGL version is {}", minimal_egl.version()); + + // Select the rendering API. + if let Some(egl1_2) = minimal_egl.upcast::() { + println!("selecting API"); + egl1_2.bind_api(egl::OPENGL_API).expect("unable to select OpenGL API"); + } + + // Setup Open GL. + gl::load_with(|name| minimal_egl.get_proc_address(name).unwrap() as *const std::ffi::c_void); + + match minimal_egl.upcast::() { + Some(egl1_4) => { + foo_with_1_4(egl1_4) + }, + None => { + foo_without_1_4(&minimal_egl) + } + } +} + +fn foo_with_1_4(_egl: &egl::Instance) { + println!("with 1.4"); + // do something that requires at least EGL 1.4. +} + +fn foo_without_1_4(_egl: &egl::Instance) { + println!("without 1.4"); + // do something without any specific EGL version (other that 1.0). +} \ No newline at end of file -- cgit v1.2.3