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.1.1"
features
use feature tokio-thread to use drm-gfx in a tokio based application
Basic Example
use K3dMesh;
use ;
use Drawable;
use ;
use ;
use Point3;
use PI;
use c_void;
// TODO: make this run time
// this needs to fit with the output from display creation
const WIDTH: usize = 1024;
const HEIGHT: usize = 600;
async
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!;
Framebuffer Optimization
For improved performance, the library supports double buffering:
use DoubleBuffer;
let mut buffer = new;
// In your render loop:
buffer.swap;
let framebuffer = buffer.get_front;
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.