drm-gfx 0.2.1

3D graphics rendering for direct rendering manager with optional tokio thread support
Documentation

drm-gfx

A 3D graphics rendering library for the Linux Direct Rendering Manager (DRM). This library provides a lightweight 3D rendering engine that works directly with the DRM interface, without requiring a full graphics stack or window manager.

Or to put it more bluntly: I stitched together https://github.com/Kezii/embedded-gfx/tree/master with https://github.com/Smithay/drm-rs/tree/develop without any care and threw it into https://github.com/FLimburg/drm-gfx .

Features

  • 3D mesh rendering with multiple render modes (Points, Lines, Solid, Directional Lighting)
  • Camera with configurable position, target, and field of view
  • Support for transformations and model matrices
  • Backface culling
  • Simple lighting model
  • Direct rendering to DRM framebuffers
  • Double buffering support
  • Performance counters for optimization

Usage

Add this to your Cargo.toml:

[dependencies]
drm-gfx = "0.2.1"

features

use feature tokio-thread to use drm-gfx in a tokio based application

Basic Example

screen resolution will be detected automatically (... it worked on my machine) cargo build -r [--features=tokio-threads]

Run the examples: cargo run -r --example triangles cargo run -r --features tokio-threads --example tokio-triangles

Supported Render Modes

  • Points: Renders just the vertices as points
  • Lines: Renders edges of the mesh as lines
  • Solid: Renders filled triangles with backface culling
  • SolidLightDir: Adds directional lighting to solid rendering

Dependencies

  • embedded-graphics-core: For pixel color representation
  • nalgebra: For matrix math and transformations
  • line_drawing: For line rasterization
  • drm: For interfacing with the Direct Rendering Manager

Performance

The library includes performance counters that can be used to measure rendering time and optimize your application.

use drm_gfx::perfcounter::PerfCounter;

let mut perf = PerfCounter::new();
perf.start();
// Perform rendering
perf.end();
println!("Rendering took {} ms", perf.elapsed_ms());

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

unit test disclaimer

All unit tests are autogenerated by some ai.