This Rust crate makes it easy to render 2D and 3D graphics.
A simple example that initiates duku, sets up a 3D camera and draws a cube on the screen.
```rust use duku::Color; use duku::Camera; use duku::Duku; use duku::Result;
fn main() -> Result<()> { // initialize duku and OS window with a size of 500x500 let (mut duku, window) = Duku::builder().build_window(500, 500).build()?;
// create a 3D perspective camera with an FOV of 90
let mut camera = Camera::perspective_autosized(90);
// move the camera to some location
// and make it look at the center of the world
camera.transform.move_by([2.0, 1.5, -2.0]);
camera.transform.look_at([0.0, 0.0, 0.0]);
// start up the main event loop
window.main_loop(move |_| {
// start drawing on the window using our camera
duku.draw_on_window(Some(&camera), |target| {
// set the background color to sky blue
target.clear = Color::SKY_BLUE;
// draw a cube at the center of the world
target.draw_cube();
});
});
Ok(())
} ```
This example uses the optional feature window
for OS window creation.
Want more? Check out these other [examples].
To use this crate, add this dependency to your Cargo.toml
file.
toml
[dependencies]
duku = "0.1.0"
This crate supports additional optional features that you can add
to your dependency in your Cargo.toml
file.
toml
[dependencies]
duku = { ... , features = ["feature-name"] }
The optional features include:
| Name | Uses | Description |
| -------- | -------------- | ------------------------------------- |
| window
| [winit] | adds OS window creation support |
| png
| [png] | adds png file loading support |
| jpeg
| [jpeg-decoder] | adds jpeg file loading support |
| gltf
| [gltf] | adds gltf file loading support |
| glsl
| [shaderc] | adds custom glsl file loading support |
| log
| n/a | adds informational logs |