library: render: add Renderer trait
This commit is contained in:
parent
83ed6406ac
commit
9c6b9af31a
|
@ -1,4 +1,13 @@
|
|||
//! Define the different kinds of renderers for use on a given scene.
|
||||
use image::RgbImage;
|
||||
|
||||
/// Each renderer implements this trait, to be called after being built.
|
||||
pub trait Renderer {
|
||||
/// Render the [`Scene`] using the chosen rendering technique.
|
||||
///
|
||||
/// [`Scene`]: ../scene/scene/struct.Scene.html
|
||||
fn render(&self) -> RgbImage;
|
||||
}
|
||||
|
||||
mod raytracer;
|
||||
pub use raytracer::*;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use super::utils::*;
|
||||
use super::Renderer;
|
||||
use crate::scene::{Object, Scene};
|
||||
use crate::{
|
||||
core::{LightProperties, LinearColor, ReflTransEnum},
|
||||
|
@ -247,3 +248,9 @@ impl Raytracer {
|
|||
.sum()
|
||||
}
|
||||
}
|
||||
|
||||
impl Renderer for Raytracer {
|
||||
fn render(&self) -> RgbImage {
|
||||
self.render()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue