Skip to main content

Crate easydrm

Crate easydrm 

Source
Expand description

§EasyDRM - Minimal DRM/KMS Framework

EasyDRM provides a simple, GLFW-like API for direct rendering on Linux without a compositor (no X11, no Wayland). It’s designed for fullscreen applications, kiosks, embedded systems, or custom compositors.

§Features

  • Multi-monitor support with independent OpenGL ES contexts per monitor
  • Hot-plug detection - monitors can be added/removed at runtime
  • Zero-monitor graceful handling - doesn’t crash without monitors
  • Per-monitor user context - attach custom data (Skia, Cairo, etc.)
  • Refresh-rate grouping metadata for diagnostics or custom scheduling strategies
  • Atomic commits with proper fence synchronization
  • 3-state mode management for efficient mode setting

§Basic Usage

use easydrm::EasyDRM;

// Initialize without custom context
let mut easydrm = EasyDRM::init_empty().unwrap();

loop {
    // Wait for events (page flip, hotplug, etc.)
    easydrm.poll_events().unwrap();

    // Render to each monitor that's ready
    for monitor in easydrm.monitors() {
        if monitor.can_render() {
            monitor.make_current().unwrap();
            let gl = monitor.gl();
            unsafe {
                gl.Clear(gl::COLOR_BUFFER_BIT);
            }
        }
    }

    // Commit all drawn monitors
    easydrm.swap_buffers().unwrap();
}

§With Custom Context

use easydrm::EasyDRM;

struct MyContext {
    frame_count: u32,
}

let mut easydrm = EasyDRM::init(|req| {
    println!(
        "Monitor init: {}x{}, get symbol ptr example: {:?}",
        req.width,
        req.height,
        (req.get_proc_address)("glCreateShader")
    );
    MyContext { frame_count: 0 }
})
.unwrap();

for monitor in easydrm.monitors() {
    let ctx = monitor.context_mut();
    ctx.frame_count += 1;
}

Modules§

gl
OpenGL ES bindings generated at build time

Structs§

EasyDRM
GlesContext
Monitor
Represents a connected display monitor with a shared surfaceless GL context and a monitor-local explicit GBM swapchain.
MonitorContextCreationRequest
Data provided to the user callback when creating a per-monitor context.
SwapResult

Enums§

EasyDRMError
GlesContextError