use egl::API as egl; use gl::types::{GLboolean, GLchar, GLenum, GLint, GLuint, GLvoid}; use std::ffi::CStr; use std::ptr; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc;
use wayland_client::{
protocol::{wl_compositor::WlCompositor, wl_surface::WlSurface},
DispatchData, Display, EventQueue, Main,
};
use wayland_protocols::xdg_shell::client::{
xdg_surface::{self, XdgSurface},
xdg_wm_base::{self, XdgWmBase},
};
fn process_xdg_event(xdg: Main<XdgWmBase>, event: xdg_wm_base::Event, _dd: DispatchData) { use xdg_wm_base::Event::*;
match event {
Ping { serial } => xdg.pong(serial),
_ => (),
}
}
fn setup_wayland() -> DisplayConnection { let display =
wayland_client::Display::connect_to_env().expect("unable to connect to the wayland server"); letmut event_queue = display.create_event_queue(); let attached_display = display.clone().attach(event_queue.token());
let globals = wayland_client::GlobalManager::new(&attached_display);
// Roundtrip to retrieve the globals list
event_queue
.sync_roundtrip(&mut (), |_, _, _| unreachable!())
.unwrap();
// Get the compositor. let compositor: Main<WlCompositor> = globals.instantiate_exact(1).unwrap();
// Xdg protocol. let xdg: Main<XdgWmBase> = globals.instantiate_exact(1).unwrap();
xdg.quick_assign(process_xdg_event);
match event {
Configure { serial } => { iflet Some(surface) = weak_surface.upgrade() { if !surface.initialized.swap(true, Ordering::Relaxed) { let wl_egl_surface =
wayland_egl::WlEglSurface::new(&surface.handle, width, height);
let egl_surface = unsafe {
egl.create_window_surface(
egl_display,
egl_config,
wl_egl_surface.ptr() as egl::NativeWindowType,
None,
)
.expect("unable to create an EGL surface")
};
egl.make_current(
egl_display,
Some(egl_surface),
Some(egl_surface),
Some(egl_context),
)
.expect("unable to bind the context");
render();
egl.swap_buffers(egl_display, egl_surface)
.expect("unable to post the surface content");
fn main() { // Setup Open GL.
egl.bind_api(egl::OPENGL_API)
.expect("unable to select OpenGL API");
gl::load_with(|name| egl.get_proc_address(name).unwrap() as *const std::ffi::c_void);
// Setup the Wayland client. letmut ctx = setup_wayland();
// Setup EGL. let egl_display = setup_egl(&ctx.display); let (egl_context, egl_config) = create_context(egl_display);
// Create a surface. // Note that it must be kept alive to the end of execution. let _surface = create_surface(&ctx, egl_display, egl_context, egl_config, 800, 600);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.