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:
[]
= "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 representationnalgebra: For matrix math and transformationsline_drawing: For line rasterizationdrm: 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 PerfCounter;
let mut perf = new;
perf.start;
// Perform rendering
perf.end;
println!;
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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.