Crate gbm[][src]

Expand description

Safe libgbm bindings for rust

The Generic Buffer Manager

This module provides an abstraction that the caller can use to request a buffer from the underlying memory management system for the platform.

This allows the creation of portable code whilst still allowing access to the underlying memory manager.

This library is best used in combination with drm-rs, provided through the drm-support feature.


use drm::control::{self, crtc, framebuffer};
use gbm::{BufferObjectFlags, Device, Format};

// ... init your drm device ...
let drm = init_drm_device();

// init a GBM device
let gbm = Device::new(drm).unwrap();

// create a 4x4 buffer
let mut bo = gbm
        BufferObjectFlags::SCANOUT | BufferObjectFlags::WRITE,
// write something to it (usually use import or egl rendering instead)
let buffer = {
    let mut buffer = Vec::new();
    for i in 0..1280 {
        for _ in 0..720 {
            buffer.push(if i % 2 == 0 { 0 } else { 255 });

// create a framebuffer from our buffer
let fb = gbm.add_framebuffer(&bo, 32, 32).unwrap();

// display it (and get a crtc, mode and connector before)
gbm.set_crtc(crtc_handle, Some(fb), (0, 0), &[con], Some(mode))


A GBM buffer object

Flags to indicate the intended use for the buffer - these are passed into Device::create_buffer_object().

An open GBM device

Thrown when the underlying GBM device was already destroyed

Type wrapping a foreign file destructor

A mapped buffer object

A GBM rendering surface

Thrown when the GBM device does not belong to the buffer object


Errors that may happen when locking the front buffer


Trait for types that allow to obtain the underlying raw libinput pointer.

Type Definitions

Abstraction representing the handle to a buffer allocated by the manager

An EGLImage handle