library: render: add Renderer trait

This commit is contained in:
Bruno BELANYI 2020-03-29 21:23:42 +02:00
parent 83ed6406ac
commit 9c6b9af31a
2 changed files with 16 additions and 0 deletions

View file

@ -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::*;

View file

@ -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()
}
}