ltk

Module egl_context

Source
Expand description

EGL bootstrap for the GPU rendering path.

Initialises an EGLDisplay from the Wayland connection, picks an EGLConfig, and creates an EGLContext. Tries GLES 3 first and falls back to GLES 2 if the driver does not advertise it. On success returns an EglContext holding a glow::Context already pointed at the resolved GL functions; on failure returns Err( reason ) so the caller can fall back to the software wl_shm path.

Per-surface, EglSurface wraps a wl_egl_window plus an EGLSurface pinned to the wayland surface. Resizing the wayland surface must call EglSurface::resize so the underlying buffer follows.

The bootstrap honours LTK_FORCE_SOFTWARE=1 by failing fast with a descriptive error. Backend selection is announced exactly once per process via eprintln!( "[ltk] render backend: {GLES3|GLES2|SOFTWARE (...)}" ) — the GPU branch logs from EglContext::new, the SOFTWARE branch from log_software_fallback (called by the integration site in draw.rs).

Structs§

  • Process-wide EGL display + GLES context. Cheap to clone because the heavy state (Arc<EglInstance>, Arc<glow::Context>) is reference-counted; the raw EGL handles are POD.
  • Runtime-free EGL target for code that wants a GPU crate::render::Canvas without going through ltk::run.
  • Per-Wayland-surface EGL window. egl_window owns the wl_egl_window; it must outlive surface because EGL keeps a raw pointer into it. egl and display are kept so that Drop can call eglDestroySurface without requiring a &EglContext at the call site.

Functions§