pub struct Renderer { /* private fields */ }Expand description
Immediate mode renderer.
This object allows one to render graphics into arbitrary vectors, holding any QuantizePixel
types. The typical flow of each frame is as follows:
- Clear the framebuffer with
Renderer::clear_screen. - First pass object rendering with
Renderer::render. - Second pass text rendering with
Renderer::text_pass.
The end result may look something like this:
... . . .. ... . . . . .. . .. . .
.. . . .. ... . . ... ==. . . . . . . .. .. .
. .. .. ==+===================.. ...... . . ..
. . . ..##=++==========+=+====+=... ..... . .. .
.. . .####===.........+=====.. .. .. ...
. . ....... .###%%#.Example.=====...... . . .
. . . . . ####%.........=+== . .. . . .
. . .. .. . .##########+=====.. ... . . . . . . .
. .. . . . . .. ########==+==.=+ .... . ... . .
. . . . . .... ..######===. . +== .. .. . ..
.. .. .... . .. ###=== . . +++. .. .. ..
. ... .... . .. . .#= . ..++=... ... . .
. . . .. .. .. .. .... . .... .=++.. ... .
. ... ... . ... ... . ... ... . ++.Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn clear_screen<T: QuantizePixel>(
&mut self,
bg: &Background,
conv_params: &T::Params,
dithering: &mut impl Dithering,
buf: &mut Vec<T>,
w: usize,
h: usize,
)
pub fn clear_screen<T: QuantizePixel>( &mut self, bg: &Background, conv_params: &T::Params, dithering: &mut impl Dithering, buf: &mut Vec<T>, w: usize, h: usize, )
Clears the screen with specified background.
This function must be called before every Renderer::render call, because it sets
internal buffers up with specified dimensions.
The buf should be then passed to subsequent renderer calls, without having its dimensions
modified beforehand.
Sourcepub fn render<T: QuantizePixel, M: Material + ?Sized>(
&mut self,
camera: &Camera,
conv_params: &T::Params,
mats: &mut [impl AsMut<M>],
objects: &[Object],
dithering: &mut impl Dithering,
buf: &mut Vec<T>,
)
pub fn render<T: QuantizePixel, M: Material + ?Sized>( &mut self, camera: &Camera, conv_params: &T::Params, mats: &mut [impl AsMut<M>], objects: &[Object], dithering: &mut impl Dithering, buf: &mut Vec<T>, )
Draws objects on screen.
This function takes a list of objects, their materials, and draws them to given buffer.
Note that buf must be first cleared using Renderer::clear_screen function.
Sourcepub fn text_pass<T: PixelText + QuantizePixel>(
&mut self,
objects: &[Object],
buf: &mut Vec<T>,
)
pub fn text_pass<T: PixelText + QuantizePixel>( &mut self, objects: &[Object], buf: &mut Vec<T>, )
Draws text on top of rendered objects.
This function takes a list of objects (the identical set, to previously passed to
Renderer::render), and draws auxiliary text, if it was set.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Renderer
impl RefUnwindSafe for Renderer
impl Send for Renderer
impl Sync for Renderer
impl Unpin for Renderer
impl UnwindSafe for Renderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.