Skip to main content

duku/
lib.rs

1// Oliver Berzs
2// https://github.com/oberzs/duku
3
4// Duku is a Vulkan rendering engine
5
6//! This Rust crate makes it easy to render 2D and 3D graphics.
7//!
8//! # Example
9//!
10//! ```no_run
11//! // This example draws a cube in the center of the window,
12//! // rotating and coloring it based on the time that has passed.
13//!
14//! use duku::Camera;
15//! use duku::Duku;
16//! use duku::Hsb;
17//! use duku::Light;
18//! use duku::Result;
19//! use std::time::Instant;
20//!
21//! fn main() -> Result<()> {
22//!     // create duku context and window
23//!     let (mut duku, window) = Duku::windowed(500, 500)?;
24//!
25//!     // create 3D camera with 90 fov
26//!     let camera = Camera::perspective(90);
27//!
28//!     // create directional light
29//!     let light = Light::directional("#ffffff", [-1.0, -1.0, 1.0]);
30//!
31//!     // start timer for rotation and color
32//!     let timer = Instant::now();
33//!
34//!     // start window loop
35//!     window.while_open(move |_| {
36//!         // start drawing on window
37//!         duku.draw(Some(&camera), |t| {
38//!             // setup scene
39//!             t.background("#ababab");
40//!             t.light(light);
41//!
42//!             // get elapsed time since start
43//!             let elapsed = timer.elapsed().as_secs_f32();
44//!
45//!             // transform scene
46//!             let angle = elapsed * 45.0;
47//!             t.rotate_x(angle);
48//!             t.rotate_y(angle);
49//!             t.translate_z(2.0);
50//!
51//!             // draw cube
52//!             let hue = (elapsed * 60.0) as u16;
53//!             t.tint(Hsb::new(hue, 70, 80));
54//!             t.cube([1.0, 1.0, 1.0]);
55//!         });
56//!     });
57//!
58//!     Ok(())
59//! }
60//! ```
61//!
62//! More usage examples can be found [here](https://github.com/oberzs/duku/tree/release/examples).
63
64#![warn(
65    rust_2018_idioms,
66    unused,
67    future_incompatible,
68    missing_docs,
69    missing_doc_code_examples,
70    unused_qualifications,
71    clippy::missing_const_for_fn,
72    clippy::unwrap_used,
73    clippy::cast_lossless,
74    clippy::clone_on_ref_ptr,
75    clippy::cognitive_complexity,
76    clippy::explicit_iter_loop,
77    clippy::explicit_into_iter_loop,
78    clippy::if_not_else,
79    clippy::imprecise_flops,
80    clippy::inefficient_to_string,
81    clippy::unused_self
82)]
83
84// should be imported first
85mod macros;
86
87mod buffer;
88mod color;
89mod device;
90mod duku;
91mod error;
92mod features;
93mod font;
94mod image;
95mod instance;
96mod math;
97mod mesh;
98mod pipeline;
99mod renderer;
100mod resources;
101mod surface;
102mod vk;
103
104// normal exports
105pub use self::duku::Duku;
106pub use self::duku::DukuBuilder;
107pub use color::Gradient;
108pub use color::Hsb;
109pub use color::Mix;
110pub use color::Rgb;
111pub use color::Rgbf;
112pub use device::Stats;
113pub use error::Error;
114pub use error::Result;
115pub use font::CharData;
116pub use font::Font;
117pub use font::FontData;
118pub use image::Canvas;
119pub use image::ColorSpace;
120pub use image::Cubemap;
121pub use image::CubemapSides;
122pub use image::Filter;
123pub use image::Format;
124pub use image::Mips;
125pub use image::Msaa;
126pub use image::Texture;
127pub use image::Wrap;
128pub use math::Mat4;
129pub use math::Quat;
130pub use math::Vec2;
131pub use math::Vec3;
132pub use math::Vec4;
133pub use mesh::Mesh;
134pub use mesh::Model;
135pub use mesh::ModelNode;
136pub use pipeline::Material;
137pub use pipeline::Shader;
138pub use renderer::BorderMode;
139pub use renderer::Camera;
140pub use renderer::Light;
141pub use renderer::LightType;
142pub use renderer::Pcf;
143pub use renderer::Projection;
144pub use renderer::ShapeMode;
145pub use renderer::Target;
146pub use resources::Handle;
147pub use resources::ReadGuard;
148pub use resources::WriteGuard;
149pub use surface::VSync;
150pub use surface::WindowHandle;
151
152// optional feature exports
153#[cfg(feature = "glsl")]
154pub use features::glsl;
155#[cfg(feature = "gltf")]
156pub use features::gltf;
157#[cfg(feature = "otf")]
158pub use features::otf;
159#[cfg(feature = "window")]
160pub use features::window;