1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
use rand; use std::ops::{Deref, DerefMut}; use math::{FScalar, FVector4}; mod camera; mod mesh; pub mod pipeline; mod renderer; mod texture; pub use self::camera::{AspectRatio, Camera, Projection}; pub use self::mesh::{MeshBuffer, ToMeshBuffer}; pub use self::pipeline::{Transform, Vertex}; pub use self::renderer::{GlutinRenderer, MetaRenderer, Renderer, RenderError}; pub use self::texture::Texture; pub type Index = u32; pub struct Color(FVector4); impl Color { pub fn new(r: FScalar, g: FScalar, b: FScalar, a: FScalar) -> Self { Color(FVector4::new(r, g, b, a)) } pub fn random() -> Self { Color::new( rand::random::<FScalar>(), rand::random::<FScalar>(), rand::random::<FScalar>(), 1.0, ) } pub fn white() -> Self { Color::new(1.0, 1.0, 1.0, 1.0) } pub fn black() -> Self { Color::new(0.0, 0.0, 0.0, 1.0) } } impl Deref for Color { type Target = FVector4; fn deref(&self) -> &Self::Target { &self.0 } } impl DerefMut for Color { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } }