diff --git a/pathtracer/src/render/mod.rs b/pathtracer/src/render/mod.rs index dd37450..89cde0c 100644 --- a/pathtracer/src/render/mod.rs +++ b/pathtracer/src/render/mod.rs @@ -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::*; diff --git a/pathtracer/src/render/raytracer.rs b/pathtracer/src/render/raytracer.rs index f231189..b6c564d 100644 --- a/pathtracer/src/render/raytracer.rs +++ b/pathtracer/src/render/raytracer.rs @@ -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() + } +}